posthog-js-lite 3.0.1 → 3.1.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.
package/lib/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- declare type PostHogCoreOptions = {
2
- /** PostHog API host, usually 'https://app.posthog.com' or 'https://eu.posthog.com' */
1
+ type PostHogCoreOptions = {
2
+ /** PostHog API host, usually 'https://us.i.posthog.com' or 'https://eu.i.posthog.com' */
3
3
  host?: string;
4
4
  /** The number of events to queue before sending to PostHog (flushing) */
5
5
  flushAt?: number;
@@ -36,9 +36,11 @@ declare type PostHogCoreOptions = {
36
36
  featureFlagsRequestTimeoutMs?: number;
37
37
  /** For Session Analysis how long before we expire a session (defaults to 30 mins) */
38
38
  sessionExpirationTimeSeconds?: number;
39
- /** Whether to post events to PostHog in JSON or compressed format. Defaults to 'form' */
39
+ /** Whether to post events to PostHog in JSON or compressed format. Defaults to 'json' */
40
40
  captureMode?: 'json' | 'form';
41
41
  disableGeoip?: boolean;
42
+ /** Special flag to indicate ingested data is for a historical migration. */
43
+ historicalMigration?: boolean;
42
44
  };
43
45
  declare enum PostHogPersistedProperty {
44
46
  AnonymousId = "anonymous_id",
@@ -54,9 +56,10 @@ declare enum PostHogPersistedProperty {
54
56
  PersonProperties = "person_properties",
55
57
  GroupProperties = "group_properties",
56
58
  InstalledAppBuild = "installed_app_build",
57
- InstalledAppVersion = "installed_app_version"
59
+ InstalledAppVersion = "installed_app_version",
60
+ SessionReplay = "session_replay"
58
61
  }
59
- declare type PostHogFetchOptions = {
62
+ type PostHogFetchOptions = {
60
63
  method: 'GET' | 'POST' | 'PUT' | 'PATCH';
61
64
  mode?: 'no-cors';
62
65
  credentials?: 'omit';
@@ -66,22 +69,22 @@ declare type PostHogFetchOptions = {
66
69
  body?: string;
67
70
  signal?: AbortSignal;
68
71
  };
69
- declare type PostHogCaptureOptions = {
72
+ type PostHogCaptureOptions = {
70
73
  /** If provided overrides the auto-generated event ID */
71
74
  uuid?: string;
72
75
  /** If provided overrides the auto-generated timestamp */
73
76
  timestamp?: Date;
74
77
  disableGeoip?: boolean;
75
78
  };
76
- declare type PostHogFetchResponse = {
79
+ type PostHogFetchResponse = {
77
80
  status: number;
78
81
  text: () => Promise<string>;
79
82
  json: () => Promise<any>;
80
83
  };
81
- declare type PostHogEventProperties = {
84
+ type PostHogEventProperties = {
82
85
  [key: string]: any;
83
86
  };
84
- declare type PostHogAutocaptureElement = {
87
+ type PostHogAutocaptureElement = {
85
88
  $el_text?: string;
86
89
  tag_name: string;
87
90
  href?: string;
@@ -91,7 +94,7 @@ declare type PostHogAutocaptureElement = {
91
94
  } & {
92
95
  [key: string]: any;
93
96
  };
94
- declare type PostHogDecideResponse = {
97
+ type PostHogDecideResponse = {
95
98
  config: {
96
99
  enable_collect_everything: boolean;
97
100
  };
@@ -108,9 +111,11 @@ declare type PostHogDecideResponse = {
108
111
  [key: string]: JsonType;
109
112
  };
110
113
  errorsWhileComputingFlags: boolean;
111
- sessionRecording: boolean;
114
+ sessionRecording?: boolean | {
115
+ [key: string]: JsonType;
116
+ };
112
117
  };
113
- declare type JsonType = string | number | boolean | null | {
118
+ type JsonType = string | number | boolean | null | {
114
119
  [key: string]: JsonType;
115
120
  } | Array<JsonType>;
116
121
 
@@ -130,9 +135,9 @@ declare class SimpleEventEmitter {
130
135
  }
131
136
 
132
137
  declare abstract class PostHogCoreStateless {
133
- private apiKey;
134
- host: string;
135
- private flushAt;
138
+ readonly apiKey: string;
139
+ readonly host: string;
140
+ readonly flushAt: number;
136
141
  private maxBatchSize;
137
142
  private maxQueueSize;
138
143
  private flushInterval;
@@ -142,7 +147,8 @@ declare abstract class PostHogCoreStateless {
142
147
  private captureMode;
143
148
  private removeDebugCallback?;
144
149
  private disableGeoip;
145
- disabled: boolean;
150
+ private historicalMigration;
151
+ protected disabled: boolean;
146
152
  private defaultOptIn;
147
153
  private pendingPromises;
148
154
  protected _events: SimpleEventEmitter;
@@ -157,6 +163,7 @@ declare abstract class PostHogCoreStateless {
157
163
  abstract getPersistedProperty<T>(key: PostHogPersistedProperty): T | undefined;
158
164
  abstract setPersistedProperty<T>(key: PostHogPersistedProperty, value: T | null): void;
159
165
  constructor(apiKey: string, options?: PostHogCoreOptions);
166
+ protected logMsgIfDebug(fn: () => void): void;
160
167
  protected wrap(fn: () => void): void;
161
168
  protected getCommonEventProperties(): any;
162
169
  get optedOut(): boolean;
@@ -165,6 +172,7 @@ declare abstract class PostHogCoreStateless {
165
172
  on(event: string, cb: (...args: any[]) => void): () => void;
166
173
  debug(enabled?: boolean): void;
167
174
  get isDebug(): boolean;
175
+ get isDisabled(): boolean;
168
176
  private buildPayload;
169
177
  protected addPendingPromise<T>(promise: Promise<T>): Promise<T>;
170
178
  /***
@@ -308,7 +316,7 @@ declare abstract class PostHogCore extends PostHogCoreStateless {
308
316
  overrideFeatureFlag(flags: PostHogDecideResponse['featureFlags'] | null): Promise<void>;
309
317
  }
310
318
 
311
- declare type PostHogOptions = {
319
+ type PostHogOptions = {
312
320
  autocapture?: boolean;
313
321
  persistence?: 'localStorage' | 'sessionStorage' | 'cookie' | 'memory';
314
322
  persistence_name?: string;