posthog-js 1.85.3 → 1.85.4

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.
Files changed (41) hide show
  1. package/dist/array.full.js +1 -1
  2. package/dist/array.full.js.map +1 -1
  3. package/dist/array.js +1 -1
  4. package/dist/array.js.map +1 -1
  5. package/dist/es.js +1 -1
  6. package/dist/es.js.map +1 -1
  7. package/dist/exception-autocapture.js +2 -0
  8. package/dist/exception-autocapture.js.map +1 -0
  9. package/dist/module.d.ts +0 -32
  10. package/dist/module.js +1 -1
  11. package/dist/module.js.map +1 -1
  12. package/lib/package.json +1 -1
  13. package/lib/src/decide.js +23 -10
  14. package/lib/src/decide.js.map +1 -1
  15. package/lib/src/extensions/exception-autocapture/error-conversion.js.map +1 -0
  16. package/lib/src/extensions/{exceptions/exception-autocapture.d.ts → exception-autocapture/index.d.ts} +1 -1
  17. package/lib/src/extensions/{exceptions/exception-autocapture.js → exception-autocapture/index.js} +9 -36
  18. package/lib/src/extensions/exception-autocapture/index.js.map +1 -0
  19. package/lib/src/extensions/exception-autocapture/stack-trace.js.map +1 -0
  20. package/lib/src/extensions/exception-autocapture/type-checking.js.map +1 -0
  21. package/lib/src/extensions/replay/sessionrecording.d.ts +0 -1
  22. package/lib/src/extensions/replay/sessionrecording.js +0 -3
  23. package/lib/src/extensions/replay/sessionrecording.js.map +1 -1
  24. package/lib/src/extensions/sentry-integration.js.map +1 -1
  25. package/lib/src/loader-exception-autocapture.d.ts +2 -0
  26. package/lib/src/loader-exception-autocapture.js +6 -0
  27. package/lib/src/loader-exception-autocapture.js.map +1 -0
  28. package/lib/src/posthog-core.d.ts +0 -3
  29. package/lib/src/posthog-core.js +0 -16
  30. package/lib/src/posthog-core.js.map +1 -1
  31. package/package.json +1 -1
  32. package/lib/src/extensions/exceptions/error-conversion.js.map +0 -1
  33. package/lib/src/extensions/exceptions/exception-autocapture.js.map +0 -1
  34. package/lib/src/extensions/exceptions/stack-trace.js.map +0 -1
  35. package/lib/src/extensions/exceptions/type-checking.js.map +0 -1
  36. /package/lib/src/extensions/{exceptions → exception-autocapture}/error-conversion.d.ts +0 -0
  37. /package/lib/src/extensions/{exceptions → exception-autocapture}/error-conversion.js +0 -0
  38. /package/lib/src/extensions/{exceptions → exception-autocapture}/stack-trace.d.ts +0 -0
  39. /package/lib/src/extensions/{exceptions → exception-autocapture}/stack-trace.js +0 -0
  40. /package/lib/src/extensions/{exceptions → exception-autocapture}/type-checking.d.ts +0 -0
  41. /package/lib/src/extensions/{exceptions → exception-autocapture}/type-checking.js +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"sentry-integration.js","sourceRoot":"","sources":["../../../src/extensions/sentry-integration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAmCH;IAQI,2BAAY,QAAiB,EAAE,YAAqB,EAAE,SAAkB,EAAE,MAAe;QACrF,gEAAgE;QAChE,IAAI,CAAC,IAAI,GAAG,YAAY,CAAA;QACxB,IAAI,CAAC,SAAS,GAAG,UAAU,uBAAkE;YACzF,uBAAuB,CAAC,UAAC,KAAmB;;gBACxC,IAAI,KAAK,CAAC,KAAK,KAAK,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ;oBAAE,OAAO,KAAK,CAAA;gBAC/D,IAAI,CAAC,KAAK,CAAC,IAAI;oBAAE,KAAK,CAAC,IAAI,GAAG,EAAE,CAAA;gBAEhC,IAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAA;gBAChE,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,GAAG,IAAI,GAAG,UAAU,GAAG,QAAQ,CAAC,eAAe,EAAE,CAAA;gBACjF,IAAI,QAAQ,CAAC,uBAAuB,EAAE,EAAE;oBACpC,KAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,GAAG,QAAQ,CAAC,sBAAsB,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;iBACjG;gBAED,IAAM,UAAU,GAAG,CAAA,MAAA,KAAK,CAAC,SAAS,0CAAE,MAAM,KAAI,EAAE,CAAA;gBAEhD,IAAM,IAAI,GAAgD;oBACtD,gCAAgC;oBAChC,kBAAkB,EAAE,MAAA,UAAU,CAAC,CAAC,CAAC,0CAAE,KAAK;oBACxC,eAAe,EAAE,MAAA,UAAU,CAAC,CAAC,CAAC,0CAAE,IAAI;oBACpC,oBAAoB,EAAE,IAAI,GAAG,UAAU,GAAG,QAAQ,CAAC,eAAe,EAAE;oBACpE,8BAA8B;oBAC9B,gBAAgB,EAAE,KAAK,CAAC,QAAQ;oBAChC,iBAAiB,EAAE,KAAK,CAAC,SAAS;oBAClC,yBAAyB,EAAE,MAAA,UAAU,CAAC,CAAC,CAAC,0CAAE,KAAK;oBAC/C,sBAAsB,EAAE,MAAA,UAAU,CAAC,CAAC,CAAC,0CAAE,IAAI;oBAC3C,YAAY,EAAE,KAAK,CAAC,IAAI;iBAC3B,CAAA;gBAED,IAAI,YAAY,IAAI,SAAS;oBACzB,IAAI,CAAC,aAAa,CAAC;wBACf,CAAC,MAAM,IAAI,kCAAkC,CAAC;4BAC9C,YAAY;4BACZ,mBAAmB;4BACnB,SAAS;4BACT,SAAS;4BACT,KAAK,CAAC,QAAQ,CAAA;gBACtB,QAAQ,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,CAAA;gBACpC,OAAO,KAAK,CAAA;YAChB,CAAC,CAAC,CAAA;QACN,CAAC,CAAA;IACL,CAAC;IACL,wBAAC;AAAD,CAAC,AAlDD,IAkDC","sourcesContent":["/**\n * Integrate Sentry with PostHog. This will add a direct link to the person in Sentry, and an $exception event in PostHog\n *\n * ### Usage\n *\n * Sentry.init({\n * dsn: 'https://example',\n * integrations: [\n * new posthog.SentryIntegration(posthog)\n * ]\n * })\n *\n * @param {Object} [posthog] The posthog object\n * @param {string} [organization] Optional: The Sentry organization, used to send a direct link from PostHog to Sentry\n * @param {Number} [projectId] Optional: The Sentry project id, used to send a direct link from PostHog to Sentry\n * @param {string} [prefix] Optional: Url of a self-hosted sentry instance (default: https://sentry.io/organizations/)\n */\n\nimport { PostHog } from '../posthog-core'\nimport { ErrorProperties } from './exceptions/error-conversion'\n\n// NOTE - we can't import from @sentry/types because it changes frequently and causes clashes\n// We only use a small subset of the types, so we can just define the integration overall and use any for the rest\n\n// import {\n// Event as _SentryEvent,\n// EventProcessor as _SentryEventProcessor,\n// Hub as _SentryHub,\n// Integration as _SentryIntegration,\n// } from '@sentry/types'\n\n// Uncomment the above and comment the below to get type checking for development\n\ntype _SentryEvent = any\ntype _SentryEventProcessor = any\ntype _SentryHub = any\n\ninterface _SentryIntegration {\n name: string\n setupOnce(addGlobalEventProcessor: (callback: _SentryEventProcessor) => void, getCurrentHub: () => _SentryHub): void\n}\n\ninterface SentryExceptionProperties {\n $sentry_event_id: any\n $sentry_exception: any\n $sentry_exception_message: any\n $sentry_exception_type: any\n $sentry_tags: any\n $sentry_url?: string\n}\n\nexport class SentryIntegration implements _SentryIntegration {\n name: string\n\n setupOnce: (\n addGlobalEventProcessor: (callback: _SentryEventProcessor) => void,\n getCurrentHub: () => _SentryHub\n ) => void\n\n constructor(_posthog: PostHog, organization?: string, projectId?: number, prefix?: string) {\n // setupOnce gets called by Sentry when it intializes the plugin\n this.name = 'posthog-js'\n this.setupOnce = function (addGlobalEventProcessor: (callback: _SentryEventProcessor) => void) {\n addGlobalEventProcessor((event: _SentryEvent) => {\n if (event.level !== 'error' || !_posthog.__loaded) return event\n if (!event.tags) event.tags = {}\n\n const host = _posthog.config.ui_host || _posthog.config.api_host\n event.tags['PostHog Person URL'] = host + '/person/' + _posthog.get_distinct_id()\n if (_posthog.sessionRecordingStarted()) {\n event.tags['PostHog Recording URL'] = _posthog.get_session_replay_url({ withTimestamp: true })\n }\n\n const exceptions = event.exception?.values || []\n\n const data: SentryExceptionProperties & ErrorProperties = {\n // PostHog Exception Properties,\n $exception_message: exceptions[0]?.value,\n $exception_type: exceptions[0]?.type,\n $exception_personURL: host + '/person/' + _posthog.get_distinct_id(),\n // Sentry Exception Properties\n $sentry_event_id: event.event_id,\n $sentry_exception: event.exception,\n $sentry_exception_message: exceptions[0]?.value,\n $sentry_exception_type: exceptions[0]?.type,\n $sentry_tags: event.tags,\n }\n\n if (organization && projectId)\n data['$sentry_url'] =\n (prefix || 'https://sentry.io/organizations/') +\n organization +\n '/issues/?project=' +\n projectId +\n '&query=' +\n event.event_id\n _posthog.capture('$exception', data)\n return event\n })\n }\n }\n}\n"]}
