posthog-js-lite 2.2.0 → 2.2.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 +4 -0
- package/lib/index.cjs.js +414 -227
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +55 -22
- package/lib/index.esm.js +414 -227
- package/lib/index.esm.js.map +1 -1
- package/lib/posthog-core/src/index.d.ts +55 -22
- package/package.json +1 -1
- package/lib/node_modules/tslib/tslib.es6.d.ts +0 -35
package/lib/index.d.ts
CHANGED
|
@@ -100,42 +100,84 @@ declare class SimpleEventEmitter {
|
|
|
100
100
|
emit(event: string, payload: any): void;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
declare abstract class
|
|
103
|
+
declare abstract class PostHogCoreStateless {
|
|
104
104
|
private apiKey;
|
|
105
105
|
host: string;
|
|
106
106
|
private flushAt;
|
|
107
107
|
private flushInterval;
|
|
108
108
|
private requestTimeout;
|
|
109
109
|
private captureMode;
|
|
110
|
-
private sendFeatureFlagEvent;
|
|
111
|
-
private flagCallReported;
|
|
112
110
|
private removeDebugCallback?;
|
|
111
|
+
private _optoutOverride;
|
|
113
112
|
protected _events: SimpleEventEmitter;
|
|
114
113
|
protected _flushTimer?: any;
|
|
115
|
-
protected _decideResponsePromise?: Promise<PostHogDecideResponse>;
|
|
116
114
|
protected _retryOptions: RetriableOptions;
|
|
117
|
-
protected _sessionExpirationTimeSeconds: number;
|
|
118
115
|
abstract fetch(url: string, options: PostHogFetchOptions): Promise<PostHogFetchResponse>;
|
|
119
116
|
abstract getLibraryId(): string;
|
|
120
117
|
abstract getLibraryVersion(): string;
|
|
121
118
|
abstract getCustomUserAgent(): string | void;
|
|
122
119
|
abstract getPersistedProperty<T>(key: PostHogPersistedProperty): T | undefined;
|
|
123
120
|
abstract setPersistedProperty<T>(key: PostHogPersistedProperty, value: T | null): void;
|
|
124
|
-
private _optoutOverride;
|
|
125
121
|
constructor(apiKey: string, options?: PosthogCoreOptions);
|
|
126
122
|
protected getCommonEventProperties(): any;
|
|
123
|
+
get optedOut(): boolean;
|
|
124
|
+
optIn(): void;
|
|
125
|
+
optOut(): void;
|
|
126
|
+
on(event: string, cb: (...args: any[]) => void): () => void;
|
|
127
|
+
debug(enabled?: boolean): void;
|
|
128
|
+
private buildPayload;
|
|
129
|
+
/***
|
|
130
|
+
*** TRACKING
|
|
131
|
+
***/
|
|
132
|
+
protected identifyStateless(distinctId: string, properties?: PostHogEventProperties, options?: PosthogCaptureOptions): this;
|
|
133
|
+
protected captureStateless(distinctId: string, event: string, properties?: {
|
|
134
|
+
[key: string]: any;
|
|
135
|
+
}, options?: PosthogCaptureOptions): this;
|
|
136
|
+
protected aliasStateless(alias: string, distinctId: string, properties?: {
|
|
137
|
+
[key: string]: any;
|
|
138
|
+
}): this;
|
|
139
|
+
/***
|
|
140
|
+
*** GROUPS
|
|
141
|
+
***/
|
|
142
|
+
protected groupIdentifyStateless(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties, options?: PosthogCaptureOptions, distinctId?: string, eventProperties?: PostHogEventProperties): this;
|
|
143
|
+
/***
|
|
144
|
+
*** FEATURE FLAGS
|
|
145
|
+
***/
|
|
146
|
+
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>;
|
|
147
|
+
protected getFeatureFlagStateless(key: string, distinctId: string, groups?: Record<string, string>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>): Promise<boolean | string | undefined>;
|
|
148
|
+
protected getFeatureFlagPayloadStateless(key: string, distinctId: string, groups?: Record<string, string>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>): Promise<JsonType | undefined>;
|
|
149
|
+
protected getFeatureFlagPayloadsStateless(distinctId: string, groups?: Record<string, string>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>): Promise<PostHogDecideResponse['featureFlagPayloads'] | undefined>;
|
|
150
|
+
protected _parsePayload(response: any): any;
|
|
151
|
+
protected getFeatureFlagsStateless(distinctId: string, groups?: Record<string, string | number>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>): Promise<PostHogDecideResponse['featureFlags'] | undefined>;
|
|
152
|
+
protected getFeatureFlagsAndPayloadsStateless(distinctId: string, groups?: Record<string, string | number>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>): Promise<{
|
|
153
|
+
flags: PostHogDecideResponse['featureFlags'] | undefined;
|
|
154
|
+
payloads: PostHogDecideResponse['featureFlagPayloads'] | undefined;
|
|
155
|
+
}>;
|
|
156
|
+
/***
|
|
157
|
+
*** QUEUEING AND FLUSHING
|
|
158
|
+
***/
|
|
159
|
+
protected enqueue(type: string, _message: any, options?: PosthogCaptureOptions): void;
|
|
160
|
+
flushAsync(): Promise<any>;
|
|
161
|
+
flush(callback?: (err?: any, data?: any) => void): void;
|
|
162
|
+
private fetchWithRetry;
|
|
163
|
+
shutdownAsync(): Promise<void>;
|
|
164
|
+
shutdown(): void;
|
|
165
|
+
}
|
|
166
|
+
declare abstract class PostHogCore extends PostHogCoreStateless {
|
|
167
|
+
private sendFeatureFlagEvent;
|
|
168
|
+
private flagCallReported;
|
|
169
|
+
protected _decideResponsePromise?: Promise<PostHogDecideResponse | undefined>;
|
|
170
|
+
protected _sessionExpirationTimeSeconds: number;
|
|
171
|
+
constructor(apiKey: string, options?: PosthogCoreOptions);
|
|
127
172
|
protected setupBootstrap(options?: Partial<PosthogCoreOptions>): void;
|
|
128
173
|
private get props();
|
|
129
174
|
private set props(value);
|
|
130
175
|
private clearProps;
|
|
131
176
|
private _props;
|
|
132
|
-
get optedOut(): boolean;
|
|
133
|
-
optIn(): void;
|
|
134
|
-
optOut(): void;
|
|
135
177
|
on(event: string, cb: (...args: any[]) => void): () => void;
|
|
136
178
|
reset(propertiesToKeep?: PostHogPersistedProperty[]): void;
|
|
137
|
-
|
|
138
|
-
private
|
|
179
|
+
protected getCommonEventProperties(): any;
|
|
180
|
+
private enrichProperties;
|
|
139
181
|
getSessionId(): string | undefined;
|
|
140
182
|
resetSessionId(): void;
|
|
141
183
|
getAnonymousId(): string;
|
|
@@ -180,26 +222,17 @@ declare abstract class PostHogCore {
|
|
|
180
222
|
getFeatureFlag(key: string): boolean | string | undefined;
|
|
181
223
|
getFeatureFlagPayload(key: string): JsonType | undefined;
|
|
182
224
|
getFeatureFlagPayloads(): PostHogDecideResponse['featureFlagPayloads'] | undefined;
|
|
183
|
-
_parsePayload(response: any): any;
|
|
184
225
|
getFeatureFlags(): PostHogDecideResponse['featureFlags'] | undefined;
|
|
185
226
|
getFeatureFlagsAndPayloads(): {
|
|
186
227
|
flags: PostHogDecideResponse['featureFlags'] | undefined;
|
|
187
228
|
payloads: PostHogDecideResponse['featureFlagPayloads'] | undefined;
|
|
188
229
|
};
|
|
189
230
|
isFeatureEnabled(key: string): boolean | undefined;
|
|
190
|
-
|
|
231
|
+
reloadFeatureFlags(cb?: (err?: Error, flags?: PostHogDecideResponse['featureFlags']) => void): void;
|
|
232
|
+
reloadFeatureFlagsAsync(sendAnonDistinctId?: boolean): Promise<PostHogDecideResponse['featureFlags'] | undefined>;
|
|
191
233
|
onFeatureFlags(cb: (flags: PostHogDecideResponse['featureFlags']) => void): () => void;
|
|
192
234
|
onFeatureFlag(key: string, cb: (value: string | boolean) => void): () => void;
|
|
193
235
|
overrideFeatureFlag(flags: PostHogDecideResponse['featureFlags'] | null): void;
|
|
194
|
-
/***
|
|
195
|
-
*** QUEUEING AND FLUSHING
|
|
196
|
-
***/
|
|
197
|
-
private enqueue;
|
|
198
|
-
flushAsync(): Promise<any>;
|
|
199
|
-
flush(callback?: (err?: any, data?: any) => void): void;
|
|
200
|
-
private fetchWithRetry;
|
|
201
|
-
shutdownAsync(): Promise<void>;
|
|
202
|
-
shutdown(): void;
|
|
203
236
|
}
|
|
204
237
|
|
|
205
238
|
declare type PostHogOptions = {
|