posthog-js-lite 3.5.0 → 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 +6 -0
- package/lib/{index.cjs.js → index.cjs} +297 -140
- package/lib/index.cjs.map +1 -0
- package/lib/index.d.ts +661 -642
- package/lib/{index.esm.js → index.mjs} +297 -140
- 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 +6 -9
- package/src/types.ts +1 -1
- 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/featureFlagUtils.d.ts +0 -34
- package/lib/posthog-core/src/index.d.ts +0 -239
- package/lib/posthog-core/src/lz-string.d.ts +0 -8
- package/lib/posthog-core/src/patch.d.ts +0 -3
- package/lib/posthog-core/src/types.d.ts +0 -422
- package/lib/posthog-core/src/utils.d.ts +0 -19
- 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 -19
- package/lib/posthog-web/src/storage.d.ts +0 -10
- package/lib/posthog-web/src/types.d.ts +0 -7
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
import { PostHogFetchOptions, PostHogFetchResponse, PostHogAutocaptureElement, PostHogDecideResponse, PostHogCoreOptions, PostHogEventProperties, PostHogPersistedProperty, PostHogCaptureOptions, JsonType, PostHogRemoteConfig, FeatureFlagValue, PostHogFeatureFlagDetails, FeatureFlagDetail, SurveyResponse } from './types';
|
|
2
|
-
import { RetriableOptions } from './utils';
|
|
3
|
-
import { LZString } from './lz-string';
|
|
4
|
-
import { SimpleEventEmitter } from './eventemitter';
|
|
5
|
-
export * as utils from './utils';
|
|
6
|
-
export declare abstract class PostHogCoreStateless {
|
|
7
|
-
readonly apiKey: string;
|
|
8
|
-
readonly host: string;
|
|
9
|
-
readonly flushAt: number;
|
|
10
|
-
readonly preloadFeatureFlags: boolean;
|
|
11
|
-
readonly disableSurveys: boolean;
|
|
12
|
-
private maxBatchSize;
|
|
13
|
-
private maxQueueSize;
|
|
14
|
-
private flushInterval;
|
|
15
|
-
private flushPromise;
|
|
16
|
-
private requestTimeout;
|
|
17
|
-
private featureFlagsRequestTimeoutMs;
|
|
18
|
-
private remoteConfigRequestTimeoutMs;
|
|
19
|
-
private captureMode;
|
|
20
|
-
private removeDebugCallback?;
|
|
21
|
-
private disableGeoip;
|
|
22
|
-
private historicalMigration;
|
|
23
|
-
protected disabled: boolean;
|
|
24
|
-
private defaultOptIn;
|
|
25
|
-
private pendingPromises;
|
|
26
|
-
protected _events: SimpleEventEmitter;
|
|
27
|
-
protected _flushTimer?: any;
|
|
28
|
-
protected _retryOptions: RetriableOptions;
|
|
29
|
-
protected _initPromise: Promise<void>;
|
|
30
|
-
protected _isInitialized: boolean;
|
|
31
|
-
protected _remoteConfigResponsePromise?: Promise<PostHogRemoteConfig | undefined>;
|
|
32
|
-
abstract fetch(url: string, options: PostHogFetchOptions): Promise<PostHogFetchResponse>;
|
|
33
|
-
abstract getLibraryId(): string;
|
|
34
|
-
abstract getLibraryVersion(): string;
|
|
35
|
-
abstract getCustomUserAgent(): string | void;
|
|
36
|
-
abstract getPersistedProperty<T>(key: PostHogPersistedProperty): T | undefined;
|
|
37
|
-
abstract setPersistedProperty<T>(key: PostHogPersistedProperty, value: T | null): void;
|
|
38
|
-
constructor(apiKey: string, options?: PostHogCoreOptions);
|
|
39
|
-
protected logMsgIfDebug(fn: () => void): void;
|
|
40
|
-
protected wrap(fn: () => void): void;
|
|
41
|
-
protected getCommonEventProperties(): any;
|
|
42
|
-
get optedOut(): boolean;
|
|
43
|
-
optIn(): Promise<void>;
|
|
44
|
-
optOut(): Promise<void>;
|
|
45
|
-
on(event: string, cb: (...args: any[]) => void): () => void;
|
|
46
|
-
debug(enabled?: boolean): void;
|
|
47
|
-
get isDebug(): boolean;
|
|
48
|
-
get isDisabled(): boolean;
|
|
49
|
-
private buildPayload;
|
|
50
|
-
protected addPendingPromise<T>(promise: Promise<T>): Promise<T>;
|
|
51
|
-
/***
|
|
52
|
-
*** TRACKING
|
|
53
|
-
***/
|
|
54
|
-
protected identifyStateless(distinctId: string, properties?: PostHogEventProperties, options?: PostHogCaptureOptions): void;
|
|
55
|
-
protected captureStateless(distinctId: string, event: string, properties?: {
|
|
56
|
-
[key: string]: any;
|
|
57
|
-
}, options?: PostHogCaptureOptions): void;
|
|
58
|
-
protected aliasStateless(alias: string, distinctId: string, properties?: {
|
|
59
|
-
[key: string]: any;
|
|
60
|
-
}, options?: PostHogCaptureOptions): void;
|
|
61
|
-
/***
|
|
62
|
-
*** GROUPS
|
|
63
|
-
***/
|
|
64
|
-
protected groupIdentifyStateless(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties, options?: PostHogCaptureOptions, distinctId?: string, eventProperties?: PostHogEventProperties): void;
|
|
65
|
-
protected getRemoteConfig(): Promise<PostHogRemoteConfig | undefined>;
|
|
66
|
-
/***
|
|
67
|
-
*** FEATURE FLAGS
|
|
68
|
-
***/
|
|
69
|
-
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>;
|
|
70
|
-
protected getFeatureFlagStateless(key: string, distinctId: string, groups?: Record<string, string>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, disableGeoip?: boolean): Promise<{
|
|
71
|
-
response: FeatureFlagValue | undefined;
|
|
72
|
-
requestId: string | undefined;
|
|
73
|
-
}>;
|
|
74
|
-
protected getFeatureFlagDetailStateless(key: string, distinctId: string, groups?: Record<string, string>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, disableGeoip?: boolean): Promise<{
|
|
75
|
-
response: FeatureFlagDetail | undefined;
|
|
76
|
-
requestId: string | undefined;
|
|
77
|
-
} | undefined>;
|
|
78
|
-
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>;
|
|
79
|
-
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>;
|
|
80
|
-
protected getFeatureFlagsStateless(distinctId: string, groups?: Record<string, string | number>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, disableGeoip?: boolean, flagKeysToEvaluate?: string[]): Promise<{
|
|
81
|
-
flags: PostHogDecideResponse['featureFlags'] | undefined;
|
|
82
|
-
payloads: PostHogDecideResponse['featureFlagPayloads'] | undefined;
|
|
83
|
-
requestId: PostHogDecideResponse['requestId'] | undefined;
|
|
84
|
-
}>;
|
|
85
|
-
protected getFeatureFlagsAndPayloadsStateless(distinctId: string, groups?: Record<string, string | number>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, disableGeoip?: boolean, flagKeysToEvaluate?: string[]): Promise<{
|
|
86
|
-
flags: PostHogDecideResponse['featureFlags'] | undefined;
|
|
87
|
-
payloads: PostHogDecideResponse['featureFlagPayloads'] | undefined;
|
|
88
|
-
requestId: PostHogDecideResponse['requestId'] | undefined;
|
|
89
|
-
}>;
|
|
90
|
-
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>;
|
|
91
|
-
/***
|
|
92
|
-
*** SURVEYS
|
|
93
|
-
***/
|
|
94
|
-
getSurveysStateless(): Promise<SurveyResponse['surveys']>;
|
|
95
|
-
/***
|
|
96
|
-
*** QUEUEING AND FLUSHING
|
|
97
|
-
***/
|
|
98
|
-
protected enqueue(type: string, _message: any, options?: PostHogCaptureOptions): void;
|
|
99
|
-
private clearFlushTimer;
|
|
100
|
-
/**
|
|
101
|
-
* Helper for flushing the queue in the background
|
|
102
|
-
* Avoids unnecessary promise errors
|
|
103
|
-
*/
|
|
104
|
-
private flushBackground;
|
|
105
|
-
flush(): Promise<any[]>;
|
|
106
|
-
protected getCustomHeaders(): {
|
|
107
|
-
[key: string]: string;
|
|
108
|
-
};
|
|
109
|
-
private _flush;
|
|
110
|
-
private fetchWithRetry;
|
|
111
|
-
shutdown(shutdownTimeoutMs?: number): Promise<void>;
|
|
112
|
-
}
|
|
113
|
-
export declare abstract class PostHogCore extends PostHogCoreStateless {
|
|
114
|
-
private sendFeatureFlagEvent;
|
|
115
|
-
private flagCallReported;
|
|
116
|
-
protected _decideResponsePromise?: Promise<PostHogDecideResponse | undefined>;
|
|
117
|
-
protected _sessionExpirationTimeSeconds: number;
|
|
118
|
-
protected sessionProps: PostHogEventProperties;
|
|
119
|
-
constructor(apiKey: string, options?: PostHogCoreOptions);
|
|
120
|
-
protected setupBootstrap(options?: Partial<PostHogCoreOptions>): void;
|
|
121
|
-
private get props();
|
|
122
|
-
private set props(value);
|
|
123
|
-
private clearProps;
|
|
124
|
-
private _props;
|
|
125
|
-
on(event: string, cb: (...args: any[]) => void): () => void;
|
|
126
|
-
reset(propertiesToKeep?: PostHogPersistedProperty[]): void;
|
|
127
|
-
protected getCommonEventProperties(): any;
|
|
128
|
-
private enrichProperties;
|
|
129
|
-
/**
|
|
130
|
-
* * @returns {string} The stored session ID for the current session. This may be an empty string if the client is not yet fully initialized.
|
|
131
|
-
*/
|
|
132
|
-
getSessionId(): string;
|
|
133
|
-
resetSessionId(): void;
|
|
134
|
-
/**
|
|
135
|
-
* * @returns {string} The stored anonymous ID. This may be an empty string if the client is not yet fully initialized.
|
|
136
|
-
*/
|
|
137
|
-
getAnonymousId(): string;
|
|
138
|
-
/**
|
|
139
|
-
* * @returns {string} The stored distinct ID. This may be an empty string if the client is not yet fully initialized.
|
|
140
|
-
*/
|
|
141
|
-
getDistinctId(): string;
|
|
142
|
-
unregister(property: string): Promise<void>;
|
|
143
|
-
register(properties: {
|
|
144
|
-
[key: string]: any;
|
|
145
|
-
}): Promise<void>;
|
|
146
|
-
registerForSession(properties: {
|
|
147
|
-
[key: string]: any;
|
|
148
|
-
}): void;
|
|
149
|
-
unregisterForSession(property: string): void;
|
|
150
|
-
/***
|
|
151
|
-
*** TRACKING
|
|
152
|
-
***/
|
|
153
|
-
identify(distinctId?: string, properties?: PostHogEventProperties, options?: PostHogCaptureOptions): void;
|
|
154
|
-
capture(event: string, properties?: {
|
|
155
|
-
[key: string]: any;
|
|
156
|
-
}, options?: PostHogCaptureOptions): void;
|
|
157
|
-
alias(alias: string): void;
|
|
158
|
-
autocapture(eventType: string, elements: PostHogAutocaptureElement[], properties?: PostHogEventProperties, options?: PostHogCaptureOptions): void;
|
|
159
|
-
/***
|
|
160
|
-
*** GROUPS
|
|
161
|
-
***/
|
|
162
|
-
groups(groups: {
|
|
163
|
-
[type: string]: string | number;
|
|
164
|
-
}): void;
|
|
165
|
-
group(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties, options?: PostHogCaptureOptions): void;
|
|
166
|
-
groupIdentify(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties, options?: PostHogCaptureOptions): void;
|
|
167
|
-
/***
|
|
168
|
-
* PROPERTIES
|
|
169
|
-
***/
|
|
170
|
-
setPersonPropertiesForFlags(properties: {
|
|
171
|
-
[type: string]: string;
|
|
172
|
-
}): void;
|
|
173
|
-
resetPersonPropertiesForFlags(): void;
|
|
174
|
-
/** @deprecated - Renamed to setPersonPropertiesForFlags */
|
|
175
|
-
personProperties(properties: {
|
|
176
|
-
[type: string]: string;
|
|
177
|
-
}): void;
|
|
178
|
-
setGroupPropertiesForFlags(properties: {
|
|
179
|
-
[type: string]: Record<string, string>;
|
|
180
|
-
}): void;
|
|
181
|
-
resetGroupPropertiesForFlags(): void;
|
|
182
|
-
/** @deprecated - Renamed to setGroupPropertiesForFlags */
|
|
183
|
-
groupProperties(properties: {
|
|
184
|
-
[type: string]: Record<string, string>;
|
|
185
|
-
}): void;
|
|
186
|
-
private remoteConfigAsync;
|
|
187
|
-
/***
|
|
188
|
-
*** FEATURE FLAGS
|
|
189
|
-
***/
|
|
190
|
-
private decideAsync;
|
|
191
|
-
private cacheSessionReplay;
|
|
192
|
-
private _remoteConfigAsync;
|
|
193
|
-
private _decideAsync;
|
|
194
|
-
private setKnownFeatureFlagDetails;
|
|
195
|
-
private getKnownFeatureFlagDetails;
|
|
196
|
-
private getKnownFeatureFlags;
|
|
197
|
-
private getKnownFeatureFlagPayloads;
|
|
198
|
-
private getBootstrappedFeatureFlagDetails;
|
|
199
|
-
private setBootstrappedFeatureFlagDetails;
|
|
200
|
-
private getBootstrappedFeatureFlags;
|
|
201
|
-
private getBootstrappedFeatureFlagPayloads;
|
|
202
|
-
getFeatureFlag(key: string): FeatureFlagValue | undefined;
|
|
203
|
-
getFeatureFlagPayload(key: string): JsonType | undefined;
|
|
204
|
-
getFeatureFlagPayloads(): PostHogDecideResponse['featureFlagPayloads'] | undefined;
|
|
205
|
-
getFeatureFlags(): PostHogDecideResponse['featureFlags'] | undefined;
|
|
206
|
-
getFeatureFlagDetails(): PostHogFeatureFlagDetails | undefined;
|
|
207
|
-
getFeatureFlagsAndPayloads(): {
|
|
208
|
-
flags: PostHogDecideResponse['featureFlags'] | undefined;
|
|
209
|
-
payloads: PostHogDecideResponse['featureFlagPayloads'] | undefined;
|
|
210
|
-
};
|
|
211
|
-
isFeatureEnabled(key: string): boolean | undefined;
|
|
212
|
-
reloadFeatureFlags(cb?: (err?: Error, flags?: PostHogDecideResponse['featureFlags']) => void): void;
|
|
213
|
-
reloadRemoteConfigAsync(): Promise<PostHogRemoteConfig | undefined>;
|
|
214
|
-
reloadFeatureFlagsAsync(sendAnonDistinctId?: boolean): Promise<PostHogDecideResponse['featureFlags'] | undefined>;
|
|
215
|
-
onFeatureFlags(cb: (flags: PostHogDecideResponse['featureFlags']) => void): () => void;
|
|
216
|
-
onFeatureFlag(key: string, cb: (value: FeatureFlagValue) => void): () => void;
|
|
217
|
-
overrideFeatureFlag(flags: PostHogDecideResponse['featureFlags'] | null): Promise<void>;
|
|
218
|
-
/***
|
|
219
|
-
*** ERROR TRACKING
|
|
220
|
-
***/
|
|
221
|
-
captureException(error: unknown, additionalProperties?: {
|
|
222
|
-
[key: string]: any;
|
|
223
|
-
}): void;
|
|
224
|
-
/**
|
|
225
|
-
* Capture written user feedback for a LLM trace. Numeric values are converted to strings.
|
|
226
|
-
* @param traceId The trace ID to capture feedback for.
|
|
227
|
-
* @param userFeedback The feedback to capture.
|
|
228
|
-
*/
|
|
229
|
-
captureTraceFeedback(traceId: string | number, userFeedback: string): void;
|
|
230
|
-
/**
|
|
231
|
-
* Capture a metric for a LLM trace. Numeric values are converted to strings.
|
|
232
|
-
* @param traceId The trace ID to capture the metric for.
|
|
233
|
-
* @param metricName The name of the metric to capture.
|
|
234
|
-
* @param metricValue The value of the metric to capture.
|
|
235
|
-
*/
|
|
236
|
-
captureTraceMetric(traceId: string | number, metricName: string, metricValue: string | number | boolean): void;
|
|
237
|
-
}
|
|
238
|
-
export * from './types';
|
|
239
|
-
export { LZString };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare const LZString: {
|
|
2
|
-
compressToBase64: (input: any) => string;
|
|
3
|
-
decompressFromBase64: (input: any) => any;
|
|
4
|
-
compress: (uncompressed: any) => any;
|
|
5
|
-
_compress: (uncompressed: any, bitsPerChar: any, getCharFromInt: any) => any;
|
|
6
|
-
decompress: (compressed: any) => any;
|
|
7
|
-
_decompress: (length: any, resetValue: any, getNextValue: any) => any;
|
|
8
|
-
};
|
|
@@ -1,422 +0,0 @@
|
|
|
1
|
-
export 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
|
-
export 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
|
-
export 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
|
-
export 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
|
-
export type PostHogFetchResponse = {
|
|
103
|
-
status: number;
|
|
104
|
-
text: () => Promise<string>;
|
|
105
|
-
json: () => Promise<any>;
|
|
106
|
-
};
|
|
107
|
-
export type PostHogQueueItem = {
|
|
108
|
-
message: any;
|
|
109
|
-
callback?: (err: any) => void;
|
|
110
|
-
};
|
|
111
|
-
export type PostHogEventProperties = {
|
|
112
|
-
[key: string]: any;
|
|
113
|
-
};
|
|
114
|
-
export type PostHogAutocaptureElement = {
|
|
115
|
-
$el_text?: string;
|
|
116
|
-
tag_name: string;
|
|
117
|
-
href?: string;
|
|
118
|
-
nth_child?: number;
|
|
119
|
-
nth_of_type?: number;
|
|
120
|
-
order?: number;
|
|
121
|
-
} & {
|
|
122
|
-
[key: string]: any;
|
|
123
|
-
};
|
|
124
|
-
export type PostHogRemoteConfig = {
|
|
125
|
-
sessionRecording?: boolean | {
|
|
126
|
-
[key: string]: JsonType;
|
|
127
|
-
};
|
|
128
|
-
/**
|
|
129
|
-
* Whether surveys are enabled
|
|
130
|
-
*/
|
|
131
|
-
surveys?: boolean | Survey[];
|
|
132
|
-
/**
|
|
133
|
-
* Indicates if the team has any flags enabled (if not we don't need to load them)
|
|
134
|
-
*/
|
|
135
|
-
hasFeatureFlags?: boolean;
|
|
136
|
-
};
|
|
137
|
-
export type FeatureFlagValue = string | boolean;
|
|
138
|
-
export type PostHogDecideResponse = Omit<PostHogRemoteConfig, 'surveys' | 'hasFeatureFlags'> & {
|
|
139
|
-
featureFlags: {
|
|
140
|
-
[key: string]: FeatureFlagValue;
|
|
141
|
-
};
|
|
142
|
-
featureFlagPayloads: {
|
|
143
|
-
[key: string]: JsonType;
|
|
144
|
-
};
|
|
145
|
-
flags: {
|
|
146
|
-
[key: string]: FeatureFlagDetail;
|
|
147
|
-
};
|
|
148
|
-
errorsWhileComputingFlags: boolean;
|
|
149
|
-
sessionRecording?: boolean | {
|
|
150
|
-
[key: string]: JsonType;
|
|
151
|
-
};
|
|
152
|
-
quotaLimited?: string[];
|
|
153
|
-
requestId?: string;
|
|
154
|
-
};
|
|
155
|
-
export type PostHogFeatureFlagsResponse = PartialWithRequired<PostHogDecideResponse, 'flags' | 'featureFlags' | 'featureFlagPayloads' | 'requestId'>;
|
|
156
|
-
/**
|
|
157
|
-
* Creates a type with all properties of T, but makes only K properties required while the rest remain optional.
|
|
158
|
-
*
|
|
159
|
-
* @template T - The base type containing all properties
|
|
160
|
-
* @template K - Union type of keys from T that should be required
|
|
161
|
-
*
|
|
162
|
-
* @example
|
|
163
|
-
* interface User {
|
|
164
|
-
* id: number;
|
|
165
|
-
* name: string;
|
|
166
|
-
* email?: string;
|
|
167
|
-
* age?: number;
|
|
168
|
-
* }
|
|
169
|
-
*
|
|
170
|
-
* // Makes 'id' and 'name' required, but 'email' and 'age' optional
|
|
171
|
-
* type RequiredUser = PartialWithRequired<User, 'id' | 'name'>;
|
|
172
|
-
*
|
|
173
|
-
* const user: RequiredUser = {
|
|
174
|
-
* id: 1, // Must be provided
|
|
175
|
-
* name: "John" // Must be provided
|
|
176
|
-
* // email and age are optional
|
|
177
|
-
* };
|
|
178
|
-
*/
|
|
179
|
-
export type PartialWithRequired<T, K extends keyof T> = {
|
|
180
|
-
[P in K]: T[P];
|
|
181
|
-
} & {
|
|
182
|
-
[P in Exclude<keyof T, K>]?: T[P];
|
|
183
|
-
};
|
|
184
|
-
/**
|
|
185
|
-
* These are the fields we care about from PostHogDecideResponse for feature flags.
|
|
186
|
-
*/
|
|
187
|
-
export type PostHogFeatureFlagDetails = PartialWithRequired<PostHogDecideResponse, 'flags' | 'featureFlags' | 'featureFlagPayloads' | 'requestId'>;
|
|
188
|
-
/**
|
|
189
|
-
* Models the response from the v3 `/decide` endpoint.
|
|
190
|
-
*/
|
|
191
|
-
export type PostHogV3DecideResponse = Omit<PostHogDecideResponse, 'flags'>;
|
|
192
|
-
export type PostHogV4DecideResponse = Omit<PostHogDecideResponse, 'featureFlags' | 'featureFlagPayloads'>;
|
|
193
|
-
/**
|
|
194
|
-
* The format of the flags object in persisted storage
|
|
195
|
-
*
|
|
196
|
-
* When we pull flags from persistence, we can normalize them to PostHogFeatureFlagDetails
|
|
197
|
-
* so that we can support v3 and v4 of the API.
|
|
198
|
-
*/
|
|
199
|
-
export type PostHogFlagsStorageFormat = Pick<PostHogFeatureFlagDetails, 'flags'>;
|
|
200
|
-
/**
|
|
201
|
-
* Models legacy flags and payloads return type for many public methods.
|
|
202
|
-
*/
|
|
203
|
-
export type PostHogFlagsAndPayloadsResponse = Partial<Pick<PostHogDecideResponse, 'featureFlags' | 'featureFlagPayloads'>>;
|
|
204
|
-
export type JsonType = string | number | boolean | null | {
|
|
205
|
-
[key: string]: JsonType;
|
|
206
|
-
} | Array<JsonType>;
|
|
207
|
-
export type FetchLike = (url: string, options: PostHogFetchOptions) => Promise<PostHogFetchResponse>;
|
|
208
|
-
export type FeatureFlagDetail = {
|
|
209
|
-
key: string;
|
|
210
|
-
enabled: boolean;
|
|
211
|
-
variant: string | undefined;
|
|
212
|
-
reason: EvaluationReason | undefined;
|
|
213
|
-
metadata: FeatureFlagMetadata | undefined;
|
|
214
|
-
};
|
|
215
|
-
export type FeatureFlagMetadata = {
|
|
216
|
-
id: number | undefined;
|
|
217
|
-
version: number | undefined;
|
|
218
|
-
description: string | undefined;
|
|
219
|
-
payload: string | undefined;
|
|
220
|
-
};
|
|
221
|
-
export type EvaluationReason = {
|
|
222
|
-
code: string | undefined;
|
|
223
|
-
condition_index: number | undefined;
|
|
224
|
-
description: string | undefined;
|
|
225
|
-
};
|
|
226
|
-
export type SurveyAppearance = {
|
|
227
|
-
backgroundColor?: string;
|
|
228
|
-
submitButtonColor?: string;
|
|
229
|
-
submitButtonText?: string;
|
|
230
|
-
submitButtonTextColor?: string;
|
|
231
|
-
ratingButtonColor?: string;
|
|
232
|
-
ratingButtonActiveColor?: string;
|
|
233
|
-
autoDisappear?: boolean;
|
|
234
|
-
displayThankYouMessage?: boolean;
|
|
235
|
-
thankYouMessageHeader?: string;
|
|
236
|
-
thankYouMessageDescription?: string;
|
|
237
|
-
thankYouMessageDescriptionContentType?: SurveyQuestionDescriptionContentType;
|
|
238
|
-
thankYouMessageCloseButtonText?: string;
|
|
239
|
-
borderColor?: string;
|
|
240
|
-
position?: SurveyPosition;
|
|
241
|
-
placeholder?: string;
|
|
242
|
-
shuffleQuestions?: boolean;
|
|
243
|
-
surveyPopupDelaySeconds?: number;
|
|
244
|
-
widgetType?: SurveyWidgetType;
|
|
245
|
-
widgetSelector?: string;
|
|
246
|
-
widgetLabel?: string;
|
|
247
|
-
widgetColor?: string;
|
|
248
|
-
};
|
|
249
|
-
export declare enum SurveyPosition {
|
|
250
|
-
Left = "left",
|
|
251
|
-
Right = "right",
|
|
252
|
-
Center = "center"
|
|
253
|
-
}
|
|
254
|
-
export declare enum SurveyWidgetType {
|
|
255
|
-
Button = "button",
|
|
256
|
-
Tab = "tab",
|
|
257
|
-
Selector = "selector"
|
|
258
|
-
}
|
|
259
|
-
export declare enum SurveyType {
|
|
260
|
-
Popover = "popover",
|
|
261
|
-
API = "api",
|
|
262
|
-
Widget = "widget"
|
|
263
|
-
}
|
|
264
|
-
export type SurveyQuestion = BasicSurveyQuestion | LinkSurveyQuestion | RatingSurveyQuestion | MultipleSurveyQuestion;
|
|
265
|
-
export declare enum SurveyQuestionDescriptionContentType {
|
|
266
|
-
Html = "html",
|
|
267
|
-
Text = "text"
|
|
268
|
-
}
|
|
269
|
-
type SurveyQuestionBase = {
|
|
270
|
-
question: string;
|
|
271
|
-
id?: string;
|
|
272
|
-
description?: string;
|
|
273
|
-
descriptionContentType?: SurveyQuestionDescriptionContentType;
|
|
274
|
-
optional?: boolean;
|
|
275
|
-
buttonText?: string;
|
|
276
|
-
originalQuestionIndex: number;
|
|
277
|
-
branching?: NextQuestionBranching | EndBranching | ResponseBasedBranching | SpecificQuestionBranching;
|
|
278
|
-
};
|
|
279
|
-
export type BasicSurveyQuestion = SurveyQuestionBase & {
|
|
280
|
-
type: SurveyQuestionType.Open;
|
|
281
|
-
};
|
|
282
|
-
export type LinkSurveyQuestion = SurveyQuestionBase & {
|
|
283
|
-
type: SurveyQuestionType.Link;
|
|
284
|
-
link?: string;
|
|
285
|
-
};
|
|
286
|
-
export type RatingSurveyQuestion = SurveyQuestionBase & {
|
|
287
|
-
type: SurveyQuestionType.Rating;
|
|
288
|
-
display: SurveyRatingDisplay;
|
|
289
|
-
scale: 3 | 5 | 7 | 10;
|
|
290
|
-
lowerBoundLabel: string;
|
|
291
|
-
upperBoundLabel: string;
|
|
292
|
-
};
|
|
293
|
-
export declare enum SurveyRatingDisplay {
|
|
294
|
-
Number = "number",
|
|
295
|
-
Emoji = "emoji"
|
|
296
|
-
}
|
|
297
|
-
export type MultipleSurveyQuestion = SurveyQuestionBase & {
|
|
298
|
-
type: SurveyQuestionType.SingleChoice | SurveyQuestionType.MultipleChoice;
|
|
299
|
-
choices: string[];
|
|
300
|
-
hasOpenChoice?: boolean;
|
|
301
|
-
shuffleOptions?: boolean;
|
|
302
|
-
};
|
|
303
|
-
export declare enum SurveyQuestionType {
|
|
304
|
-
Open = "open",
|
|
305
|
-
MultipleChoice = "multiple_choice",
|
|
306
|
-
SingleChoice = "single_choice",
|
|
307
|
-
Rating = "rating",
|
|
308
|
-
Link = "link"
|
|
309
|
-
}
|
|
310
|
-
export declare enum SurveyQuestionBranchingType {
|
|
311
|
-
NextQuestion = "next_question",
|
|
312
|
-
End = "end",
|
|
313
|
-
ResponseBased = "response_based",
|
|
314
|
-
SpecificQuestion = "specific_question"
|
|
315
|
-
}
|
|
316
|
-
export type NextQuestionBranching = {
|
|
317
|
-
type: SurveyQuestionBranchingType.NextQuestion;
|
|
318
|
-
};
|
|
319
|
-
export type EndBranching = {
|
|
320
|
-
type: SurveyQuestionBranchingType.End;
|
|
321
|
-
};
|
|
322
|
-
export type ResponseBasedBranching = {
|
|
323
|
-
type: SurveyQuestionBranchingType.ResponseBased;
|
|
324
|
-
responseValues: Record<string, any>;
|
|
325
|
-
};
|
|
326
|
-
export type SpecificQuestionBranching = {
|
|
327
|
-
type: SurveyQuestionBranchingType.SpecificQuestion;
|
|
328
|
-
index: number;
|
|
329
|
-
};
|
|
330
|
-
export type SurveyResponse = {
|
|
331
|
-
surveys: Survey[];
|
|
332
|
-
};
|
|
333
|
-
export type SurveyCallback = (surveys: Survey[]) => void;
|
|
334
|
-
export declare enum SurveyMatchType {
|
|
335
|
-
Regex = "regex",
|
|
336
|
-
NotRegex = "not_regex",
|
|
337
|
-
Exact = "exact",
|
|
338
|
-
IsNot = "is_not",
|
|
339
|
-
Icontains = "icontains",
|
|
340
|
-
NotIcontains = "not_icontains"
|
|
341
|
-
}
|
|
342
|
-
export type SurveyElement = {
|
|
343
|
-
text?: string;
|
|
344
|
-
$el_text?: string;
|
|
345
|
-
tag_name?: string;
|
|
346
|
-
href?: string;
|
|
347
|
-
attr_id?: string;
|
|
348
|
-
attr_class?: string[];
|
|
349
|
-
nth_child?: number;
|
|
350
|
-
nth_of_type?: number;
|
|
351
|
-
attributes?: Record<string, any>;
|
|
352
|
-
event_id?: number;
|
|
353
|
-
order?: number;
|
|
354
|
-
group_id?: number;
|
|
355
|
-
};
|
|
356
|
-
export type SurveyRenderReason = {
|
|
357
|
-
visible: boolean;
|
|
358
|
-
disabledReason?: string;
|
|
359
|
-
};
|
|
360
|
-
export type Survey = {
|
|
361
|
-
id: string;
|
|
362
|
-
name: string;
|
|
363
|
-
description?: string;
|
|
364
|
-
type: SurveyType;
|
|
365
|
-
feature_flag_keys?: {
|
|
366
|
-
key: string;
|
|
367
|
-
value?: string;
|
|
368
|
-
}[];
|
|
369
|
-
linked_flag_key?: string;
|
|
370
|
-
targeting_flag_key?: string;
|
|
371
|
-
internal_targeting_flag_key?: string;
|
|
372
|
-
questions: SurveyQuestion[];
|
|
373
|
-
appearance?: SurveyAppearance;
|
|
374
|
-
conditions?: {
|
|
375
|
-
url?: string;
|
|
376
|
-
selector?: string;
|
|
377
|
-
seenSurveyWaitPeriodInDays?: number;
|
|
378
|
-
urlMatchType?: SurveyMatchType;
|
|
379
|
-
events?: {
|
|
380
|
-
repeatedActivation?: boolean;
|
|
381
|
-
values?: {
|
|
382
|
-
name: string;
|
|
383
|
-
}[];
|
|
384
|
-
};
|
|
385
|
-
actions?: {
|
|
386
|
-
values: SurveyActionType[];
|
|
387
|
-
};
|
|
388
|
-
deviceTypes?: string[];
|
|
389
|
-
deviceTypesMatchType?: SurveyMatchType;
|
|
390
|
-
};
|
|
391
|
-
start_date?: string;
|
|
392
|
-
end_date?: string;
|
|
393
|
-
current_iteration?: number;
|
|
394
|
-
current_iteration_start_date?: string;
|
|
395
|
-
};
|
|
396
|
-
export type SurveyActionType = {
|
|
397
|
-
id: number;
|
|
398
|
-
name?: string;
|
|
399
|
-
steps?: ActionStepType[];
|
|
400
|
-
};
|
|
401
|
-
/** Sync with plugin-server/src/types.ts */
|
|
402
|
-
export declare enum ActionStepStringMatching {
|
|
403
|
-
Contains = "contains",
|
|
404
|
-
Exact = "exact",
|
|
405
|
-
Regex = "regex"
|
|
406
|
-
}
|
|
407
|
-
export type ActionStepType = {
|
|
408
|
-
event?: string;
|
|
409
|
-
selector?: string;
|
|
410
|
-
/** @deprecated Only `selector` should be used now. */
|
|
411
|
-
tag_name?: string;
|
|
412
|
-
text?: string;
|
|
413
|
-
/** @default StringMatching.Exact */
|
|
414
|
-
text_matching?: ActionStepStringMatching;
|
|
415
|
-
href?: string;
|
|
416
|
-
/** @default ActionStepStringMatching.Exact */
|
|
417
|
-
href_matching?: ActionStepStringMatching;
|
|
418
|
-
url?: string;
|
|
419
|
-
/** @default StringMatching.Contains */
|
|
420
|
-
url_matching?: ActionStepStringMatching;
|
|
421
|
-
};
|
|
422
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { FetchLike } from './types';
|
|
2
|
-
export declare const NEW_FLAGS_ROLLOUT_PERCENTAGE = 1;
|
|
3
|
-
export declare const NEW_FLAGS_EXCLUDED_HASHES: Set<string>;
|
|
4
|
-
export declare function assert(truthyValue: any, message: string): void;
|
|
5
|
-
export declare function removeTrailingSlash(url: string): string;
|
|
6
|
-
export interface RetriableOptions {
|
|
7
|
-
retryCount: number;
|
|
8
|
-
retryDelay: number;
|
|
9
|
-
retryCheck: (err: any) => boolean;
|
|
10
|
-
}
|
|
11
|
-
export declare function retriable<T>(fn: () => Promise<T>, props: RetriableOptions): Promise<T>;
|
|
12
|
-
export declare function currentTimestamp(): number;
|
|
13
|
-
export declare function currentISOTime(): string;
|
|
14
|
-
export declare function safeSetTimeout(fn: () => void, timeout: number): any;
|
|
15
|
-
export declare const isPromise: (obj: any) => obj is Promise<any>;
|
|
16
|
-
export declare const isError: (x: unknown) => x is Error;
|
|
17
|
-
export declare function getFetch(): FetchLike | undefined;
|
|
18
|
-
export declare const isFunction: (f: any) => f is (...args: any[]) => any;
|
|
19
|
-
export declare function isTokenInRollout(token: string, percentage?: number, excludedHashes?: Set<string>): boolean;
|