1
+ {"version":3,"file":"sentry-integration.js","sourceRoot":"","sources":["../../../src/extensions/sentry-integration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAkCH;IAQI,2BAAY,QAAiB,EAAE,YAAqB,EAAE,SAAkB,EAAE,MAAe;QACrF,gEAAgE;QAChE,IAAI,CAAC,IAAI,GAAG,YAAY,CAAA;QACxB,IAAI,CAAC,SAAS,GAAG,UAAU,uBAAkE;YACzF,uBAAuB,CAAC,UAAC,KAAmB;;gBACxC,IAAI,KAAK,CAAC,KAAK,KAAK,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ;oBAAE,OAAO,KAAK,CAAA;gBAC/D,IAAI,CAAC,KAAK,CAAC,IAAI;oBAAE,KAAK,CAAC,IAAI,GAAG,EAAE,CAAA;gBAEhC,IAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAA;gBAChE,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,GAAG,IAAI,GAAG,UAAU,GAAG,QAAQ,CAAC,eAAe,EAAE,CAAA;gBACjF,IAAI,QAAQ,CAAC,uBAAuB,EAAE,EAAE;oBACpC,KAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,GAAG,QAAQ,CAAC,sBAAsB,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;iBACjG;gBAED,IAAM,UAAU,GAAG,CAAA,MAAA,KAAK,CAAC,SAAS,0CAAE,MAAM,KAAI,EAAE,CAAA;gBAEhD,IAAM,IAAI,GAMN;oBACA,gCAAgC;oBAChC,kBAAkB,EAAE,MAAA,UAAU,CAAC,CAAC,CAAC,0CAAE,KAAK;oBACxC,eAAe,EAAE,MAAA,UAAU,CAAC,CAAC,CAAC,0CAAE,IAAI;oBACpC,oBAAoB,EAAE,IAAI,GAAG,UAAU,GAAG,QAAQ,CAAC,eAAe,EAAE;oBACpE,8BAA8B;oBAC9B,gBAAgB,EAAE,KAAK,CAAC,QAAQ;oBAChC,iBAAiB,EAAE,KAAK,CAAC,SAAS;oBAClC,yBAAyB,EAAE,MAAA,UAAU,CAAC,CAAC,CAAC,0CAAE,KAAK;oBAC/C,sBAAsB,EAAE,MAAA,UAAU,CAAC,CAAC,CAAC,0CAAE,IAAI;oBAC3C,YAAY,EAAE,KAAK,CAAC,IAAI;iBAC3B,CAAA;gBAED,IAAI,YAAY,IAAI,SAAS;oBACzB,IAAI,CAAC,aAAa,CAAC;wBACf,CAAC,MAAM,IAAI,kCAAkC,CAAC;4BAC9C,YAAY;4BACZ,mBAAmB;4BACnB,SAAS;4BACT,SAAS;4BACT,KAAK,CAAC,QAAQ,CAAA;gBACtB,QAAQ,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,CAAA;gBACpC,OAAO,KAAK,CAAA;YAChB,CAAC,CAAC,CAAA;QACN,CAAC,CAAA;IACL,CAAC;IACL,wBAAC;AAAD,CAAC,AAxDD,IAwDC","sourcesContent":["/**\n * Integrate Sentry with PostHog. This will add a direct link to the person in Sentry, and an $exception event in PostHog\n *\n * ### Usage\n *\n * Sentry.init({\n * dsn: 'https://example',\n * integrations: [\n * new posthog.SentryIntegration(posthog)\n * ]\n * })\n *\n * @param {Object} [posthog] The posthog object\n * @param {string} [organization] Optional: The Sentry organization, used to send a direct link from PostHog to Sentry\n * @param {Number} [projectId] Optional: The Sentry project id, used to send a direct link from PostHog to Sentry\n * @param {string} [prefix] Optional: Url of a self-hosted sentry instance (default: https://sentry.io/organizations/)\n */\n\nimport { PostHog } from '../posthog-core'\n\n// NOTE - we can't import from @sentry/types because it changes frequently and causes clashes\n// We only use a small subset of the types, so we can just define the integration overall and use any for the rest\n\n// import {\n// Event as _SentryEvent,\n// EventProcessor as _SentryEventProcessor,\n// Hub as _SentryHub,\n// Integration as _SentryIntegration,\n// } from '@sentry/types'\n\n// Uncomment the above and comment the below to get type checking for development\n\ntype _SentryEvent = any\ntype _SentryEventProcessor = any\ntype _SentryHub = any\n\ninterface _SentryIntegration {\n name: string\n setupOnce(addGlobalEventProcessor: (callback: _SentryEventProcessor) => void, getCurrentHub: () => _SentryHub): void\n}\n\ninterface SentryExceptionProperties {\n $sentry_event_id: any\n $sentry_exception: any\n $sentry_exception_message: any\n $sentry_exception_type: any\n $sentry_tags: any\n $sentry_url?: string\n}\n\nexport class SentryIntegration implements _SentryIntegration {\n name: string\n\n setupOnce: (\n addGlobalEventProcessor: (callback: _SentryEventProcessor) => void,\n getCurrentHub: () => _SentryHub\n ) => void\n\n constructor(_posthog: PostHog, organization?: string, projectId?: number, prefix?: string) {\n // setupOnce gets called by Sentry when it intializes the plugin\n this.name = 'posthog-js'\n this.setupOnce = function (addGlobalEventProcessor: (callback: _SentryEventProcessor) => void) {\n addGlobalEventProcessor((event: _SentryEvent) => {\n if (event.level !== 'error' || !_posthog.__loaded) return event\n if (!event.tags) event.tags = {}\n\n const host = _posthog.config.ui_host || _posthog.config.api_host\n event.tags['PostHog Person URL'] = host + '/person/' + _posthog.get_distinct_id()\n if (_posthog.sessionRecordingStarted()) {\n event.tags['PostHog Recording URL'] = _posthog.get_session_replay_url({ withTimestamp: true })\n }\n\n const exceptions = event.exception?.values || []\n\n const data: SentryExceptionProperties & {\n // two properties added to match any exception auto-capture\n // added manually to avoid any dependency on the lazily loaded content\n $exception_message: any\n $exception_type: any\n $exception_personURL: string\n } = {\n // PostHog Exception Properties,\n $exception_message: exceptions[0]?.value,\n $exception_type: exceptions[0]?.type,\n $exception_personURL: host + '/person/' + _posthog.get_distinct_id(),\n // Sentry Exception Properties\n $sentry_event_id: event.event_id,\n $sentry_exception: event.exception,\n $sentry_exception_message: exceptions[0]?.value,\n $sentry_exception_type: exceptions[0]?.type,\n $sentry_tags: event.tags,\n }\n\n if (organization && projectId)\n data['$sentry_url'] =\n (prefix || 'https://sentry.io/organizations/') +\n organization +\n '/issues/?project=' +\n projectId +\n '&query=' +\n event.event_id\n _posthog.capture('$exception', data)\n return event\n })\n }\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import { extendPostHog } from './extensions/exception-autocapture';
2
+ export default extendPostHog;
@@ -0,0 +1,6 @@
1
+ import { extendPostHog } from './extensions/exception-autocapture';
2
+ import { _isUndefined } from './utils';
3
+ var win = _isUndefined(window) ? {} : window;
4
+ win.extendPostHogWithExceptionAutoCapture = extendPostHog;
5
+ export default extendPostHog;
6
+ //# sourceMappingURL=loader-exception-autocapture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loader-exception-autocapture.js","sourceRoot":"","sources":["../../src/loader-exception-autocapture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAA;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAEtC,IAAM,GAAG,GAA+B,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAE,EAAoB,CAAC,CAAC,CAAC,MAAM,CAE5F;AAAC,GAAW,CAAC,qCAAqC,GAAG,aAAa,CAAA;AAEnE,eAAe,aAAa,CAAA","sourcesContent":["import { extendPostHog } from './extensions/exception-autocapture'\nimport { _isUndefined } from './utils'\n\nconst win: Window & typeof globalThis = _isUndefined(window) ? ({} as typeof window) : window\n\n;(win as any).extendPostHogWithExceptionAutoCapture = extendPostHog\n\nexport default extendPostHog\n"]}
@@ -9,7 +9,6 @@ import { SessionIdManager } from './sessionid';
9
9
  import { AutocaptureConfig, CaptureOptions, CaptureResult, Compression, EarlyAccessFeatureCallback, GDPROptions, isFeatureEnabledOptions, JSC, JsonType, OptInOutCapturingOptions, PostHogConfig, Properties, Property, RequestCallback, SessionIdChangedCallback, SnippetArrayItem, ToolbarParams, XHROptions } from './types';
10
10
  import { SentryIntegration } from './extensions/sentry-integration';
11
11
  import { PageViewManager } from './page-view';
12
- import { ExceptionObserver } from './extensions/exceptions/exception-autocapture';
13
12
  import { PostHogSurveys } from './posthog-surveys';
14
13
  import { RateLimiter } from './rate-limiter';
15
14
  import { SurveyCallback } from './posthog-surveys-types';
@@ -33,7 +32,6 @@ export declare class PostHog {
33
32
  _retryQueue?: RetryQueue;
34
33
  sessionRecording?: SessionRecording;
35
34
  webPerformance?: WebPerformanceObserver;
36
- exceptionAutocapture?: ExceptionObserver;
37
35
  _triggered_notifs: any;
38
36
  compression: Partial<Record<Compression, boolean>>;
39
37
  _jsc: JSC;
@@ -111,7 +109,6 @@ export declare class PostHog {
111
109
  * @param {Array} item A [function_name, args...] array to be executed
112
110
  */
113
111
  push(item: SnippetArrayItem): void;
114
- captureException(exception: Error, properties?: Properties): void;
115
112
  /**
116
113
  * Capture an event. This is the most important and
117
114
  * frequently used PostHog function.
@@ -54,7 +54,6 @@ import { SessionIdManager } from './sessionid';
54
54
  import { SentryIntegration } from './extensions/sentry-integration';
55
55
  import { createSegmentIntegration } from './extensions/segment-integration';
56
56
  import { PageViewManager } from './page-view';
57
- import { ExceptionObserver } from './extensions/exceptions/exception-autocapture';
58
57
  import { PostHogSurveys } from './posthog-surveys';
59
58
  import { RateLimiter } from './rate-limiter';
60
59
  import { uuidv7 } from './uuidv7';
@@ -200,7 +199,6 @@ var create_phlib = function (token, config, name, createComplete) {
200
199
  if (instance.config.__preview_measure_pageview_stats) {
201
200
  instance.pageViewManager.startMeasuringScrollPosition();
202
201
  }
203
- instance.exceptionAutocapture = new ExceptionObserver(instance);
204
202
  instance.__autocapture = instance.config.autocapture;
205
203
  autocapture._setIsAutocaptureEnabled(instance);
206
204
  if (autocapture._isAutocaptureEnabled) {
@@ -678,20 +676,6 @@ var PostHog = /** @class */ (function () {
678
676
  PostHog.prototype.push = function (item) {
679
677
  this._execute_array([item]);
680
678
  };
681
- /*
682
- * PostHog supports exception autocapture, however, this function
683
- * is used to manually capture an exception
684
- * and can be used to add more context to that exception
685
- *
686
- * Properties passed as the second option will be merged with the properties
687
- * of the exception event.
688
- * Where there is a key in both generated exception and passed properties,
689
- * the generated exception property takes precedence.
690
- */
691
- PostHog.prototype.captureException = function (exception, properties) {
692
- var _a;
693
- (_a = this.exceptionAutocapture) === null || _a === void 0 ? void 0 : _a.captureException([exception.name, undefined, undefined, undefined, exception], properties);
694
- };
695
679
  /**
696
680
  * Capture an event. This is the most important and
697
681
  * frequently used PostHog function.