posthog-js 1.46.0 → 1.46.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- import { Integration, EventProcessor, Hub } from '@sentry/types';
2
-
3
1
  declare enum NodeType {
4
2
  Document = 0,
5
3
  DocumentType = 1,
@@ -951,9 +949,15 @@ declare class SessionIdManager {
951
949
  * @param {string} [prefix] Optional: Url of a self-hosted sentry instance (default: https://sentry.io/organizations/)
952
950
  */
953
951
 
954
- declare class SentryIntegration implements Integration {
952
+ declare type _SentryEventProcessor = any;
953
+ declare type _SentryHub = any;
954
+ interface _SentryIntegration {
955
+ name: string;
956
+ setupOnce(addGlobalEventProcessor: (callback: _SentryEventProcessor) => void, getCurrentHub: () => _SentryHub): void;
957
+ }
958
+ declare class SentryIntegration implements _SentryIntegration {
955
959
  name: string;
956
- setupOnce: (addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub) => void;
960
+ setupOnce: (addGlobalEventProcessor: (callback: _SentryEventProcessor) => void, getCurrentHub: () => _SentryHub) => void;
957
961
  constructor(_posthog: PostHog, organization?: string, projectId?: number, prefix?: string);
958
962
  }
959
963
 
package/dist/module.js CHANGED
@@ -921,7 +921,7 @@ var LZString = {
921
921
  }
922
922
  };
923
923
 
924
- var version = "1.46.0";
924
+ var version = "1.46.2";
925
925
 
926
926
  // e.g. Config.DEBUG = Config.DEBUG || instance.get_config('debug')
927
927
 
@@ -1407,7 +1407,7 @@ var _UUID = function () {
1407
1407
  };
1408
1408
 
1409
1409
  return function () {
1410
- var se = (window.screen.height * window.screen.width).toString(16);
1410
+ var se = typeof window !== 'undefined' ? (window.screen.height * window.screen.width).toString(16) : '0';
1411
1411
  return T() + '-' + R() + '-' + UA() + '-' + se + '-' + T();
1412
1412
  };
1413
1413
  }(); // _.isBlockedUA()
@@ -1756,19 +1756,19 @@ var _info = {
1756
1756
  properties: function properties() {
1757
1757
  return _extend(_strip_empty_properties({
1758
1758
  $os: _info.os(),
1759
- $browser: _info.browser(userAgent, navigator.vendor, window.opera),
1759
+ $browser: _info.browser(userAgent, navigator.vendor, win.opera),
1760
1760
  $device: _info.device(userAgent),
1761
1761
  $device_type: _info.deviceType(userAgent)
1762
1762
  }), {
1763
- $current_url: window.location.href,
1764
- $host: window.location.host,
1765
- $pathname: window.location.pathname,
1766
- $browser_version: _info.browserVersion(userAgent, navigator.vendor, window.opera),
1763
+ $current_url: win === null || win === void 0 ? void 0 : win.location.href,
1764
+ $host: win === null || win === void 0 ? void 0 : win.location.host,
1765
+ $pathname: win === null || win === void 0 ? void 0 : win.location.pathname,
1766
+ $browser_version: _info.browserVersion(userAgent, navigator.vendor, win.opera),
1767
1767
  $browser_language: _info.browserLanguage(),
1768
- $screen_height: window.screen.height,
1769
- $screen_width: window.screen.width,
1770
- $viewport_height: window.innerHeight,
1771
- $viewport_width: window.innerWidth,
1768
+ $screen_height: win === null || win === void 0 ? void 0 : win.screen.height,
1769
+ $screen_width: win === null || win === void 0 ? void 0 : win.screen.width,
1770
+ $viewport_height: win === null || win === void 0 ? void 0 : win.innerHeight,
1771
+ $viewport_width: win === null || win === void 0 ? void 0 : win.innerWidth,
1772
1772
  $lib: 'web',
1773
1773
  $lib_version: Config.LIB_VERSION,
1774
1774
  $insert_id: Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10),
@@ -1779,9 +1779,9 @@ var _info = {
1779
1779
  people_properties: function people_properties() {
1780
1780
  return _extend(_strip_empty_properties({
1781
1781
  $os: _info.os(),
1782
- $browser: _info.browser(userAgent, navigator.vendor, window.opera)
1782
+ $browser: _info.browser(userAgent, navigator.vendor, win.opera)
1783
1783
  }), {
1784
- $browser_version: _info.browserVersion(userAgent, navigator.vendor, window.opera)
1784
+ $browser_version: _info.browserVersion(userAgent, navigator.vendor, win.opera)
1785
1785
  });
1786
1786
  }
1787
1787
  };
@@ -2531,7 +2531,7 @@ var localStore = {
2531
2531
 
2532
2532
  var supported = true;
2533
2533
 
2534
- if (window) {
2534
+ if (typeof window !== 'undefined') {
2535
2535
  try {
2536
2536
  var key = '__mplssupport__',
2537
2537
  val = 'xyz';
@@ -2673,7 +2673,7 @@ var sessionStore = {
2673
2673
 
2674
2674
  sessionStorageSupported = true;
2675
2675
 
2676
- if (window) {
2676
+ if (typeof window !== 'undefined') {
2677
2677
  try {
2678
2678
  var key = '__support__',
2679
2679
  val = 'xyz';
@@ -5892,7 +5892,7 @@ var RetryQueue = /*#__PURE__*/function (_RequestQueueScaffold) {
5892
5892
  _this.areWeOnline = true;
5893
5893
  _this.onXHRError = onXHRError;
5894
5894
 
5895
- if ('onLine' in window.navigator) {
5895
+ if (typeof window !== 'undefined' && 'onLine' in window.navigator) {
5896
5896
  _this.areWeOnline = window.navigator.onLine;
5897
5897
  window.addEventListener('online', function () {
5898
5898
  _this._handleWeAreNowOnline();
@@ -6241,12 +6241,19 @@ var SessionIdManager = /*#__PURE__*/function () {
6241
6241
  * @param {Number} [projectId] Optional: The Sentry project id, used to send a direct link from PostHog to Sentry
6242
6242
  * @param {string} [prefix] Optional: Url of a self-hosted sentry instance (default: https://sentry.io/organizations/)
6243
6243
  */
6244
+ // NOTE - we can't import from @sentry/types because it changes frequently and causes clashes
6245
+ // We only use a small subset of the types, so we can just define the integration overall and use any for the rest
6246
+ // import {
6247
+ // Event as _SentryEvent,
6248
+ // EventProcessor as _SentryEventProcessor,
6249
+ // Hub as _SentryHub,
6250
+ // Integration as _SentryIntegration,
6251
+ // } from '@sentry/types'
6252
+ // Uncomment the above and comment the below to get type checking for development
6244
6253
  var SentryIntegration = /*#__PURE__*/_createClass(function SentryIntegration(_posthog, organization, projectId, prefix) {
6245
6254
  _classCallCheck(this, SentryIntegration);
6246
6255
 
6247
6256
  // setupOnce gets called by Sentry when it intializes the plugin
6248
- // 'this' is not this: PostHogLib object, but the new class that's created.
6249
- // TODO: refactor to a real class. The types
6250
6257
  this.name = 'posthog-js';
6251
6258
 
6252
6259
  this.setupOnce = function (addGlobalEventProcessor) {