posthog-js 1.85.3 → 1.86.0

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 (43) 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 +5 -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 +26 -30
  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 +3 -4
  29. package/lib/src/posthog-core.js +38 -17
  30. package/lib/src/posthog-core.js.map +1 -1
  31. package/lib/src/types.d.ts +3 -0
  32. package/lib/src/types.js.map +1 -1
  33. package/package.json +1 -1
  34. package/lib/src/extensions/exceptions/error-conversion.js.map +0 -1
  35. package/lib/src/extensions/exceptions/exception-autocapture.js.map +0 -1
  36. package/lib/src/extensions/exceptions/stack-trace.js.map +0 -1
  37. package/lib/src/extensions/exceptions/type-checking.js.map +0 -1
  38. /package/lib/src/extensions/{exceptions → exception-autocapture}/error-conversion.d.ts +0 -0
  39. /package/lib/src/extensions/{exceptions → exception-autocapture}/error-conversion.js +0 -0
  40. /package/lib/src/extensions/{exceptions → exception-autocapture}/stack-trace.d.ts +0 -0
  41. /package/lib/src/extensions/{exceptions → exception-autocapture}/stack-trace.js +0 -0
  42. /package/lib/src/extensions/{exceptions → exception-autocapture}/type-checking.d.ts +0 -0
  43. /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"]}
@@ -6,10 +6,9 @@ import { Toolbar } from './extensions/toolbar';
6
6
  import { RequestQueue } from './request-queue';
7
7
  import { RetryQueue } from './retry-queue';
8
8
  import { SessionIdManager } from './sessionid';
