posthog-js 1.138.0 → 1.138.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.
Files changed (57) hide show
  1. package/dist/array.full.js +2 -2
  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/lib/src/extensions/replay/rrweb-plugins/patch.d.ts +3 -0
  8. package/dist/lib/src/extensions/sentry-integration.d.ts +22 -2
  9. package/dist/lib/src/extensions/surveys/surveys-utils.d.ts +2 -0
  10. package/dist/lib/src/extensions/tracing-headers.d.ts +10 -0
  11. package/dist/lib/src/loader-recorder.d.ts +0 -3
  12. package/dist/lib/src/loader-tracing-headers.d.ts +1 -0
  13. package/dist/lib/src/posthog-core.d.ts +2 -1
  14. package/dist/lib/src/posthog-surveys-types.d.ts +2 -0
  15. package/dist/lib/src/types.d.ts +5 -0
  16. package/dist/module.d.ts +29 -2
  17. package/dist/module.js +1 -1
  18. package/dist/module.js.map +1 -1
  19. package/dist/recorder-v2.js +1 -1
  20. package/dist/recorder-v2.js.map +1 -1
  21. package/dist/recorder.js +1 -1
  22. package/dist/recorder.js.map +1 -1
  23. package/dist/surveys-module-previews.js +1 -1
  24. package/dist/surveys-module-previews.js.map +1 -1
  25. package/dist/surveys.js +1 -1
  26. package/dist/surveys.js.map +1 -1
  27. package/dist/tracing-headers.js +2 -0
  28. package/dist/tracing-headers.js.map +1 -0
  29. package/lib/package.json +2 -2
  30. package/lib/src/extensions/replay/rrweb-plugins/patch.d.ts +3 -0
  31. package/lib/src/extensions/replay/rrweb-plugins/patch.js +39 -0
  32. package/lib/src/extensions/replay/rrweb-plugins/patch.js.map +1 -0
  33. package/lib/src/extensions/sentry-integration.d.ts +22 -2
  34. package/lib/src/extensions/sentry-integration.js +55 -39
  35. package/lib/src/extensions/sentry-integration.js.map +1 -1
  36. package/lib/src/extensions/surveys/surveys-utils.d.ts +2 -0
  37. package/lib/src/extensions/surveys/surveys-utils.jsx +37 -3
  38. package/lib/src/extensions/surveys/surveys-utils.jsx.map +1 -1
  39. package/lib/src/extensions/surveys.jsx +5 -20
  40. package/lib/src/extensions/surveys.jsx.map +1 -1
  41. package/lib/src/extensions/tracing-headers.d.ts +10 -0
  42. package/lib/src/extensions/tracing-headers.js +51 -0
  43. package/lib/src/extensions/tracing-headers.js.map +1 -0
  44. package/lib/src/loader-recorder.d.ts +0 -3
  45. package/lib/src/loader-recorder.js +2 -42
  46. package/lib/src/loader-recorder.js.map +1 -1
  47. package/lib/src/loader-tracing-headers.d.ts +1 -0
  48. package/lib/src/loader-tracing-headers.js +87 -0
  49. package/lib/src/loader-tracing-headers.js.map +1 -0
  50. package/lib/src/posthog-core.d.ts +2 -1
  51. package/lib/src/posthog-core.js +5 -1
  52. package/lib/src/posthog-core.js.map +1 -1
  53. package/lib/src/posthog-surveys-types.d.ts +2 -0
  54. package/lib/src/posthog-surveys-types.js.map +1 -1
  55. package/lib/src/types.d.ts +5 -0
  56. package/lib/src/types.js.map +1 -1
  57. package/package.json +2 -2
