posthog-js-lite 3.6.0 → 4.1.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 +11 -0
- package/lib/index.cjs +129 -645
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +39 -39
- package/lib/index.mjs +129 -645
- package/lib/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/posthog-web.spec.ts +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -50,8 +50,8 @@ type PostHogCoreOptions = {
|
|
|
50
50
|
remoteConfigRequestTimeoutMs?: number;
|
|
51
51
|
/** For Session Analysis how long before we expire a session (defaults to 30 mins) */
|
|
52
52
|
sessionExpirationTimeSeconds?: number;
|
|
53
|
-
/** Whether to
|
|
54
|
-
|
|
53
|
+
/** Whether to disable GZIP compression */
|
|
54
|
+
disableCompression?: boolean;
|
|
55
55
|
disableGeoip?: boolean;
|
|
56
56
|
/** Special flag to indicate ingested data is for a historical migration. */
|
|
57
57
|
historicalMigration?: boolean;
|
|
@@ -77,11 +77,11 @@ declare enum PostHogPersistedProperty {
|
|
|
77
77
|
InstalledAppBuild = "installed_app_build",
|
|
78
78
|
InstalledAppVersion = "installed_app_version",
|
|
79
79
|
SessionReplay = "session_replay",
|
|
80
|
-
DecideEndpointWasHit = "decide_endpoint_was_hit",
|
|
81
80
|
SurveyLastSeenDate = "survey_last_seen_date",
|
|
82
81
|
SurveysSeen = "surveys_seen",
|
|
83
82
|
Surveys = "surveys",
|
|
84
|
-
RemoteConfig = "remote_config"
|
|
83
|
+
RemoteConfig = "remote_config",
|
|
84
|
+
FlagsEndpointWasHit = "flags_endpoint_was_hit"
|
|
85
85
|
}
|
|
86
86
|
type PostHogFetchOptions = {
|
|
87
87
|
method: 'GET' | 'POST' | 'PUT' | 'PATCH';
|
|
@@ -90,7 +90,7 @@ type PostHogFetchOptions = {
|
|
|
90
90
|
headers: {
|
|
91
91
|
[key: string]: string;
|
|
92
92
|
};
|
|
93
|
-
body?: string;
|
|
93
|
+
body?: string | Blob;
|
|
94
94
|
signal?: AbortSignal;
|
|
95
95
|
};
|
|
96
96
|
type PostHogCaptureOptions = {
|
|
@@ -119,10 +119,18 @@ type PostHogAutocaptureElement = {
|
|
|
119
119
|
nth_of_type?: number;
|
|
120
120
|
order?: number;
|
|
121
121
|
} & PostHogEventProperties;
|
|
122
|
+
declare enum Compression {
|
|
123
|
+
GZipJS = "gzip-js",
|
|
124
|
+
Base64 = "base64"
|
|
125
|
+
}
|
|
122
126
|
type PostHogRemoteConfig = {
|
|
123
127
|
sessionRecording?: boolean | {
|
|
124
128
|
[key: string]: JsonType;
|
|
125
129
|
};
|
|
130
|
+
/**
|
|
131
|
+
* Supported compression algorithms
|
|
132
|
+
*/
|
|
133
|
+
supportedCompression?: Compression[];
|
|
126
134
|
/**
|
|
127
135
|
* Whether surveys are enabled
|
|
128
136
|
*/
|
|
@@ -133,7 +141,7 @@ type PostHogRemoteConfig = {
|
|
|
133
141
|
hasFeatureFlags?: boolean;
|
|
134
142
|
};
|
|
135
143
|
type FeatureFlagValue = string | boolean;
|
|
136
|
-
type
|
|
144
|
+
type PostHogFlagsResponse = Omit<PostHogRemoteConfig, 'surveys' | 'hasFeatureFlags'> & {
|
|
137
145
|
featureFlags: {
|
|
138
146
|
[key: string]: FeatureFlagValue;
|
|
139
147
|
};
|
|
@@ -179,9 +187,9 @@ type PartialWithRequired<T, K extends keyof T> = {
|
|
|
179
187
|
[P in Exclude<keyof T, K>]?: T[P];
|
|
180
188
|
};
|
|
181
189
|
/**
|
|
182
|
-
* These are the fields we care about from
|
|
190
|
+
* These are the fields we care about from PostHogFlagsResponse for feature flags.
|
|
183
191
|
*/
|
|
184
|
-
type PostHogFeatureFlagDetails = PartialWithRequired<
|
|
192
|
+
type PostHogFeatureFlagDetails = PartialWithRequired<PostHogFlagsResponse, 'flags' | 'featureFlags' | 'featureFlagPayloads' | 'requestId'>;
|
|
185
193
|
type JsonType = string | number | boolean | null | {
|
|
186
194
|
[key: string]: JsonType;
|
|
187
195
|
} | Array<JsonType> | JsonType[];
|
|
@@ -368,8 +376,6 @@ declare enum ActionStepStringMatching {
|
|
|
368
376
|
type ActionStepType = {
|
|
369
377
|
event?: string;
|
|
370
378
|
selector?: string;
|
|
371
|
-
/** @deprecated Only `selector` should be used now. */
|
|
372
|
-
tag_name?: string;
|
|
373
379
|
text?: string;
|
|
374
380
|
/** @default StringMatching.Exact */
|
|
375
381
|
text_matching?: ActionStepStringMatching;
|
|
@@ -410,11 +416,11 @@ declare abstract class PostHogCoreStateless {
|
|
|
410
416
|
private requestTimeout;
|
|
411
417
|
private featureFlagsRequestTimeoutMs;
|
|
412
418
|
private remoteConfigRequestTimeoutMs;
|
|
413
|
-
private captureMode;
|
|
414
419
|
private removeDebugCallback?;
|
|
415
420
|
private disableGeoip;
|
|
416
421
|
private historicalMigration;
|
|
417
422
|
protected disabled: boolean;
|
|
423
|
+
protected disableCompression: boolean;
|
|
418
424
|
private defaultOptIn;
|
|
419
425
|
private pendingPromises;
|
|
420
426
|
protected _events: SimpleEventEmitter;
|
|
@@ -459,7 +465,7 @@ declare abstract class PostHogCoreStateless {
|
|
|
459
465
|
/***
|
|
460
466
|
*** FEATURE FLAGS
|
|
461
467
|
***/
|
|
462
|
-
protected
|
|
468
|
+
protected getFlags(distinctId: string, groups?: Record<string, string | number>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, extraPayload?: Record<string, any>): Promise<PostHogFlagsResponse | undefined>;
|
|
463
469
|
protected getFeatureFlagStateless(key: string, distinctId: string, groups?: Record<string, string>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, disableGeoip?: boolean): Promise<{
|
|
464
470
|
response: FeatureFlagValue | undefined;
|
|
465
471
|
requestId: string | undefined;
|
|
@@ -469,16 +475,16 @@ declare abstract class PostHogCoreStateless {
|
|
|
469
475
|
requestId: string | undefined;
|
|
470
476
|
} | undefined>;
|
|
471
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>;
|
|
472
|
-
protected getFeatureFlagPayloadsStateless(distinctId: string, groups?: Record<string, string>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, disableGeoip?: boolean, flagKeysToEvaluate?: string[]): Promise<
|
|
478
|
+
protected getFeatureFlagPayloadsStateless(distinctId: string, groups?: Record<string, string>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, disableGeoip?: boolean, flagKeysToEvaluate?: string[]): Promise<PostHogFlagsResponse['featureFlagPayloads'] | undefined>;
|
|
473
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<{
|
|
474
|
-
flags:
|
|
475
|
-
payloads:
|
|
476
|
-
requestId:
|
|
480
|
+
flags: PostHogFlagsResponse['featureFlags'] | undefined;
|
|
481
|
+
payloads: PostHogFlagsResponse['featureFlagPayloads'] | undefined;
|
|
482
|
+
requestId: PostHogFlagsResponse['requestId'] | undefined;
|
|
477
483
|
}>;
|
|
478
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<{
|
|
479
|
-
flags:
|
|
480
|
-
payloads:
|
|
481
|
-
requestId:
|
|
485
|
+
flags: PostHogFlagsResponse['featureFlags'] | undefined;
|
|
486
|
+
payloads: PostHogFlagsResponse['featureFlagPayloads'] | undefined;
|
|
487
|
+
requestId: PostHogFlagsResponse['requestId'] | undefined;
|
|
482
488
|
}>;
|
|
483
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>;
|
|
484
490
|
/***
|
|
@@ -544,7 +550,7 @@ declare abstract class PostHogCoreStateless {
|
|
|
544
550
|
declare abstract class PostHogCore extends PostHogCoreStateless {
|
|
545
551
|
private sendFeatureFlagEvent;
|
|
546
552
|
private flagCallReported;
|
|
547
|
-
protected
|
|
553
|
+
protected _flagsResponsePromise?: Promise<PostHogFlagsResponse | undefined>;
|
|
548
554
|
protected _sessionExpirationTimeSeconds: number;
|
|
549
555
|
private _sessionMaxLengthSeconds;
|
|
550
556
|
protected sessionProps: PostHogEventProperties;
|
|
@@ -590,29 +596,21 @@ declare abstract class PostHogCore extends PostHogCoreStateless {
|
|
|
590
596
|
[type: string]: string;
|
|
591
597
|
}): void;
|
|
592
598
|
resetPersonPropertiesForFlags(): void;
|
|
593
|
-
/** @deprecated - Renamed to setPersonPropertiesForFlags */
|
|
594
|
-
personProperties(properties: {
|
|
595
|
-
[type: string]: string;
|
|
596
|
-
}): void;
|
|
597
599
|
setGroupPropertiesForFlags(properties: {
|
|
598
600
|
[type: string]: Record<string, string>;
|
|
599
601
|
}): void;
|
|
600
602
|
resetGroupPropertiesForFlags(): void;
|
|
601
|
-
/** @deprecated - Renamed to setGroupPropertiesForFlags */
|
|
602
|
-
groupProperties(properties: {
|
|
603
|
-
[type: string]: Record<string, string>;
|
|
604
|
-
}): void;
|
|
605
603
|
private remoteConfigAsync;
|
|
606
604
|
/***
|
|
607
605
|
*** FEATURE FLAGS
|
|
608
606
|
***/
|
|
609
|
-
private
|
|
607
|
+
private flagsAsync;
|
|
610
608
|
private cacheSessionReplay;
|
|
611
609
|
private _remoteConfigAsync;
|
|
612
|
-
private
|
|
610
|
+
private _flagsAsync;
|
|
613
611
|
private setKnownFeatureFlagDetails;
|
|
614
612
|
private getKnownFeatureFlagDetails;
|
|
615
|
-
protected getKnownFeatureFlags():
|
|
613
|
+
protected getKnownFeatureFlags(): PostHogFlagsResponse['featureFlags'] | undefined;
|
|
616
614
|
private getKnownFeatureFlagPayloads;
|
|
617
615
|
private getBootstrappedFeatureFlagDetails;
|
|
618
616
|
private setBootstrappedFeatureFlagDetails;
|
|
@@ -620,20 +618,22 @@ declare abstract class PostHogCore extends PostHogCoreStateless {
|
|
|
620
618
|
private getBootstrappedFeatureFlagPayloads;
|
|
621
619
|
getFeatureFlag(key: string): FeatureFlagValue | undefined;
|
|
622
620
|
getFeatureFlagPayload(key: string): JsonType | undefined;
|
|
623
|
-
getFeatureFlagPayloads():
|
|
624
|
-
getFeatureFlags():
|
|
621
|
+
getFeatureFlagPayloads(): PostHogFlagsResponse['featureFlagPayloads'] | undefined;
|
|
622
|
+
getFeatureFlags(): PostHogFlagsResponse['featureFlags'] | undefined;
|
|
625
623
|
getFeatureFlagDetails(): PostHogFeatureFlagDetails | undefined;
|
|
626
624
|
getFeatureFlagsAndPayloads(): {
|
|
627
|
-
flags:
|
|
628
|
-
payloads:
|
|
625
|
+
flags: PostHogFlagsResponse['featureFlags'] | undefined;
|
|
626
|
+
payloads: PostHogFlagsResponse['featureFlagPayloads'] | undefined;
|
|
629
627
|
};
|
|
630
628
|
isFeatureEnabled(key: string): boolean | undefined;
|
|
631
|
-
reloadFeatureFlags(
|
|
629
|
+
reloadFeatureFlags(options?: {
|
|
630
|
+
cb?: (err?: Error, flags?: PostHogFlagsResponse['featureFlags']) => void;
|
|
631
|
+
}): void;
|
|
632
632
|
reloadRemoteConfigAsync(): Promise<PostHogRemoteConfig | undefined>;
|
|
633
|
-
reloadFeatureFlagsAsync(sendAnonDistinctId?: boolean): Promise<
|
|
634
|
-
onFeatureFlags(cb: (flags:
|
|
633
|
+
reloadFeatureFlagsAsync(sendAnonDistinctId?: boolean): Promise<PostHogFlagsResponse['featureFlags'] | undefined>;
|
|
634
|
+
onFeatureFlags(cb: (flags: PostHogFlagsResponse['featureFlags']) => void): () => void;
|
|
635
635
|
onFeatureFlag(key: string, cb: (value: FeatureFlagValue) => void): () => void;
|
|
636
|
-
overrideFeatureFlag(flags:
|
|
636
|
+
overrideFeatureFlag(flags: PostHogFlagsResponse['featureFlags'] | null): Promise<void>;
|
|
637
637
|
/***
|
|
638
638
|
*** ERROR TRACKING
|
|
639
639
|
***/
|