9
- import { AutocaptureConfig, CaptureOptions, CaptureResult, Compression, EarlyAccessFeatureCallback, GDPROptions, isFeatureEnabledOptions, JSC, JsonType, OptInOutCapturingOptions, PostHogConfig, Properties, Property, RequestCallback, SessionIdChangedCallback, SnippetArrayItem, ToolbarParams, XHROptions } from './types';
9
+ import { AutocaptureConfig, CaptureOptions, CaptureResult, Compression, DecideResponse, 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;
@@ -41,6 +39,7 @@ export declare class PostHog {
41
39
  __request_queue: [url: string, data: Record<string, any>, options: XHROptions, callback?: RequestCallback][];
42
40
  __autocapture: boolean | AutocaptureConfig | undefined;
43
41
  decideEndpointWasHit: boolean;
42
+ analyticsDefaultEndpoint: string;
44
43
  SentryIntegration: typeof SentryIntegration;
45
44
  segmentIntegration: () => any;
46
45
  /** DEPRECATED: We keep this to support existing usage but now one should just call .setPersonProperties */
@@ -67,6 +66,7 @@ export declare class PostHog {
67
66
  */
68
67
  init(token: string, config?: Partial<PostHogConfig>, name?: string): PostHog | void;
69
68
  _init(token: string, config?: Partial<PostHogConfig>, name?: string, initComplete?: (instance: PostHog) => void): void;
69
+ _afterDecideResponse(response: DecideResponse): void;
70
70
  _loaded(): void;
71
71
  _start_queue_if_opted_in(): void;
72
72
  _dom_loaded(): void;
@@ -111,7 +111,6 @@ export declare class PostHog {
111
111
  * @param {Array} item A [function_name, args...] array to be executed
112
112
  */
113
113
  push(item: SnippetArrayItem): void;
114
- captureException(exception: Error, properties?: Properties): void;
115
114
  /**
116
115
  * Capture an event. This is the most important and
117
116
  * frequently used PostHog function.
@@ -9,6 +9,17 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
+ var __values = (this && this.__values) || function(o) {
13
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
14
+ if (m) return m.call(o);
15
+ if (o && typeof o.length === "number") return {
16
+ next: function () {
17
+ if (o && i >= o.length) o = void 0;
18
+ return { value: o && o[i++], done: !o };
19
+ }
20
+ };
21
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
22
+ };
12
23
  var __read = (this && this.__read) || function (o, n) {
13
24
  var m = typeof Symbol === "function" && o[Symbol.iterator];
14
25
  if (!m) return o;
@@ -54,7 +65,6 @@ import { SessionIdManager } from './sessionid';
54
65
  import { SentryIntegration } from './extensions/sentry-integration';
55
66
  import { createSegmentIntegration } from './extensions/segment-integration';
56
67
  import { PageViewManager } from './page-view';
57
- import { ExceptionObserver } from './extensions/exceptions/exception-autocapture';
58
68
  import { PostHogSurveys } from './posthog-surveys';
59
69
  import { RateLimiter } from './rate-limiter';
60
70
  import { uuidv7 } from './uuidv7';
@@ -200,7 +210,6 @@ var create_phlib = function (token, config, name, createComplete) {
200
210
  if (instance.config.__preview_measure_pageview_stats) {
201
211
  instance.pageViewManager.startMeasuringScrollPosition();
202
212
  }
203
- instance.exceptionAutocapture = new ExceptionObserver(instance);
204
213
  instance.__autocapture = instance.config.autocapture;
205
214
  autocapture._setIsAutocaptureEnabled(instance);
206
215
  if (autocapture._isAutocaptureEnabled) {
@@ -251,6 +260,7 @@ var PostHog = /** @class */ (function () {
251
260
  this.__loaded_recorder_version = undefined;
252
261
  this.__autocapture = undefined;
253
262
  this._jsc = function () { };
263
+ this.analyticsDefaultEndpoint = '/e/';
254
264
  this.featureFlags = new PostHogFeatureFlags(this);
255
265
  this.toolbar = new Toolbar(this);
256
266
  this.pageViewManager = new PageViewManager();
@@ -432,6 +442,31 @@ var PostHog = /** @class */ (function () {
432
442
  updateInitComplete('syncCode')();
433
443
  };
434
444
  // Private methods
445
+ PostHog.prototype._afterDecideResponse = function (response) {
446
+ var e_1, _a;
447
+ var _b;
448
+ this.compression = {};
449
+ if (response.supportedCompression && !this.config.disable_compression) {
450
+ var compression = {};
451
+ try {
452
+ for (var _c = __values(response['supportedCompression']), _d = _c.next(); !_d.done; _d = _c.next()) {
453
+ var method = _d.value;
454
+ compression[method] = true;
455
+ }
456
+ }
457
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
458
+ finally {
459
+ try {
460
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
461
+ }
462
+ finally { if (e_1) throw e_1.error; }
463
+ }
464
+ this.compression = compression;
465
+ }
466
+ if ((_b = response.analytics) === null || _b === void 0 ? void 0 : _b.endpoint) {
467
+ this.analyticsDefaultEndpoint = response.analytics.endpoint;
468
+ }
469
+ };
435
470
  PostHog.prototype._loaded = function () {
436
471
  // Pause `reloadFeatureFlags` calls in config.loaded callback.
437
472
  // These feature flags are loaded in the decide call made right
@@ -678,20 +713,6 @@ var PostHog = /** @class */ (function () {
678
713
  PostHog.prototype.push = function (item) {
679
714
  this._execute_array([item]);
680
715
  };
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
716
  /**
696
717
  * Capture an event. This is the most important and
697
718
  * frequently used PostHog function.
@@ -760,7 +781,7 @@ var PostHog = /** @class */ (function () {
760
781
  }
761
782
  logger.info('send', data);
762
783
  var jsonData = JSON.stringify(data);
763
- var url = this.config.api_host + (options.endpoint || '/e/');
784
+ var url = this.config.api_host + (options.endpoint || this.analyticsDefaultEndpoint);
764
785
  var has_unique_traits = options !== __NOOPTIONS;
765
786
  if (this.config.request_batching && (!has_unique_traits || options._batchKey) && !options.send_instantly) {
766
787
  this._requestQueue.enqueue(url, data, options);