@@ -0,0 +1,3 @@
1
+ export declare function patch(source: {
2
+ [key: string]: any;
3
+ }, name: string, replacement: (...args: unknown[]) => unknown): () => void;
@@ -16,15 +16,35 @@
16
16
  * @param {string} [prefix] Optional: Url of a self-hosted sentry instance (default: https://sentry.io/organizations/)
17
17
  */
18
18
  import { PostHog } from '../posthog-core';
19
+ type _SentryEvent = any;
19
20
  type _SentryEventProcessor = any;
20
21
  type _SentryHub = any;
21
- interface _SentryIntegration {
22
+ interface _SentryIntegrationClass {
22
23
  name: string;
23
24
  setupOnce(addGlobalEventProcessor: (callback: _SentryEventProcessor) => void, getCurrentHub: () => _SentryHub): void;
24
25
  }
26
+ interface _SentryIntegration {
27
+ name: string;
28
+ processEvent(event: _SentryEvent): _SentryEvent;
29
+ }
25
30
  declare const severityLevels: readonly ["fatal", "error", "warning", "log", "info", "debug"];
26
31
  declare type _SeverityLevel = typeof severityLevels[number];
27
- export declare class SentryIntegration implements _SentryIntegration {
32
+ export type SentryIntegrationOptions = {
33
+ organization?: string;
34
+ projectId?: number;
35
+ prefix?: string;
36
+ /**
37
+ * By default, only errors are sent to PostHog. You can set this to '*' to send all events.
38
+ * Or to an error of SeverityLevel to only send events matching the provided levels.
39
+ * e.g. ['error', 'fatal'] to send only errors and fatals
40
+ * e.g. ['error'] to send only errors -- the default when omitted
41
+ * e.g. '*' to send all events
42
+ */
43
+ severityAllowList?: _SeverityLevel[] | '*';
44
+ };
45
+ export declare function createEventProcessor(_posthog: PostHog, { organization, projectId, prefix, severityAllowList }?: SentryIntegrationOptions): (event: _SentryEvent) => _SentryEvent;
46
+ export declare function sentryIntegration(_posthog: PostHog, options?: SentryIntegrationOptions): _SentryIntegration;
47
+ export declare class SentryIntegration implements _SentryIntegrationClass {
28
48
  name: string;
29
49
  setupOnce: (addGlobalEventProcessor: (callback: _SentryEventProcessor) => void, getCurrentHub: () => _SentryHub) => void;
30
50
  constructor(_posthog: PostHog, organization?: string, projectId?: number, prefix?: string,
@@ -8,9 +8,11 @@ export declare const defaultSurveyAppearance: SurveyAppearance;
8
8
  export declare const defaultBackgroundColor = "#eeeded";
9
9
  export declare const createShadow: (styleSheet: string, surveyId: string) => ShadowRoot;
10
10
  export declare const sendSurveyEvent: (responses: Record<string, string | number | string[] | null> | undefined, survey: Survey, posthog?: PostHog) => void;
11
+ export declare const dismissedSurveyEvent: (survey: Survey, posthog?: PostHog, readOnly?: boolean) => void;
11
12
  export declare const shuffle: (array: any[]) => any[];
12
13
  export declare const getDisplayOrderChoices: (question: MultipleSurveyQuestion) => string[];
13
14
  export declare const getDisplayOrderQuestions: (survey: Survey) => SurveyQuestion[];
15
+ export declare const getSurveySeenKey: (survey: Survey) => string;
14
16
  export declare const SurveyContext: import("preact").Context<{
15
17
  isPreviewMode: boolean;
16
18
  previewPageIndex: number | undefined;
@@ -0,0 +1,10 @@
1
+ import { PostHog } from '../posthog-core';
2
+ export declare class TracingHeaders {
3
+ private readonly instance;
4
+ private _restoreXHRPatch;
5
+ private _restoreFetchPatch;
6
+ constructor(instance: PostHog);
7
+ private _loadScript;
8
+ startIfEnabledOrStop(): void;
9
+ private _startCapturing;
10
+ }
@@ -5,9 +5,6 @@ export type NetworkData = {
5
5
  requests: CapturedNetworkRequest[];
6
6
  isInitial?: boolean;
7
7
  };
8
- export declare function patch(source: {
9
- [key: string]: any;
10
- }, name: string, replacement: (...args: unknown[]) => unknown): () => void;
11
8
  export declare function findLast<T>(array: Array<T>, predicate: (value: T) => boolean): T | undefined;
12
9
  export declare const NETWORK_PLUGIN_NAME = "rrweb/network@1";
13
10
  export declare const getRecordNetworkPlugin: (options?: NetworkRecordOptions) => RecordPlugin;
@@ -0,0 +1 @@
1
+ export {};
@@ -7,7 +7,7 @@ import { RetryQueue } from './retry-queue';
7
7
  import { SessionIdManager } from './sessionid';
8
8
  import { RequestRouter } from './utils/request-router';
9
9
  import { CaptureOptions, CaptureResult, Compression, DecideResponse, EarlyAccessFeatureCallback, IsFeatureEnabledOptions, JsonType, PostHogConfig, Properties, Property, QueuedRequestOptions, RequestCallback, SessionIdChangedCallback, SnippetArrayItem, ToolbarParams } from './types';
10
- import { SentryIntegration } from './extensions/sentry-integration';
10
+ import { SentryIntegration, SentryIntegrationOptions, sentryIntegration } from './extensions/sentry-integration';
11
11
  import { PageViewManager } from './page-view';
12
12
  import { PostHogSurveys } from './posthog-surveys';
13
13
  import { RateLimiter } from './rate-limiter';
@@ -56,6 +56,7 @@ export declare class PostHog {
56
56
  decideEndpointWasHit: boolean;
57
57
  analyticsDefaultEndpoint: string;
58
58
  SentryIntegration: typeof SentryIntegration;
59
+ sentryIntegration: (options?: SentryIntegrationOptions) => ReturnType<typeof sentryIntegration>;
59
60
  private _debugEventEmitter;
60
61
  /** DEPRECATED: We keep this to support existing usage but now one should just call .setPersonProperties */
61
62
  people: {
@@ -99,5 +99,7 @@ export interface Survey {
99
99
  } | null;
100
100
  start_date: string | null;
101
101
  end_date: string | null;
102
+ current_iteration: number | null;
103
+ current_iteration_start_date: string | null;
102
104
  }
103
105
  export {};
@@ -154,6 +154,11 @@ export interface PostHogConfig {
154
154
  /** How many events can be captured in a burst. This defaults to 10 times the events_per_second count */
155
155
  events_burst_limit?: number;
156
156
  };
157
+ /**
158
+ * PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION
159
+ * whether to wrap fetch and add tracing headers to the request
160
+ * */
161
+ __add_tracing_headers?: boolean;
157
162
  }
158
163
  export interface OptInOutCapturingOptions {
159
164
  capture: (event: string, properties: Properties, options: CaptureOptions) => void;
package/dist/module.d.ts CHANGED
@@ -286,6 +286,11 @@ interface PostHogConfig {
286
286
  /** How many events can be captured in a burst. This defaults to 10 times the events_per_second count */
287
287
  events_burst_limit?: number;
288
288
  };
289
+ /**
290
+ * PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION
291
+ * whether to wrap fetch and add tracing headers to the request
292
+ * */
293
+ __add_tracing_headers?: boolean;
289
294
  }
290
295
  interface OptInOutCapturingOptions {
291
296
  capture: (event: string, properties: Properties, options: CaptureOptions) => void;
@@ -1101,15 +1106,34 @@ declare class RequestRouter {
1101
1106
  * @param {string} [prefix] Optional: Url of a self-hosted sentry instance (default: https://sentry.io/organizations/)
1102
1107
  */
1103
1108
 
1109
+ type _SentryEvent = any;
1104
1110
  type _SentryEventProcessor = any;
1105
1111
  type _SentryHub = any;
1106
- interface _SentryIntegration {
1112
+ interface _SentryIntegrationClass {
1107
1113
  name: string;
1108
1114
  setupOnce(addGlobalEventProcessor: (callback: _SentryEventProcessor) => void, getCurrentHub: () => _SentryHub): void;
1109
1115
  }
1116
+ interface _SentryIntegration {
1117
+ name: string;
1118
+ processEvent(event: _SentryEvent): _SentryEvent;
1119
+ }
1110
1120
  declare const severityLevels: readonly ["fatal", "error", "warning", "log", "info", "debug"];
1111
1121
  declare type _SeverityLevel = typeof severityLevels[number];
1112
- declare class SentryIntegration implements _SentryIntegration {
1122
+ type SentryIntegrationOptions = {
1123
+ organization?: string;
1124
+ projectId?: number;
1125
+ prefix?: string;
1126
+ /**
1127
+ * By default, only errors are sent to PostHog. You can set this to '*' to send all events.
1128
+ * Or to an error of SeverityLevel to only send events matching the provided levels.
1129
+ * e.g. ['error', 'fatal'] to send only errors and fatals
1130
+ * e.g. ['error'] to send only errors -- the default when omitted
1131
+ * e.g. '*' to send all events
1132
+ */
1133
+ severityAllowList?: _SeverityLevel[] | '*';
1134
+ };
1135
+ declare function sentryIntegration(_posthog: PostHog, options?: SentryIntegrationOptions): _SentryIntegration;
1136
+ declare class SentryIntegration implements _SentryIntegrationClass {
1113
1137
  name: string;
1114
1138
  setupOnce: (addGlobalEventProcessor: (callback: _SentryEventProcessor) => void, getCurrentHub: () => _SentryHub) => void;
1115
1139
  constructor(_posthog: PostHog, organization?: string, projectId?: number, prefix?: string,
@@ -1244,6 +1268,8 @@ interface Survey {
1244
1268
  } | null;
1245
1269
  start_date: string | null;
1246
1270
  end_date: string | null;
1271
+ current_iteration: number | null;
1272
+ current_iteration_start_date: string | null;
1247
1273
  }
1248
1274
 
1249
1275
  declare class SurveyEventReceiver {
@@ -1457,6 +1483,7 @@ declare class PostHog {
1457
1483
  decideEndpointWasHit: boolean;
1458
1484
  analyticsDefaultEndpoint: string;
1459
1485
  SentryIntegration: typeof SentryIntegration;
1486
+ sentryIntegration: (options?: SentryIntegrationOptions) => ReturnType<typeof sentryIntegration>;
1460
1487
  private _debugEventEmitter;
1461
1488
  /** DEPRECATED: We keep this to support existing usage but now one should just call .setPersonProperties */
1462
1489
  people: {