posthog-js-lite 3.0.2 → 3.2.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/CHANGELOG.md +20 -3
- package/README.md +5 -1
- package/lib/index.cjs.js +129 -124
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +27 -16
- package/lib/index.esm.js +129 -124
- package/lib/index.esm.js.map +1 -1
- package/lib/posthog-core/src/index.d.ts +7 -4
- package/lib/posthog-core/src/types.d.ts +21 -13
- package/lib/posthog-web/src/storage.d.ts +1 -1
- package/lib/posthog-web/src/types.d.ts +1 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
type PostHogCoreOptions = {
|
|
2
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) */
|
|
@@ -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 '
|
|
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",
|
|
@@ -46,6 +48,8 @@ declare enum PostHogPersistedProperty {
|
|
|
46
48
|
Props = "props",
|
|
47
49
|
FeatureFlags = "feature_flags",
|
|
48
50
|
FeatureFlagPayloads = "feature_flag_payloads",
|
|
51
|
+
BootstrapFeatureFlags = "bootstrap_feature_flags",
|
|
52
|
+
BootstrapFeatureFlagPayloads = "bootstrap_feature_flag_payloads",
|
|
49
53
|
OverrideFeatureFlags = "override_feature_flags",
|
|
50
54
|
Queue = "queue",
|
|
51
55
|
OptedOut = "opted_out",
|
|
@@ -54,9 +58,11 @@ declare enum PostHogPersistedProperty {
|
|
|
54
58
|
PersonProperties = "person_properties",
|
|
55
59
|
GroupProperties = "group_properties",
|
|
56
60
|
InstalledAppBuild = "installed_app_build",
|
|
57
|
-
InstalledAppVersion = "installed_app_version"
|
|
61
|
+
InstalledAppVersion = "installed_app_version",
|
|
62
|
+
SessionReplay = "session_replay",
|
|
63
|
+
DecideEndpointWasHit = "decide_endpoint_was_hit"
|
|
58
64
|
}
|
|
59
|
-
|
|
65
|
+
type PostHogFetchOptions = {
|
|
60
66
|
method: 'GET' | 'POST' | 'PUT' | 'PATCH';
|
|
61
67
|
mode?: 'no-cors';
|
|
62
68
|
credentials?: 'omit';
|
|
@@ -66,22 +72,22 @@ declare type PostHogFetchOptions = {
|
|
|
66
72
|
body?: string;
|
|
67
73
|
signal?: AbortSignal;
|
|
68
74
|
};
|
|
69
|
-
|
|
75
|
+
type PostHogCaptureOptions = {
|
|
70
76
|
/** If provided overrides the auto-generated event ID */
|
|
71
77
|
uuid?: string;
|
|
72
78
|
/** If provided overrides the auto-generated timestamp */
|
|
73
79
|
timestamp?: Date;
|
|
74
80
|
disableGeoip?: boolean;
|
|
75
81
|
};
|
|
76
|
-
|
|
82
|
+
type PostHogFetchResponse = {
|
|
77
83
|
status: number;
|
|
78
84
|
text: () => Promise<string>;
|
|
79
85
|
json: () => Promise<any>;
|
|
80
86
|
};
|
|
81
|
-
|
|
87
|
+
type PostHogEventProperties = {
|
|
82
88
|
[key: string]: any;
|
|
83
89
|
};
|
|
84
|
-
|
|
90
|
+
type PostHogAutocaptureElement = {
|
|
85
91
|
$el_text?: string;
|
|
86
92
|
tag_name: string;
|
|
87
93
|
href?: string;
|
|
@@ -91,7 +97,7 @@ declare type PostHogAutocaptureElement = {
|
|
|
91
97
|
} & {
|
|
92
98
|
[key: string]: any;
|
|
93
99
|
};
|
|
94
|
-
|
|
100
|
+
type PostHogDecideResponse = {
|
|
95
101
|
config: {
|
|
96
102
|
enable_collect_everything: boolean;
|
|
97
103
|
};
|
|
@@ -108,9 +114,11 @@ declare type PostHogDecideResponse = {
|
|
|
108
114
|
[key: string]: JsonType;
|
|
109
115
|
};
|
|
110
116
|
errorsWhileComputingFlags: boolean;
|
|
111
|
-
sessionRecording
|
|
117
|
+
sessionRecording?: boolean | {
|
|
118
|
+
[key: string]: JsonType;
|
|
119
|
+
};
|
|
112
120
|
};
|
|
113
|
-
|
|
121
|
+
type JsonType = string | number | boolean | null | {
|
|
114
122
|
[key: string]: JsonType;
|
|
115
123
|
} | Array<JsonType>;
|
|
116
124
|
|
|
@@ -130,9 +138,9 @@ declare class SimpleEventEmitter {
|
|
|
130
138
|
}
|
|
131
139
|
|
|
132
140
|
declare abstract class PostHogCoreStateless {
|
|
133
|
-
|
|
134
|
-
host: string;
|
|
135
|
-
|
|
141
|
+
readonly apiKey: string;
|
|
142
|
+
readonly host: string;
|
|
143
|
+
readonly flushAt: number;
|
|
136
144
|
private maxBatchSize;
|
|
137
145
|
private maxQueueSize;
|
|
138
146
|
private flushInterval;
|
|
@@ -142,7 +150,8 @@ declare abstract class PostHogCoreStateless {
|
|
|
142
150
|
private captureMode;
|
|
143
151
|
private removeDebugCallback?;
|
|
144
152
|
private disableGeoip;
|
|
145
|
-
|
|
153
|
+
private historicalMigration;
|
|
154
|
+
protected disabled: boolean;
|
|
146
155
|
private defaultOptIn;
|
|
147
156
|
private pendingPromises;
|
|
148
157
|
protected _events: SimpleEventEmitter;
|
|
@@ -157,6 +166,7 @@ declare abstract class PostHogCoreStateless {
|
|
|
157
166
|
abstract getPersistedProperty<T>(key: PostHogPersistedProperty): T | undefined;
|
|
158
167
|
abstract setPersistedProperty<T>(key: PostHogPersistedProperty, value: T | null): void;
|
|
159
168
|
constructor(apiKey: string, options?: PostHogCoreOptions);
|
|
169
|
+
protected logMsgIfDebug(fn: () => void): void;
|
|
160
170
|
protected wrap(fn: () => void): void;
|
|
161
171
|
protected getCommonEventProperties(): any;
|
|
162
172
|
get optedOut(): boolean;
|
|
@@ -165,6 +175,7 @@ declare abstract class PostHogCoreStateless {
|
|
|
165
175
|
on(event: string, cb: (...args: any[]) => void): () => void;
|
|
166
176
|
debug(enabled?: boolean): void;
|
|
167
177
|
get isDebug(): boolean;
|
|
178
|
+
get isDisabled(): boolean;
|
|
168
179
|
private buildPayload;
|
|
169
180
|
protected addPendingPromise<T>(promise: Promise<T>): Promise<T>;
|
|
170
181
|
/***
|
|
@@ -308,7 +319,7 @@ declare abstract class PostHogCore extends PostHogCoreStateless {
|
|
|
308
319
|
overrideFeatureFlag(flags: PostHogDecideResponse['featureFlags'] | null): Promise<void>;
|
|
309
320
|
}
|
|
310
321
|
|
|
311
|
-
|
|
322
|
+
type PostHogOptions = {
|
|
312
323
|
autocapture?: boolean;
|
|
313
324
|
persistence?: 'localStorage' | 'sessionStorage' | 'cookie' | 'memory';
|
|
314
325
|
persistence_name?: string;
|