posthog-js-lite 2.1.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 +10 -1
- package/lib/index.cjs.js +421 -248
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +63 -30
- package/lib/index.esm.js +421 -248
- package/lib/index.esm.js.map +1 -1
- package/lib/posthog-core/src/index.d.ts +61 -31
- package/lib/posthog-core/src/types.d.ts +3 -0
- package/package.json +1 -1
- package/lib/node_modules/tslib/tslib.es6.d.ts +0 -35
|
@@ -1,44 +1,86 @@
|
|
|
1
|
-
import { PostHogFetchOptions, PostHogFetchResponse, PostHogAutocaptureElement, PostHogDecideResponse, PosthogCoreOptions, PostHogEventProperties, PostHogPersistedProperty, JsonType } from './types';
|
|
1
|
+
import { PostHogFetchOptions, PostHogFetchResponse, PostHogAutocaptureElement, PostHogDecideResponse, PosthogCoreOptions, PostHogEventProperties, PostHogPersistedProperty, PosthogCaptureOptions, JsonType } from './types';
|
|
2
2
|
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 _optoutOverride;
|
|
16
15
|
protected _events: SimpleEventEmitter;
|
|
17
16
|
protected _flushTimer?: any;
|
|
18
|
-
protected _decideResponsePromise?: Promise<PostHogDecideResponse>;
|
|
19
17
|
protected _retryOptions: RetriableOptions;
|
|
20
|
-
protected _sessionExpirationTimeSeconds: number;
|
|
21
18
|
abstract fetch(url: string, options: PostHogFetchOptions): Promise<PostHogFetchResponse>;
|
|
22
19
|
abstract getLibraryId(): string;
|
|
23
20
|
abstract getLibraryVersion(): string;
|
|
24
21
|
abstract getCustomUserAgent(): string | void;
|
|
25
22
|
abstract getPersistedProperty<T>(key: PostHogPersistedProperty): T | undefined;
|
|
26
23
|
abstract setPersistedProperty<T>(key: PostHogPersistedProperty, value: T | null): void;
|
|
27
|
-
private _optoutOverride;
|
|
28
24
|
constructor(apiKey: string, options?: PosthogCoreOptions);
|
|
29
25
|
protected getCommonEventProperties(): any;
|
|
26
|
+
get optedOut(): boolean;
|
|
27
|
+
optIn(): void;
|
|
28
|
+
optOut(): void;
|
|
29
|
+
on(event: string, cb: (...args: any[]) => void): () => void;
|
|
30
|
+
debug(enabled?: boolean): void;
|
|
31
|
+
private buildPayload;
|
|
32
|
+
/***
|
|
33
|
+
*** TRACKING
|
|
34
|
+
***/
|
|
35
|
+
protected identifyStateless(distinctId: string, properties?: PostHogEventProperties, options?: PosthogCaptureOptions): this;
|
|
36
|
+
protected captureStateless(distinctId: string, event: string, properties?: {
|
|
37
|
+
[key: string]: any;
|
|
38
|
+
}, options?: PosthogCaptureOptions): this;
|
|
39
|
+
protected aliasStateless(alias: string, distinctId: string, properties?: {
|
|
40
|
+
[key: string]: any;
|
|
41
|
+
}): this;
|
|
42
|
+
/***
|
|
43
|
+
*** GROUPS
|
|
44
|
+
***/
|
|
45
|
+
protected groupIdentifyStateless(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties, options?: PosthogCaptureOptions, distinctId?: string, eventProperties?: PostHogEventProperties): this;
|
|
46
|
+
/***
|
|
47
|
+
*** FEATURE FLAGS
|
|
48
|
+
***/
|
|
49
|
+
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>;
|
|
50
|
+
protected getFeatureFlagStateless(key: string, distinctId: string, groups?: Record<string, string>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>): Promise<boolean | string | undefined>;
|
|
51
|
+
protected getFeatureFlagPayloadStateless(key: string, distinctId: string, groups?: Record<string, string>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>): Promise<JsonType | undefined>;
|
|
52
|
+
protected getFeatureFlagPayloadsStateless(distinctId: string, groups?: Record<string, string>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>): Promise<PostHogDecideResponse['featureFlagPayloads'] | undefined>;
|
|
53
|
+
protected _parsePayload(response: any): any;
|
|
54
|
+
protected getFeatureFlagsStateless(distinctId: string, groups?: Record<string, string | number>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>): Promise<PostHogDecideResponse['featureFlags'] | undefined>;
|
|
55
|
+
protected getFeatureFlagsAndPayloadsStateless(distinctId: string, groups?: Record<string, string | number>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>): Promise<{
|
|
56
|
+
flags: PostHogDecideResponse['featureFlags'] | undefined;
|
|
57
|
+
payloads: PostHogDecideResponse['featureFlagPayloads'] | undefined;
|
|
58
|
+
}>;
|
|
59
|
+
/***
|
|
60
|
+
*** QUEUEING AND FLUSHING
|
|
61
|
+
***/
|
|
62
|
+
protected enqueue(type: string, _message: any, options?: PosthogCaptureOptions): void;
|
|
63
|
+
flushAsync(): Promise<any>;
|
|
64
|
+
flush(callback?: (err?: any, data?: any) => void): void;
|
|
65
|
+
private fetchWithRetry;
|
|
66
|
+
shutdownAsync(): Promise<void>;
|
|
67
|
+
shutdown(): void;
|
|
68
|
+
}
|
|
69
|
+
export declare abstract class PostHogCore extends PostHogCoreStateless {
|
|
70
|
+
private sendFeatureFlagEvent;
|
|
71
|
+
private flagCallReported;
|
|
72
|
+
protected _decideResponsePromise?: Promise<PostHogDecideResponse | undefined>;
|
|
73
|
+
protected _sessionExpirationTimeSeconds: number;
|
|
74
|
+
constructor(apiKey: string, options?: PosthogCoreOptions);
|
|
30
75
|
protected setupBootstrap(options?: Partial<PosthogCoreOptions>): void;
|
|
31
76
|
private get props();
|
|
32
77
|
private set props(value);
|
|
33
78
|
private clearProps;
|
|
34
79
|
private _props;
|
|
35
|
-
get optedOut(): boolean;
|
|
36
|
-
optIn(): void;
|
|
37
|
-
optOut(): void;
|
|
38
80
|
on(event: string, cb: (...args: any[]) => void): () => void;
|
|
39
81
|
reset(propertiesToKeep?: PostHogPersistedProperty[]): void;
|
|
40
|
-
|
|
41
|
-
private
|
|
82
|
+
protected getCommonEventProperties(): any;
|
|
83
|
+
private enrichProperties;
|
|
42
84
|
getSessionId(): string | undefined;
|
|
43
85
|
resetSessionId(): void;
|
|
44
86
|
getAnonymousId(): string;
|
|
@@ -50,20 +92,20 @@ export declare abstract class PostHogCore {
|
|
|
50
92
|
/***
|
|
51
93
|
*** TRACKING
|
|
52
94
|
***/
|
|
53
|
-
identify(distinctId?: string, properties?: PostHogEventProperties): this;
|
|
95
|
+
identify(distinctId?: string, properties?: PostHogEventProperties, options?: PosthogCaptureOptions): this;
|
|
54
96
|
capture(event: string, properties?: {
|
|
55
97
|
[key: string]: any;
|
|
56
|
-
},
|
|
98
|
+
}, options?: PosthogCaptureOptions): this;
|
|
57
99
|
alias(alias: string): this;
|
|
58
|
-
autocapture(eventType: string, elements: PostHogAutocaptureElement[], properties?: PostHogEventProperties): this;
|
|
100
|
+
autocapture(eventType: string, elements: PostHogAutocaptureElement[], properties?: PostHogEventProperties, options?: PosthogCaptureOptions): this;
|
|
59
101
|
/***
|
|
60
102
|
*** GROUPS
|
|
61
103
|
***/
|
|
62
104
|
groups(groups: {
|
|
63
105
|
[type: string]: string | number;
|
|
64
106
|
}): this;
|
|
65
|
-
group(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties): this;
|
|
66
|
-
groupIdentify(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties): this;
|
|
107
|
+
group(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties, options?: PosthogCaptureOptions): this;
|
|
108
|
+
groupIdentify(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties, options?: PosthogCaptureOptions): this;
|
|
67
109
|
/***
|
|
68
110
|
* PROPERTIES
|
|
69
111
|
***/
|
|
@@ -83,29 +125,17 @@ export declare abstract class PostHogCore {
|
|
|
83
125
|
getFeatureFlag(key: string): boolean | string | undefined;
|
|
84
126
|
getFeatureFlagPayload(key: string): JsonType | undefined;
|
|
85
127
|
getFeatureFlagPayloads(): PostHogDecideResponse['featureFlagPayloads'] | undefined;
|
|
86
|
-
_parsePayload(response: any): any;
|
|
87
128
|
getFeatureFlags(): PostHogDecideResponse['featureFlags'] | undefined;
|
|
88
129
|
getFeatureFlagsAndPayloads(): {
|
|
89
130
|
flags: PostHogDecideResponse['featureFlags'] | undefined;
|
|
90
131
|
payloads: PostHogDecideResponse['featureFlagPayloads'] | undefined;
|
|
91
132
|
};
|
|
92
133
|
isFeatureEnabled(key: string): boolean | undefined;
|
|
93
|
-
|
|
134
|
+
reloadFeatureFlags(cb?: (err?: Error, flags?: PostHogDecideResponse['featureFlags']) => void): void;
|
|
135
|
+
reloadFeatureFlagsAsync(sendAnonDistinctId?: boolean): Promise<PostHogDecideResponse['featureFlags'] | undefined>;
|
|
94
136
|
onFeatureFlags(cb: (flags: PostHogDecideResponse['featureFlags']) => void): () => void;
|
|
95
137
|
onFeatureFlag(key: string, cb: (value: string | boolean) => void): () => void;
|
|
96
138
|
overrideFeatureFlag(flags: PostHogDecideResponse['featureFlags'] | null): void;
|
|
97
|
-
_sendFeatureFlags(event: string, properties?: {
|
|
98
|
-
[key: string]: any;
|
|
99
|
-
}): void;
|
|
100
|
-
/***
|
|
101
|
-
*** QUEUEING AND FLUSHING
|
|
102
|
-
***/
|
|
103
|
-
private enqueue;
|
|
104
|
-
flushAsync(): Promise<any>;
|
|
105
|
-
flush(callback?: (err?: any, data?: any) => void): void;
|
|
106
|
-
private fetchWithRetry;
|
|
107
|
-
shutdownAsync(): Promise<void>;
|
|
108
|
-
shutdown(): void;
|
|
109
139
|
}
|
|
110
140
|
export * from './types';
|
|
111
141
|
export { LZString };
|
|
@@ -41,6 +41,9 @@ export declare type PostHogFetchOptions = {
|
|
|
41
41
|
body?: string;
|
|
42
42
|
signal?: AbortSignal;
|
|
43
43
|
};
|
|
44
|
+
export declare type PosthogCaptureOptions = {
|
|
45
|
+
timestamp?: Date;
|
|
46
|
+
};
|
|
44
47
|
export declare type PostHogFetchResponse = {
|
|
45
48
|
status: number;
|
|
46
49
|
text: () => Promise<string>;
|
package/package.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;
|