posthog-js-lite 2.2.0 → 2.3.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 +12 -0
- package/lib/index.cjs.js +516 -238
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +61 -23
- package/lib/index.esm.js +516 -238
- package/lib/index.esm.js.map +1 -1
- package/lib/posthog-core/src/index.d.ts +58 -22
- package/lib/posthog-core/src/types.d.ts +2 -0
- package/lib/posthog-core/src/utils.d.ts +1 -1
- package/package.json +1 -1
- package/tsconfig.json +1 -1
- package/lib/node_modules/tslib/tslib.es6.d.ts +0 -35
|
@@ -3,42 +3,87 @@ import { RetriableOptions } from './utils';
|
|
|
3
3
|
export * as utils from './utils';
|
|
4
4
|
import { LZString } from './lz-string';
|
|
5
5
|
import { SimpleEventEmitter } from './eventemitter';
|
|
6
|
-
export declare abstract class
|
|
6
|
+
export declare abstract class PostHogCoreStateless {
|
|
7
7
|
private apiKey;
|
|
8
8
|
host: string;
|
|
9
9
|
private flushAt;
|
|
10
10
|
private flushInterval;
|
|
11
11
|
private requestTimeout;
|
|
12
12
|
private captureMode;
|
|
13
|
-
private sendFeatureFlagEvent;
|
|
14
|
-
private flagCallReported;
|
|
15
13
|
private removeDebugCallback?;
|
|
14
|
+
private debugMode;
|
|
15
|
+
private pendingPromises;
|
|
16
|
+
private disableGeoip;
|
|
17
|
+
private _optoutOverride;
|
|
16
18
|
protected _events: SimpleEventEmitter;
|
|
17
19
|
protected _flushTimer?: any;
|
|
18
|
-
protected _decideResponsePromise?: Promise<PostHogDecideResponse>;
|
|
19
20
|
protected _retryOptions: RetriableOptions;
|
|
20
|
-
protected _sessionExpirationTimeSeconds: number;
|
|
21
21
|
abstract fetch(url: string, options: PostHogFetchOptions): Promise<PostHogFetchResponse>;
|
|
22
22
|
abstract getLibraryId(): string;
|
|
23
23
|
abstract getLibraryVersion(): string;
|
|
24
24
|
abstract getCustomUserAgent(): string | void;
|
|
25
25
|
abstract getPersistedProperty<T>(key: PostHogPersistedProperty): T | undefined;
|
|
26
26
|
abstract setPersistedProperty<T>(key: PostHogPersistedProperty, value: T | null): void;
|
|
27
|
-
private _optoutOverride;
|
|
28
27
|
constructor(apiKey: string, options?: PosthogCoreOptions);
|
|
29
28
|
protected getCommonEventProperties(): any;
|
|
29
|
+
get optedOut(): boolean;
|
|
30
|
+
optIn(): void;
|
|
31
|
+
optOut(): void;
|
|
32
|
+
on(event: string, cb: (...args: any[]) => void): () => void;
|
|
33
|
+
debug(enabled?: boolean): void;
|
|
34
|
+
private buildPayload;
|
|
35
|
+
/***
|
|
36
|
+
*** TRACKING
|
|
37
|
+
***/
|
|
38
|
+
protected identifyStateless(distinctId: string, properties?: PostHogEventProperties, options?: PosthogCaptureOptions): this;
|
|
39
|
+
protected captureStateless(distinctId: string, event: string, properties?: {
|
|
40
|
+
[key: string]: any;
|
|
41
|
+
}, options?: PosthogCaptureOptions): this;
|
|
42
|
+
protected aliasStateless(alias: string, distinctId: string, properties?: {
|
|
43
|
+
[key: string]: any;
|
|
44
|
+
}, options?: PosthogCaptureOptions): this;
|
|
45
|
+
/***
|
|
46
|
+
*** GROUPS
|
|
47
|
+
***/
|
|
48
|
+
protected groupIdentifyStateless(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties, options?: PosthogCaptureOptions, distinctId?: string, eventProperties?: PostHogEventProperties): this;
|
|
49
|
+
/***
|
|
50
|
+
*** FEATURE FLAGS
|
|
51
|
+
***/
|
|
52
|
+
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>;
|
|
53
|
+
protected getFeatureFlagStateless(key: string, distinctId: string, groups?: Record<string, string>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, disableGeoip?: boolean): Promise<boolean | string | undefined>;
|
|
54
|
+
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>;
|
|
55
|
+
protected getFeatureFlagPayloadsStateless(distinctId: string, groups?: Record<string, string>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, disableGeoip?: boolean): Promise<PostHogDecideResponse['featureFlagPayloads'] | undefined>;
|
|
56
|
+
protected _parsePayload(response: any): any;
|
|
57
|
+
protected getFeatureFlagsStateless(distinctId: string, groups?: Record<string, string | number>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, disableGeoip?: boolean): Promise<PostHogDecideResponse['featureFlags'] | undefined>;
|
|
58
|
+
protected getFeatureFlagsAndPayloadsStateless(distinctId: string, groups?: Record<string, string | number>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, disableGeoip?: boolean): Promise<{
|
|
59
|
+
flags: PostHogDecideResponse['featureFlags'] | undefined;
|
|
60
|
+
payloads: PostHogDecideResponse['featureFlagPayloads'] | undefined;
|
|
61
|
+
}>;
|
|
62
|
+
/***
|
|
63
|
+
*** QUEUEING AND FLUSHING
|
|
64
|
+
***/
|
|
65
|
+
protected enqueue(type: string, _message: any, options?: PosthogCaptureOptions): void;
|
|
66
|
+
flushAsync(): Promise<any>;
|
|
67
|
+
flush(callback?: (err?: any, data?: any) => void): void;
|
|
68
|
+
private fetchWithRetry;
|
|
69
|
+
shutdownAsync(): Promise<void>;
|
|
70
|
+
shutdown(): void;
|
|
71
|
+
}
|
|
72
|
+
export declare abstract class PostHogCore extends PostHogCoreStateless {
|
|
73
|
+
private sendFeatureFlagEvent;
|
|
74
|
+
private flagCallReported;
|
|
75
|
+
protected _decideResponsePromise?: Promise<PostHogDecideResponse | undefined>;
|
|
76
|
+
protected _sessionExpirationTimeSeconds: number;
|
|
77
|
+
constructor(apiKey: string, options?: PosthogCoreOptions);
|
|
30
78
|
protected setupBootstrap(options?: Partial<PosthogCoreOptions>): void;
|
|
31
79
|
private get props();
|
|
32
80
|
private set props(value);
|
|
33
81
|
private clearProps;
|
|
34
82
|
private _props;
|
|
35
|
-
get optedOut(): boolean;
|
|
36
|
-
optIn(): void;
|
|
37
|
-
optOut(): void;
|
|
38
83
|
on(event: string, cb: (...args: any[]) => void): () => void;
|
|
39
84
|
reset(propertiesToKeep?: PostHogPersistedProperty[]): void;
|
|
40
|
-
|
|
41
|
-
private
|
|
85
|
+
protected getCommonEventProperties(): any;
|
|
86
|
+
private enrichProperties;
|
|
42
87
|
getSessionId(): string | undefined;
|
|
43
88
|
resetSessionId(): void;
|
|
44
89
|
getAnonymousId(): string;
|
|
@@ -83,26 +128,17 @@ export declare abstract class PostHogCore {
|
|
|
83
128
|
getFeatureFlag(key: string): boolean | string | undefined;
|
|
84
129
|
getFeatureFlagPayload(key: string): JsonType | undefined;
|
|
85
130
|
getFeatureFlagPayloads(): PostHogDecideResponse['featureFlagPayloads'] | undefined;
|
|
86
|
-
_parsePayload(response: any): any;
|
|
87
131
|
getFeatureFlags(): PostHogDecideResponse['featureFlags'] | undefined;
|
|
88
132
|
getFeatureFlagsAndPayloads(): {
|
|
89
133
|
flags: PostHogDecideResponse['featureFlags'] | undefined;
|
|
90
134
|
payloads: PostHogDecideResponse['featureFlagPayloads'] | undefined;
|
|
91
135
|
};
|
|
92
136
|
isFeatureEnabled(key: string): boolean | undefined;
|
|
93
|
-
|
|
137
|
+
reloadFeatureFlags(cb?: (err?: Error, flags?: PostHogDecideResponse['featureFlags']) => void): void;
|
|
138
|
+
reloadFeatureFlagsAsync(sendAnonDistinctId?: boolean): Promise<PostHogDecideResponse['featureFlags'] | undefined>;
|
|
94
139
|
onFeatureFlags(cb: (flags: PostHogDecideResponse['featureFlags']) => void): () => void;
|
|
95
140
|
onFeatureFlag(key: string, cb: (value: string | boolean) => void): () => void;
|
|
96
141
|
overrideFeatureFlag(flags: PostHogDecideResponse['featureFlags'] | null): void;
|
|
97
|
-
/***
|
|
98
|
-
*** QUEUEING AND FLUSHING
|
|
99
|
-
***/
|
|
100
|
-
private enqueue;
|
|
101
|
-
flushAsync(): Promise<any>;
|
|
102
|
-
flush(callback?: (err?: any, data?: any) => void): void;
|
|
103
|
-
private fetchWithRetry;
|
|
104
|
-
shutdownAsync(): Promise<void>;
|
|
105
|
-
shutdown(): void;
|
|
106
142
|
}
|
|
107
143
|
export * from './types';
|
|
108
144
|
export { LZString };
|
|
@@ -16,6 +16,7 @@ export declare type PosthogCoreOptions = {
|
|
|
16
16
|
requestTimeout?: number;
|
|
17
17
|
sessionExpirationTimeSeconds?: number;
|
|
18
18
|
captureMode?: 'json' | 'form';
|
|
19
|
+
disableGeoip?: boolean;
|
|
19
20
|
};
|
|
20
21
|
export declare enum PostHogPersistedProperty {
|
|
21
22
|
AnonymousId = "anonymous_id",
|
|
@@ -43,6 +44,7 @@ export declare type PostHogFetchOptions = {
|
|
|
43
44
|
};
|
|
44
45
|
export declare type PosthogCaptureOptions = {
|
|
45
46
|
timestamp?: Date;
|
|
47
|
+
disableGeoip?: boolean;
|
|
46
48
|
};
|
|
47
49
|
export declare type PostHogFetchResponse = {
|
|
48
50
|
status: number;
|
|
@@ -3,7 +3,7 @@ export declare function removeTrailingSlash(url: string): string;
|
|
|
3
3
|
export interface RetriableOptions {
|
|
4
4
|
retryCount?: number;
|
|
5
5
|
retryDelay?: number;
|
|
6
|
-
retryCheck?: (err: any) =>
|
|
6
|
+
retryCheck?: (err: any) => boolean;
|
|
7
7
|
}
|
|
8
8
|
export declare function retriable<T>(fn: () => Promise<T>, props?: RetriableOptions): Promise<T>;
|
|
9
9
|
export declare function generateUUID(globalThis?: any): string;
|
package/package.json
CHANGED
package/tsconfig.json
CHANGED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export function __extends(d: any, b: any): void;
|
|
2
|
-
export function __rest(s: any, e: any): {};
|
|
3
|
-
export function __decorate(decorators: any, target: any, key: any, desc: any, ...args: any[]): any;
|
|
4
|
-
export function __param(paramIndex: any, decorator: any): (target: any, key: any) => void;
|
|
5
|
-
export function __metadata(metadataKey: any, metadataValue: any): any;
|
|
6
|
-
export function __awaiter(thisArg: any, _arguments: any, P: any, generator: any): any;
|
|
7
|
-
export function __generator(thisArg: any, body: any): {
|
|
8
|
-
next: (v: any) => any;
|
|
9
|
-
throw: (v: any) => any;
|
|
10
|
-
return: (v: any) => any;
|
|
11
|
-
};
|
|
12
|
-
export function __exportStar(m: any, o: any): void;
|
|
13
|
-
export function __values(o: any): any;
|
|
14
|
-
export function __read(o: any, n: any): any;
|
|
15
|
-
/** @deprecated */
|
|
16
|
-
export function __spread(...args: any[]): any[];
|
|
17
|
-
/** @deprecated */
|
|
18
|
-
export function __spreadArrays(...args: any[]): any[];
|
|
19
|
-
export function __spreadArray(to: any, from: any, pack: any, ...args: any[]): any;
|
|
20
|
-
export function __await(v: any): __await;
|
|
21
|
-
export class __await {
|
|
22
|
-
constructor(v: any);
|
|
23
|
-
v: any;
|
|
24
|
-
}
|
|
25
|
-
export function __asyncGenerator(thisArg: any, _arguments: any, generator: any): {};
|
|
26
|
-
export function __asyncDelegator(o: any): {};
|
|
27
|
-
export function __asyncValues(o: any): any;
|
|
28
|
-
export function __makeTemplateObject(cooked: any, raw: any): any;
|
|
29
|
-
export function __importStar(mod: any): any;
|
|
30
|
-
export function __importDefault(mod: any): any;
|
|
31
|
-
export function __classPrivateFieldGet(receiver: any, state: any, kind: any, f: any): any;
|
|
32
|
-
export function __classPrivateFieldSet(receiver: any, state: any, value: any, kind: any, f: any): any;
|
|
33
|
-
export function __classPrivateFieldIn(state: any, receiver: any): any;
|
|
34
|
-
export function __assign(...args: any[]): any;
|
|
35
|
-
export function __createBinding(o: any, m: any, k: any, k2: any): void;
|