posthog-js-lite 3.4.2 → 3.5.1
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 +22 -0
- package/README.md +19 -0
- package/lib/{index.cjs.js → index.cjs} +950 -199
- package/lib/index.cjs.map +1 -0
- package/lib/index.d.ts +661 -350
- package/lib/{index.esm.js → index.mjs} +950 -199
- package/lib/index.mjs.map +1 -0
- package/package.json +3 -3
- package/src/context.ts +1 -1
- package/src/patch.ts +50 -0
- package/src/posthog-web.ts +57 -8
- package/src/types.ts +2 -1
- package/test/posthog-web.spec.ts +193 -2
- package/tsconfig.json +1 -0
- package/lib/index.cjs.js.map +0 -1
- package/lib/index.esm.js.map +0 -1
- package/lib/posthog-core/src/eventemitter.d.ts +0 -8
- package/lib/posthog-core/src/index.d.ts +0 -207
- package/lib/posthog-core/src/lz-string.d.ts +0 -8
- package/lib/posthog-core/src/types.d.ts +0 -133
- package/lib/posthog-core/src/utils.d.ts +0 -15
- package/lib/posthog-core/src/vendor/uuidv7.d.ts +0 -179
- package/lib/posthog-web/index.d.ts +0 -3
- package/lib/posthog-web/src/context.d.ts +0 -1
- package/lib/posthog-web/src/posthog-web.d.ts +0 -16
- package/lib/posthog-web/src/storage.d.ts +0 -10
- package/lib/posthog-web/src/types.d.ts +0 -6
package/lib/index.d.ts
CHANGED
|
@@ -1,363 +1,674 @@
|
|
|
1
|
-
type PostHogCoreOptions = {
|
|
2
|
-
/** PostHog API host, usually 'https://us.i.posthog.com' or 'https://eu.i.posthog.com' */
|
|
3
|
-
host?: string;
|
|
4
|
-
/** The number of events to queue before sending to PostHog (flushing) */
|
|
5
|
-
flushAt?: number;
|
|
6
|
-
/** The interval in milliseconds between periodic flushes */
|
|
7
|
-
flushInterval?: number;
|
|
8
|
-
/** The maximum number of queued messages to be flushed as part of a single batch (must be higher than `flushAt`) */
|
|
9
|
-
maxBatchSize?: number;
|
|
10
|
-
/** The maximum number of cached messages either in memory or on the local storage.
|
|
11
|
-
* Defaults to 1000, (must be higher than `flushAt`)
|
|
12
|
-
*/
|
|
13
|
-
maxQueueSize?: number;
|
|
14
|
-
/** If set to true the SDK is essentially disabled (useful for local environments where you don't want to track anything) */
|
|
15
|
-
disabled?: boolean;
|
|
16
|
-
/** If set to false the SDK will not track until the `optIn` function is called. */
|
|
17
|
-
defaultOptIn?: boolean;
|
|
18
|
-
/** Whether to track that `getFeatureFlag` was called (used by Experiments) */
|
|
19
|
-
sendFeatureFlagEvent?: boolean;
|
|
20
|
-
/** Whether to load feature flags when initialized or not */
|
|
21
|
-
preloadFeatureFlags?: boolean;
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
1
|
+
type PostHogCoreOptions = {
|
|
2
|
+
/** PostHog API host, usually 'https://us.i.posthog.com' or 'https://eu.i.posthog.com' */
|
|
3
|
+
host?: string;
|
|
4
|
+
/** The number of events to queue before sending to PostHog (flushing) */
|
|
5
|
+
flushAt?: number;
|
|
6
|
+
/** The interval in milliseconds between periodic flushes */
|
|
7
|
+
flushInterval?: number;
|
|
8
|
+
/** The maximum number of queued messages to be flushed as part of a single batch (must be higher than `flushAt`) */
|
|
9
|
+
maxBatchSize?: number;
|
|
10
|
+
/** The maximum number of cached messages either in memory or on the local storage.
|
|
11
|
+
* Defaults to 1000, (must be higher than `flushAt`)
|
|
12
|
+
*/
|
|
13
|
+
maxQueueSize?: number;
|
|
14
|
+
/** If set to true the SDK is essentially disabled (useful for local environments where you don't want to track anything) */
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
/** If set to false the SDK will not track until the `optIn` function is called. */
|
|
17
|
+
defaultOptIn?: boolean;
|
|
18
|
+
/** Whether to track that `getFeatureFlag` was called (used by Experiments) */
|
|
19
|
+
sendFeatureFlagEvent?: boolean;
|
|
20
|
+
/** Whether to load feature flags when initialized or not */
|
|
21
|
+
preloadFeatureFlags?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Whether to load remote config when initialized or not
|
|
24
|
+
* Experimental support
|
|
25
|
+
* Default: false - Remote config is loaded by default
|
|
26
|
+
*/
|
|
27
|
+
disableRemoteConfig?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Whether to load surveys when initialized or not
|
|
30
|
+
* Experimental support
|
|
31
|
+
* Default: false - Surveys are loaded by default, but requires the `PostHogSurveyProvider` to be used
|
|
32
|
+
*/
|
|
33
|
+
disableSurveys?: boolean;
|
|
34
|
+
/** Option to bootstrap the library with given distinctId and feature flags */
|
|
35
|
+
bootstrap?: {
|
|
36
|
+
distinctId?: string;
|
|
37
|
+
isIdentifiedId?: boolean;
|
|
38
|
+
featureFlags?: Record<string, FeatureFlagValue>;
|
|
39
|
+
featureFlagPayloads?: Record<string, JsonType>;
|
|
40
|
+
};
|
|
41
|
+
/** How many times we will retry HTTP requests. Defaults to 3. */
|
|
42
|
+
fetchRetryCount?: number;
|
|
43
|
+
/** The delay between HTTP request retries, Defaults to 3 seconds. */
|
|
44
|
+
fetchRetryDelay?: number;
|
|
45
|
+
/** Timeout in milliseconds for any calls. Defaults to 10 seconds. */
|
|
46
|
+
requestTimeout?: number;
|
|
47
|
+
/** Timeout in milliseconds for feature flag calls. Defaults to 10 seconds for stateful clients, and 3 seconds for stateless. */
|
|
48
|
+
featureFlagsRequestTimeoutMs?: number;
|
|
49
|
+
/** Timeout in milliseconds for remote config calls. Defaults to 3 seconds. */
|
|
50
|
+
remoteConfigRequestTimeoutMs?: number;
|
|
51
|
+
/** For Session Analysis how long before we expire a session (defaults to 30 mins) */
|
|
52
|
+
sessionExpirationTimeSeconds?: number;
|
|
53
|
+
/** Whether to post events to PostHog in JSON or compressed format. Defaults to 'json' */
|
|
54
|
+
captureMode?: 'json' | 'form';
|
|
55
|
+
disableGeoip?: boolean;
|
|
56
|
+
/** Special flag to indicate ingested data is for a historical migration. */
|
|
57
|
+
historicalMigration?: boolean;
|
|
58
|
+
};
|
|
59
|
+
declare enum PostHogPersistedProperty {
|
|
60
|
+
AnonymousId = "anonymous_id",
|
|
61
|
+
DistinctId = "distinct_id",
|
|
62
|
+
Props = "props",
|
|
63
|
+
FeatureFlagDetails = "feature_flag_details",
|
|
64
|
+
FeatureFlags = "feature_flags",
|
|
65
|
+
FeatureFlagPayloads = "feature_flag_payloads",
|
|
66
|
+
BootstrapFeatureFlagDetails = "bootstrap_feature_flag_details",
|
|
67
|
+
BootstrapFeatureFlags = "bootstrap_feature_flags",
|
|
68
|
+
BootstrapFeatureFlagPayloads = "bootstrap_feature_flag_payloads",
|
|
69
|
+
OverrideFeatureFlags = "override_feature_flags",
|
|
70
|
+
Queue = "queue",
|
|
71
|
+
OptedOut = "opted_out",
|
|
72
|
+
SessionId = "session_id",
|
|
73
|
+
SessionLastTimestamp = "session_timestamp",
|
|
74
|
+
PersonProperties = "person_properties",
|
|
75
|
+
GroupProperties = "group_properties",
|
|
76
|
+
InstalledAppBuild = "installed_app_build",
|
|
77
|
+
InstalledAppVersion = "installed_app_version",
|
|
78
|
+
SessionReplay = "session_replay",
|
|
79
|
+
DecideEndpointWasHit = "decide_endpoint_was_hit",
|
|
80
|
+
SurveyLastSeenDate = "survey_last_seen_date",
|
|
81
|
+
SurveysSeen = "surveys_seen",
|
|
82
|
+
Surveys = "surveys",
|
|
83
|
+
RemoteConfig = "remote_config"
|
|
84
|
+
}
|
|
85
|
+
type PostHogFetchOptions = {
|
|
86
|
+
method: 'GET' | 'POST' | 'PUT' | 'PATCH';
|
|
87
|
+
mode?: 'no-cors';
|
|
88
|
+
credentials?: 'omit';
|
|
89
|
+
headers: {
|
|
90
|
+
[key: string]: string;
|
|
91
|
+
};
|
|
92
|
+
body?: string;
|
|
93
|
+
signal?: AbortSignal;
|
|
94
|
+
};
|
|
95
|
+
type PostHogCaptureOptions = {
|
|
96
|
+
/** If provided overrides the auto-generated event ID */
|
|
97
|
+
uuid?: string;
|
|
98
|
+
/** If provided overrides the auto-generated timestamp */
|
|
99
|
+
timestamp?: Date;
|
|
100
|
+
disableGeoip?: boolean;
|
|
101
|
+
};
|
|
102
|
+
type PostHogFetchResponse = {
|
|
103
|
+
status: number;
|
|
104
|
+
text: () => Promise<string>;
|
|
105
|
+
json: () => Promise<any>;
|
|
106
|
+
};
|
|
107
|
+
type PostHogEventProperties = {
|
|
108
|
+
[key: string]: any;
|
|
109
|
+
};
|
|
110
|
+
type PostHogAutocaptureElement = {
|
|
111
|
+
$el_text?: string;
|
|
112
|
+
tag_name: string;
|
|
113
|
+
href?: string;
|
|
114
|
+
nth_child?: number;
|
|
115
|
+
nth_of_type?: number;
|
|
116
|
+
order?: number;
|
|
117
|
+
} & {
|
|
118
|
+
[key: string]: any;
|
|
119
|
+
};
|
|
120
|
+
type PostHogRemoteConfig = {
|
|
121
|
+
sessionRecording?: boolean | {
|
|
122
|
+
[key: string]: JsonType;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Whether surveys are enabled
|
|
126
|
+
*/
|
|
127
|
+
surveys?: boolean | Survey[];
|
|
128
|
+
/**
|
|
129
|
+
* Indicates if the team has any flags enabled (if not we don't need to load them)
|
|
130
|
+
*/
|
|
131
|
+
hasFeatureFlags?: boolean;
|
|
132
|
+
};
|
|
133
|
+
type FeatureFlagValue = string | boolean;
|
|
134
|
+
type PostHogDecideResponse = Omit<PostHogRemoteConfig, 'surveys' | 'hasFeatureFlags'> & {
|
|
135
|
+
featureFlags: {
|
|
136
|
+
[key: string]: FeatureFlagValue;
|
|
137
|
+
};
|
|
138
|
+
featureFlagPayloads: {
|
|
139
|
+
[key: string]: JsonType;
|
|
140
|
+
};
|
|
141
|
+
flags: {
|
|
142
|
+
[key: string]: FeatureFlagDetail;
|
|
143
|
+
};
|
|
144
|
+
errorsWhileComputingFlags: boolean;
|
|
145
|
+
sessionRecording?: boolean | {
|
|
146
|
+
[key: string]: JsonType;
|
|
147
|
+
};
|
|
148
|
+
quotaLimited?: string[];
|
|
149
|
+
requestId?: string;
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* Creates a type with all properties of T, but makes only K properties required while the rest remain optional.
|
|
153
|
+
*
|
|
154
|
+
* @template T - The base type containing all properties
|
|
155
|
+
* @template K - Union type of keys from T that should be required
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* interface User {
|
|
159
|
+
* id: number;
|
|
160
|
+
* name: string;
|
|
161
|
+
* email?: string;
|
|
162
|
+
* age?: number;
|
|
163
|
+
* }
|
|
164
|
+
*
|
|
165
|
+
* // Makes 'id' and 'name' required, but 'email' and 'age' optional
|
|
166
|
+
* type RequiredUser = PartialWithRequired<User, 'id' | 'name'>;
|
|
167
|
+
*
|
|
168
|
+
* const user: RequiredUser = {
|
|
169
|
+
* id: 1, // Must be provided
|
|
170
|
+
* name: "John" // Must be provided
|
|
171
|
+
* // email and age are optional
|
|
172
|
+
* };
|
|
173
|
+
*/
|
|
174
|
+
type PartialWithRequired<T, K extends keyof T> = {
|
|
175
|
+
[P in K]: T[P];
|
|
176
|
+
} & {
|
|
177
|
+
[P in Exclude<keyof T, K>]?: T[P];
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* These are the fields we care about from PostHogDecideResponse for feature flags.
|
|
181
|
+
*/
|
|
182
|
+
type PostHogFeatureFlagDetails = PartialWithRequired<PostHogDecideResponse, 'flags' | 'featureFlags' | 'featureFlagPayloads' | 'requestId'>;
|
|
183
|
+
type JsonType = string | number | boolean | null | {
|
|
184
|
+
[key: string]: JsonType;
|
|
124
185
|
} | Array<JsonType>;
|
|
186
|
+
type FeatureFlagDetail = {
|
|
187
|
+
key: string;
|
|
188
|
+
enabled: boolean;
|
|
189
|
+
variant: string | undefined;
|
|
190
|
+
reason: EvaluationReason | undefined;
|
|
191
|
+
metadata: FeatureFlagMetadata | undefined;
|
|
192
|
+
};
|
|
193
|
+
type FeatureFlagMetadata = {
|
|
194
|
+
id: number | undefined;
|
|
195
|
+
version: number | undefined;
|
|
196
|
+
description: string | undefined;
|
|
197
|
+
payload: string | undefined;
|
|
198
|
+
};
|
|
199
|
+
type EvaluationReason = {
|
|
200
|
+
code: string | undefined;
|
|
201
|
+
condition_index: number | undefined;
|
|
202
|
+
description: string | undefined;
|
|
203
|
+
};
|
|
204
|
+
type SurveyAppearance = {
|
|
205
|
+
backgroundColor?: string;
|
|
206
|
+
submitButtonColor?: string;
|
|
207
|
+
submitButtonText?: string;
|
|
208
|
+
submitButtonTextColor?: string;
|
|
209
|
+
ratingButtonColor?: string;
|
|
210
|
+
ratingButtonActiveColor?: string;
|
|
211
|
+
autoDisappear?: boolean;
|
|
212
|
+
displayThankYouMessage?: boolean;
|
|
213
|
+
thankYouMessageHeader?: string;
|
|
214
|
+
thankYouMessageDescription?: string;
|
|
215
|
+
thankYouMessageDescriptionContentType?: SurveyQuestionDescriptionContentType;
|
|
216
|
+
thankYouMessageCloseButtonText?: string;
|
|
217
|
+
borderColor?: string;
|
|
218
|
+
position?: SurveyPosition;
|
|
219
|
+
placeholder?: string;
|
|
220
|
+
shuffleQuestions?: boolean;
|
|
221
|
+
surveyPopupDelaySeconds?: number;
|
|
222
|
+
widgetType?: SurveyWidgetType;
|
|
223
|
+
widgetSelector?: string;
|
|
224
|
+
widgetLabel?: string;
|
|
225
|
+
widgetColor?: string;
|
|
226
|
+
};
|
|
227
|
+
declare enum SurveyPosition {
|
|
228
|
+
Left = "left",
|
|
229
|
+
Right = "right",
|
|
230
|
+
Center = "center"
|
|
231
|
+
}
|
|
232
|
+
declare enum SurveyWidgetType {
|
|
233
|
+
Button = "button",
|
|
234
|
+
Tab = "tab",
|
|
235
|
+
Selector = "selector"
|
|
236
|
+
}
|
|
237
|
+
declare enum SurveyType {
|
|
238
|
+
Popover = "popover",
|
|
239
|
+
API = "api",
|
|
240
|
+
Widget = "widget"
|
|
241
|
+
}
|
|
242
|
+
type SurveyQuestion = BasicSurveyQuestion | LinkSurveyQuestion | RatingSurveyQuestion | MultipleSurveyQuestion;
|
|
243
|
+
declare enum SurveyQuestionDescriptionContentType {
|
|
244
|
+
Html = "html",
|
|
245
|
+
Text = "text"
|
|
246
|
+
}
|
|
247
|
+
type SurveyQuestionBase = {
|
|
248
|
+
question: string;
|
|
249
|
+
id?: string;
|
|
250
|
+
description?: string;
|
|
251
|
+
descriptionContentType?: SurveyQuestionDescriptionContentType;
|
|
252
|
+
optional?: boolean;
|
|
253
|
+
buttonText?: string;
|
|
254
|
+
originalQuestionIndex: number;
|
|
255
|
+
branching?: NextQuestionBranching | EndBranching | ResponseBasedBranching | SpecificQuestionBranching;
|
|
256
|
+
};
|
|
257
|
+
type BasicSurveyQuestion = SurveyQuestionBase & {
|
|
258
|
+
type: SurveyQuestionType.Open;
|
|
259
|
+
};
|
|
260
|
+
type LinkSurveyQuestion = SurveyQuestionBase & {
|
|
261
|
+
type: SurveyQuestionType.Link;
|
|
262
|
+
link?: string;
|
|
263
|
+
};
|
|
264
|
+
type RatingSurveyQuestion = SurveyQuestionBase & {
|
|
265
|
+
type: SurveyQuestionType.Rating;
|
|
266
|
+
display: SurveyRatingDisplay;
|
|
267
|
+
scale: 3 | 5 | 7 | 10;
|
|
268
|
+
lowerBoundLabel: string;
|
|
269
|
+
upperBoundLabel: string;
|
|
270
|
+
};
|
|
271
|
+
declare enum SurveyRatingDisplay {
|
|
272
|
+
Number = "number",
|
|
273
|
+
Emoji = "emoji"
|
|
274
|
+
}
|
|
275
|
+
type MultipleSurveyQuestion = SurveyQuestionBase & {
|
|
276
|
+
type: SurveyQuestionType.SingleChoice | SurveyQuestionType.MultipleChoice;
|
|
277
|
+
choices: string[];
|
|
278
|
+
hasOpenChoice?: boolean;
|
|
279
|
+
shuffleOptions?: boolean;
|
|
280
|
+
};
|
|
281
|
+
declare enum SurveyQuestionType {
|
|
282
|
+
Open = "open",
|
|
283
|
+
MultipleChoice = "multiple_choice",
|
|
284
|
+
SingleChoice = "single_choice",
|
|
285
|
+
Rating = "rating",
|
|
286
|
+
Link = "link"
|
|
287
|
+
}
|
|
288
|
+
declare enum SurveyQuestionBranchingType {
|
|
289
|
+
NextQuestion = "next_question",
|
|
290
|
+
End = "end",
|
|
291
|
+
ResponseBased = "response_based",
|
|
292
|
+
SpecificQuestion = "specific_question"
|
|
293
|
+
}
|
|
294
|
+
type NextQuestionBranching = {
|
|
295
|
+
type: SurveyQuestionBranchingType.NextQuestion;
|
|
296
|
+
};
|
|
297
|
+
type EndBranching = {
|
|
298
|
+
type: SurveyQuestionBranchingType.End;
|
|
299
|
+
};
|
|
300
|
+
type ResponseBasedBranching = {
|
|
301
|
+
type: SurveyQuestionBranchingType.ResponseBased;
|
|
302
|
+
responseValues: Record<string, any>;
|
|
303
|
+
};
|
|
304
|
+
type SpecificQuestionBranching = {
|
|
305
|
+
type: SurveyQuestionBranchingType.SpecificQuestion;
|
|
306
|
+
index: number;
|
|
307
|
+
};
|
|
308
|
+
type SurveyResponse = {
|
|
309
|
+
surveys: Survey[];
|
|
310
|
+
};
|
|
311
|
+
declare enum SurveyMatchType {
|
|
312
|
+
Regex = "regex",
|
|
313
|
+
NotRegex = "not_regex",
|
|
314
|
+
Exact = "exact",
|
|
315
|
+
IsNot = "is_not",
|
|
316
|
+
Icontains = "icontains",
|
|
317
|
+
NotIcontains = "not_icontains"
|
|
318
|
+
}
|
|
319
|
+
type Survey = {
|
|
320
|
+
id: string;
|
|
321
|
+
name: string;
|
|
322
|
+
description?: string;
|
|
323
|
+
type: SurveyType;
|
|
324
|
+
feature_flag_keys?: {
|
|
325
|
+
key: string;
|
|
326
|
+
value?: string;
|
|
327
|
+
}[];
|
|
328
|
+
linked_flag_key?: string;
|
|
329
|
+
targeting_flag_key?: string;
|
|
330
|
+
internal_targeting_flag_key?: string;
|
|
331
|
+
questions: SurveyQuestion[];
|
|
332
|
+
appearance?: SurveyAppearance;
|
|
333
|
+
conditions?: {
|
|
334
|
+
url?: string;
|
|
335
|
+
selector?: string;
|
|
336
|
+
seenSurveyWaitPeriodInDays?: number;
|
|
337
|
+
urlMatchType?: SurveyMatchType;
|
|
338
|
+
events?: {
|
|
339
|
+
repeatedActivation?: boolean;
|
|
340
|
+
values?: {
|
|
341
|
+
name: string;
|
|
342
|
+
}[];
|
|
343
|
+
};
|
|
344
|
+
actions?: {
|
|
345
|
+
values: SurveyActionType[];
|
|
346
|
+
};
|
|
347
|
+
deviceTypes?: string[];
|
|
348
|
+
deviceTypesMatchType?: SurveyMatchType;
|
|
349
|
+
};
|
|
350
|
+
start_date?: string;
|
|
351
|
+
end_date?: string;
|
|
352
|
+
current_iteration?: number;
|
|
353
|
+
current_iteration_start_date?: string;
|
|
354
|
+
};
|
|
355
|
+
type SurveyActionType = {
|
|
356
|
+
id: number;
|
|
357
|
+
name?: string;
|
|
358
|
+
steps?: ActionStepType[];
|
|
359
|
+
};
|
|
360
|
+
/** Sync with plugin-server/src/types.ts */
|
|
361
|
+
declare enum ActionStepStringMatching {
|
|
362
|
+
Contains = "contains",
|
|
363
|
+
Exact = "exact",
|
|
364
|
+
Regex = "regex"
|
|
365
|
+
}
|
|
366
|
+
type ActionStepType = {
|
|
367
|
+
event?: string;
|
|
368
|
+
selector?: string;
|
|
369
|
+
/** @deprecated Only `selector` should be used now. */
|
|
370
|
+
tag_name?: string;
|
|
371
|
+
text?: string;
|
|
372
|
+
/** @default StringMatching.Exact */
|
|
373
|
+
text_matching?: ActionStepStringMatching;
|
|
374
|
+
href?: string;
|
|
375
|
+
/** @default ActionStepStringMatching.Exact */
|
|
376
|
+
href_matching?: ActionStepStringMatching;
|
|
377
|
+
url?: string;
|
|
378
|
+
/** @default StringMatching.Contains */
|
|
379
|
+
url_matching?: ActionStepStringMatching;
|
|
380
|
+
};
|
|
125
381
|
|
|
126
|
-
interface RetriableOptions {
|
|
127
|
-
retryCount: number;
|
|
128
|
-
retryDelay: number;
|
|
129
|
-
retryCheck: (err:
|
|
382
|
+
interface RetriableOptions {
|
|
383
|
+
retryCount: number;
|
|
384
|
+
retryDelay: number;
|
|
385
|
+
retryCheck: (err: unknown) => boolean;
|
|
130
386
|
}
|
|
131
387
|
|
|
132
|
-
declare class SimpleEventEmitter {
|
|
133
|
-
events: {
|
|
134
|
-
[key: string]: ((...args: any[]) => void)[];
|
|
135
|
-
};
|
|
136
|
-
constructor();
|
|
137
|
-
on(event: string, listener: (...args: any[]) => void): () => void;
|
|
138
|
-
emit(event: string, payload: any): void;
|
|
388
|
+
declare class SimpleEventEmitter {
|
|
389
|
+
events: {
|
|
390
|
+
[key: string]: ((...args: any[]) => void)[];
|
|
391
|
+
};
|
|
392
|
+
constructor();
|
|
393
|
+
on(event: string, listener: (...args: any[]) => void): () => void;
|
|
394
|
+
emit(event: string, payload: any): void;
|
|
139
395
|
}
|
|
140
396
|
|
|
141
|
-
declare abstract class PostHogCoreStateless {
|
|
142
|
-
readonly apiKey: string;
|
|
143
|
-
readonly host: string;
|
|
144
|
-
readonly flushAt: number;
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
private
|
|
148
|
-
private
|
|
149
|
-
private
|
|
150
|
-
private
|
|
151
|
-
private
|
|
152
|
-
private
|
|
153
|
-
private
|
|
154
|
-
private
|
|
155
|
-
|
|
156
|
-
private
|
|
157
|
-
private
|
|
158
|
-
|
|
159
|
-
protected
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
protected
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
abstract
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
get
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
protected
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
protected
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
protected
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
/***
|
|
210
|
-
***
|
|
211
|
-
***/
|
|
212
|
-
protected
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
/***
|
|
322
|
-
|
|
323
|
-
***/
|
|
324
|
-
|
|
325
|
-
[
|
|
326
|
-
}): void;
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
397
|
+
declare abstract class PostHogCoreStateless {
|
|
398
|
+
readonly apiKey: string;
|
|
399
|
+
readonly host: string;
|
|
400
|
+
readonly flushAt: number;
|
|
401
|
+
readonly preloadFeatureFlags: boolean;
|
|
402
|
+
readonly disableSurveys: boolean;
|
|
403
|
+
private maxBatchSize;
|
|
404
|
+
private maxQueueSize;
|
|
405
|
+
private flushInterval;
|
|
406
|
+
private flushPromise;
|
|
407
|
+
private shutdownPromise;
|
|
408
|
+
private requestTimeout;
|
|
409
|
+
private featureFlagsRequestTimeoutMs;
|
|
410
|
+
private remoteConfigRequestTimeoutMs;
|
|
411
|
+
private captureMode;
|
|
412
|
+
private removeDebugCallback?;
|
|
413
|
+
private disableGeoip;
|
|
414
|
+
private historicalMigration;
|
|
415
|
+
protected disabled: boolean;
|
|
416
|
+
private defaultOptIn;
|
|
417
|
+
private pendingPromises;
|
|
418
|
+
protected _events: SimpleEventEmitter;
|
|
419
|
+
protected _flushTimer?: any;
|
|
420
|
+
protected _retryOptions: RetriableOptions;
|
|
421
|
+
protected _initPromise: Promise<void>;
|
|
422
|
+
protected _isInitialized: boolean;
|
|
423
|
+
protected _remoteConfigResponsePromise?: Promise<PostHogRemoteConfig | undefined>;
|
|
424
|
+
abstract fetch(url: string, options: PostHogFetchOptions): Promise<PostHogFetchResponse>;
|
|
425
|
+
abstract getLibraryId(): string;
|
|
426
|
+
abstract getLibraryVersion(): string;
|
|
427
|
+
abstract getCustomUserAgent(): string | void;
|
|
428
|
+
abstract getPersistedProperty<T>(key: PostHogPersistedProperty): T | undefined;
|
|
429
|
+
abstract setPersistedProperty<T>(key: PostHogPersistedProperty, value: T | null): void;
|
|
430
|
+
constructor(apiKey: string, options?: PostHogCoreOptions);
|
|
431
|
+
protected logMsgIfDebug(fn: () => void): void;
|
|
432
|
+
protected wrap(fn: () => void): void;
|
|
433
|
+
protected getCommonEventProperties(): any;
|
|
434
|
+
get optedOut(): boolean;
|
|
435
|
+
optIn(): Promise<void>;
|
|
436
|
+
optOut(): Promise<void>;
|
|
437
|
+
on(event: string, cb: (...args: any[]) => void): () => void;
|
|
438
|
+
debug(enabled?: boolean): void;
|
|
439
|
+
get isDebug(): boolean;
|
|
440
|
+
get isDisabled(): boolean;
|
|
441
|
+
private buildPayload;
|
|
442
|
+
protected addPendingPromise<T>(promise: Promise<T>): Promise<T>;
|
|
443
|
+
/***
|
|
444
|
+
*** TRACKING
|
|
445
|
+
***/
|
|
446
|
+
protected identifyStateless(distinctId: string, properties?: PostHogEventProperties, options?: PostHogCaptureOptions): void;
|
|
447
|
+
protected identifyStatelessImmediate(distinctId: string, properties?: PostHogEventProperties, options?: PostHogCaptureOptions): Promise<void>;
|
|
448
|
+
protected captureStateless(distinctId: string, event: string, properties?: {
|
|
449
|
+
[key: string]: any;
|
|
450
|
+
}, options?: PostHogCaptureOptions): void;
|
|
451
|
+
protected captureStatelessImmediate(distinctId: string, event: string, properties?: {
|
|
452
|
+
[key: string]: any;
|
|
453
|
+
}, options?: PostHogCaptureOptions): Promise<void>;
|
|
454
|
+
protected aliasStateless(alias: string, distinctId: string, properties?: {
|
|
455
|
+
[key: string]: any;
|
|
456
|
+
}, options?: PostHogCaptureOptions): void;
|
|
457
|
+
protected aliasStatelessImmediate(alias: string, distinctId: string, properties?: {
|
|
458
|
+
[key: string]: any;
|
|
459
|
+
}, options?: PostHogCaptureOptions): Promise<void>;
|
|
460
|
+
/***
|
|
461
|
+
*** GROUPS
|
|
462
|
+
***/
|
|
463
|
+
protected groupIdentifyStateless(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties, options?: PostHogCaptureOptions, distinctId?: string, eventProperties?: PostHogEventProperties): void;
|
|
464
|
+
protected getRemoteConfig(): Promise<PostHogRemoteConfig | undefined>;
|
|
465
|
+
/***
|
|
466
|
+
*** FEATURE FLAGS
|
|
467
|
+
***/
|
|
468
|
+
protected getDecide(distinctId: string, groups?: Record<string, string | number>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, extraPayload?: Record<string, any>): Promise<PostHogDecideResponse | undefined>;
|
|
469
|
+
protected getFeatureFlagStateless(key: string, distinctId: string, groups?: Record<string, string>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, disableGeoip?: boolean): Promise<{
|
|
470
|
+
response: FeatureFlagValue | undefined;
|
|
471
|
+
requestId: string | undefined;
|
|
472
|
+
}>;
|
|
473
|
+
protected getFeatureFlagDetailStateless(key: string, distinctId: string, groups?: Record<string, string>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, disableGeoip?: boolean): Promise<{
|
|
474
|
+
response: FeatureFlagDetail | undefined;
|
|
475
|
+
requestId: string | undefined;
|
|
476
|
+
} | undefined>;
|
|
477
|
+
protected getFeatureFlagPayloadStateless(key: string, distinctId: string, groups?: Record<string, string>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, disableGeoip?: boolean): Promise<JsonType | undefined>;
|
|
478
|
+
protected getFeatureFlagPayloadsStateless(distinctId: string, groups?: Record<string, string>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, disableGeoip?: boolean, flagKeysToEvaluate?: string[]): Promise<PostHogDecideResponse['featureFlagPayloads'] | undefined>;
|
|
479
|
+
protected getFeatureFlagsStateless(distinctId: string, groups?: Record<string, string | number>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, disableGeoip?: boolean, flagKeysToEvaluate?: string[]): Promise<{
|
|
480
|
+
flags: PostHogDecideResponse['featureFlags'] | undefined;
|
|
481
|
+
payloads: PostHogDecideResponse['featureFlagPayloads'] | undefined;
|
|
482
|
+
requestId: PostHogDecideResponse['requestId'] | undefined;
|
|
483
|
+
}>;
|
|
484
|
+
protected getFeatureFlagsAndPayloadsStateless(distinctId: string, groups?: Record<string, string | number>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, disableGeoip?: boolean, flagKeysToEvaluate?: string[]): Promise<{
|
|
485
|
+
flags: PostHogDecideResponse['featureFlags'] | undefined;
|
|
486
|
+
payloads: PostHogDecideResponse['featureFlagPayloads'] | undefined;
|
|
487
|
+
requestId: PostHogDecideResponse['requestId'] | undefined;
|
|
488
|
+
}>;
|
|
489
|
+
protected getFeatureFlagDetailsStateless(distinctId: string, groups?: Record<string, string | number>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, disableGeoip?: boolean, flagKeysToEvaluate?: string[]): Promise<PostHogFeatureFlagDetails | undefined>;
|
|
490
|
+
/***
|
|
491
|
+
*** SURVEYS
|
|
492
|
+
***/
|
|
493
|
+
getSurveysStateless(): Promise<SurveyResponse['surveys']>;
|
|
494
|
+
/***
|
|
495
|
+
*** SUPER PROPERTIES
|
|
496
|
+
***/
|
|
497
|
+
private _props;
|
|
498
|
+
protected get props(): PostHogEventProperties;
|
|
499
|
+
protected set props(val: PostHogEventProperties | undefined);
|
|
500
|
+
register(properties: {
|
|
501
|
+
[key: string]: any;
|
|
502
|
+
}): Promise<void>;
|
|
503
|
+
unregister(property: string): Promise<void>;
|
|
504
|
+
/***
|
|
505
|
+
*** QUEUEING AND FLUSHING
|
|
506
|
+
***/
|
|
507
|
+
protected enqueue(type: string, _message: any, options?: PostHogCaptureOptions): void;
|
|
508
|
+
protected sendImmediate(type: string, _message: any, options?: PostHogCaptureOptions): Promise<void>;
|
|
509
|
+
private prepareMessage;
|
|
510
|
+
private clearFlushTimer;
|
|
511
|
+
/**
|
|
512
|
+
* Helper for flushing the queue in the background
|
|
513
|
+
* Avoids unnecessary promise errors
|
|
514
|
+
*/
|
|
515
|
+
private flushBackground;
|
|
516
|
+
flush(): Promise<any[]>;
|
|
517
|
+
protected getCustomHeaders(): {
|
|
518
|
+
[key: string]: string;
|
|
519
|
+
};
|
|
520
|
+
private _flush;
|
|
521
|
+
private fetchWithRetry;
|
|
522
|
+
_shutdown(shutdownTimeoutMs?: number): Promise<void>;
|
|
523
|
+
/**
|
|
524
|
+
* Call shutdown() once before the node process exits, so ensure that all events have been sent and all promises
|
|
525
|
+
* have resolved. Do not use this function if you intend to keep using this PostHog instance after calling it.
|
|
526
|
+
* @param shutdownTimeoutMs
|
|
527
|
+
*/
|
|
528
|
+
shutdown(shutdownTimeoutMs?: number): Promise<void>;
|
|
529
|
+
}
|
|
530
|
+
declare abstract class PostHogCore extends PostHogCoreStateless {
|
|
531
|
+
private sendFeatureFlagEvent;
|
|
532
|
+
private flagCallReported;
|
|
533
|
+
protected _decideResponsePromise?: Promise<PostHogDecideResponse | undefined>;
|
|
534
|
+
protected _sessionExpirationTimeSeconds: number;
|
|
535
|
+
protected sessionProps: PostHogEventProperties;
|
|
536
|
+
constructor(apiKey: string, options?: PostHogCoreOptions);
|
|
537
|
+
protected setupBootstrap(options?: Partial<PostHogCoreOptions>): void;
|
|
538
|
+
private clearProps;
|
|
539
|
+
on(event: string, cb: (...args: any[]) => void): () => void;
|
|
540
|
+
reset(propertiesToKeep?: PostHogPersistedProperty[]): void;
|
|
541
|
+
protected getCommonEventProperties(): any;
|
|
542
|
+
private enrichProperties;
|
|
543
|
+
/**
|
|
544
|
+
* * @returns {string} The stored session ID for the current session. This may be an empty string if the client is not yet fully initialized.
|
|
545
|
+
*/
|
|
546
|
+
getSessionId(): string;
|
|
547
|
+
resetSessionId(): void;
|
|
548
|
+
/**
|
|
549
|
+
* * @returns {string} The stored anonymous ID. This may be an empty string if the client is not yet fully initialized.
|
|
550
|
+
*/
|
|
551
|
+
getAnonymousId(): string;
|
|
552
|
+
/**
|
|
553
|
+
* * @returns {string} The stored distinct ID. This may be an empty string if the client is not yet fully initialized.
|
|
554
|
+
*/
|
|
555
|
+
getDistinctId(): string;
|
|
556
|
+
registerForSession(properties: {
|
|
557
|
+
[key: string]: any;
|
|
558
|
+
}): void;
|
|
559
|
+
unregisterForSession(property: string): void;
|
|
560
|
+
/***
|
|
561
|
+
*** TRACKING
|
|
562
|
+
***/
|
|
563
|
+
identify(distinctId?: string, properties?: PostHogEventProperties, options?: PostHogCaptureOptions): void;
|
|
564
|
+
capture(event: string, properties?: {
|
|
565
|
+
[key: string]: any;
|
|
566
|
+
}, options?: PostHogCaptureOptions): void;
|
|
567
|
+
alias(alias: string): void;
|
|
568
|
+
autocapture(eventType: string, elements: PostHogAutocaptureElement[], properties?: PostHogEventProperties, options?: PostHogCaptureOptions): void;
|
|
569
|
+
/***
|
|
570
|
+
*** GROUPS
|
|
571
|
+
***/
|
|
572
|
+
groups(groups: {
|
|
573
|
+
[type: string]: string | number;
|
|
574
|
+
}): void;
|
|
575
|
+
group(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties, options?: PostHogCaptureOptions): void;
|
|
576
|
+
groupIdentify(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties, options?: PostHogCaptureOptions): void;
|
|
577
|
+
/***
|
|
578
|
+
* PROPERTIES
|
|
579
|
+
***/
|
|
580
|
+
setPersonPropertiesForFlags(properties: {
|
|
581
|
+
[type: string]: string;
|
|
582
|
+
}): void;
|
|
583
|
+
resetPersonPropertiesForFlags(): void;
|
|
584
|
+
/** @deprecated - Renamed to setPersonPropertiesForFlags */
|
|
585
|
+
personProperties(properties: {
|
|
586
|
+
[type: string]: string;
|
|
587
|
+
}): void;
|
|
588
|
+
setGroupPropertiesForFlags(properties: {
|
|
589
|
+
[type: string]: Record<string, string>;
|
|
590
|
+
}): void;
|
|
591
|
+
resetGroupPropertiesForFlags(): void;
|
|
592
|
+
/** @deprecated - Renamed to setGroupPropertiesForFlags */
|
|
593
|
+
groupProperties(properties: {
|
|
594
|
+
[type: string]: Record<string, string>;
|
|
595
|
+
}): void;
|
|
596
|
+
private remoteConfigAsync;
|
|
597
|
+
/***
|
|
598
|
+
*** FEATURE FLAGS
|
|
599
|
+
***/
|
|
600
|
+
private decideAsync;
|
|
601
|
+
private cacheSessionReplay;
|
|
602
|
+
private _remoteConfigAsync;
|
|
603
|
+
private _decideAsync;
|
|
604
|
+
private setKnownFeatureFlagDetails;
|
|
605
|
+
private getKnownFeatureFlagDetails;
|
|
606
|
+
private getKnownFeatureFlags;
|
|
607
|
+
private getKnownFeatureFlagPayloads;
|
|
608
|
+
private getBootstrappedFeatureFlagDetails;
|
|
609
|
+
private setBootstrappedFeatureFlagDetails;
|
|
610
|
+
private getBootstrappedFeatureFlags;
|
|
611
|
+
private getBootstrappedFeatureFlagPayloads;
|
|
612
|
+
getFeatureFlag(key: string): FeatureFlagValue | undefined;
|
|
613
|
+
getFeatureFlagPayload(key: string): JsonType | undefined;
|
|
614
|
+
getFeatureFlagPayloads(): PostHogDecideResponse['featureFlagPayloads'] | undefined;
|
|
615
|
+
getFeatureFlags(): PostHogDecideResponse['featureFlags'] | undefined;
|
|
616
|
+
getFeatureFlagDetails(): PostHogFeatureFlagDetails | undefined;
|
|
617
|
+
getFeatureFlagsAndPayloads(): {
|
|
618
|
+
flags: PostHogDecideResponse['featureFlags'] | undefined;
|
|
619
|
+
payloads: PostHogDecideResponse['featureFlagPayloads'] | undefined;
|
|
620
|
+
};
|
|
621
|
+
isFeatureEnabled(key: string): boolean | undefined;
|
|
622
|
+
reloadFeatureFlags(cb?: (err?: Error, flags?: PostHogDecideResponse['featureFlags']) => void): void;
|
|
623
|
+
reloadRemoteConfigAsync(): Promise<PostHogRemoteConfig | undefined>;
|
|
624
|
+
reloadFeatureFlagsAsync(sendAnonDistinctId?: boolean): Promise<PostHogDecideResponse['featureFlags'] | undefined>;
|
|
625
|
+
onFeatureFlags(cb: (flags: PostHogDecideResponse['featureFlags']) => void): () => void;
|
|
626
|
+
onFeatureFlag(key: string, cb: (value: FeatureFlagValue) => void): () => void;
|
|
627
|
+
overrideFeatureFlag(flags: PostHogDecideResponse['featureFlags'] | null): Promise<void>;
|
|
628
|
+
/***
|
|
629
|
+
*** ERROR TRACKING
|
|
630
|
+
***/
|
|
631
|
+
captureException(error: unknown, additionalProperties?: {
|
|
632
|
+
[key: string]: any;
|
|
633
|
+
}): void;
|
|
634
|
+
/**
|
|
635
|
+
* Capture written user feedback for a LLM trace. Numeric values are converted to strings.
|
|
636
|
+
* @param traceId The trace ID to capture feedback for.
|
|
637
|
+
* @param userFeedback The feedback to capture.
|
|
638
|
+
*/
|
|
639
|
+
captureTraceFeedback(traceId: string | number, userFeedback: string): void;
|
|
640
|
+
/**
|
|
641
|
+
* Capture a metric for a LLM trace. Numeric values are converted to strings.
|
|
642
|
+
* @param traceId The trace ID to capture the metric for.
|
|
643
|
+
* @param metricName The name of the metric to capture.
|
|
644
|
+
* @param metricValue The value of the metric to capture.
|
|
645
|
+
*/
|
|
646
|
+
captureTraceMetric(traceId: string | number, metricName: string, metricValue: string | number | boolean): void;
|
|
340
647
|
}
|
|
341
648
|
|
|
342
|
-
type PostHogOptions = {
|
|
343
|
-
autocapture?: boolean;
|
|
344
|
-
persistence?: 'localStorage' | 'sessionStorage' | 'cookie' | 'memory';
|
|
345
|
-
persistence_name?: string;
|
|
649
|
+
type PostHogOptions = {
|
|
650
|
+
autocapture?: boolean;
|
|
651
|
+
persistence?: 'localStorage' | 'sessionStorage' | 'cookie' | 'memory';
|
|
652
|
+
persistence_name?: string;
|
|
653
|
+
captureHistoryEvents?: boolean;
|
|
346
654
|
} & PostHogCoreOptions;
|
|
347
655
|
|
|
348
|
-
declare class PostHog extends PostHogCore {
|
|
349
|
-
private _storage;
|
|
350
|
-
private _storageCache;
|
|
351
|
-
private _storageKey;
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
656
|
+
declare class PostHog extends PostHogCore {
|
|
657
|
+
private _storage;
|
|
658
|
+
private _storageCache;
|
|
659
|
+
private _storageKey;
|
|
660
|
+
private _lastPathname;
|
|
661
|
+
constructor(apiKey: string, options?: PostHogOptions);
|
|
662
|
+
private getWindow;
|
|
663
|
+
getPersistedProperty<T>(key: PostHogPersistedProperty): T | undefined;
|
|
664
|
+
setPersistedProperty<T>(key: PostHogPersistedProperty, value: T | null): void;
|
|
665
|
+
fetch(url: string, options: PostHogFetchOptions): Promise<PostHogFetchResponse>;
|
|
666
|
+
getLibraryId(): string;
|
|
667
|
+
getLibraryVersion(): string;
|
|
668
|
+
getCustomUserAgent(): void;
|
|
669
|
+
getCommonEventProperties(): any;
|
|
670
|
+
private setupHistoryEventTracking;
|
|
671
|
+
private captureNavigationEvent;
|
|
361
672
|
}
|
|
362
673
|
|
|
363
674
|
export { PostHog, PostHog as default };
|