posthog-js-lite 3.1.0 → 3.2.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 +7 -0
- package/lib/index.cjs.js +12 -1
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +4 -1
- package/lib/index.esm.js +12 -1
- package/lib/index.esm.js.map +1 -1
- package/lib/posthog-core/src/types.d.ts +4 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Next
|
|
2
2
|
|
|
3
|
+
# 3.2.0 - 2024-12-12
|
|
4
|
+
|
|
5
|
+
## Changed
|
|
6
|
+
|
|
7
|
+
1. Add new debugging property `$feature_flag_bootstrapped_response`, `$feature_flag_bootstrapped_payload` and `$used_bootstrap_value` to `$feature_flag_called` event
|
|
8
|
+
|
|
9
|
+
|
|
3
10
|
# 3.1.0 - 2024-11-21
|
|
4
11
|
|
|
5
12
|
## Changed
|
package/lib/index.cjs.js
CHANGED
|
@@ -9,6 +9,8 @@ var PostHogPersistedProperty;
|
|
|
9
9
|
PostHogPersistedProperty["Props"] = "props";
|
|
10
10
|
PostHogPersistedProperty["FeatureFlags"] = "feature_flags";
|
|
11
11
|
PostHogPersistedProperty["FeatureFlagPayloads"] = "feature_flag_payloads";
|
|
12
|
+
PostHogPersistedProperty["BootstrapFeatureFlags"] = "bootstrap_feature_flags";
|
|
13
|
+
PostHogPersistedProperty["BootstrapFeatureFlagPayloads"] = "bootstrap_feature_flag_payloads";
|
|
12
14
|
PostHogPersistedProperty["OverrideFeatureFlags"] = "override_feature_flags";
|
|
13
15
|
PostHogPersistedProperty["Queue"] = "queue";
|
|
14
16
|
PostHogPersistedProperty["OptedOut"] = "opted_out";
|
|
@@ -19,6 +21,7 @@ var PostHogPersistedProperty;
|
|
|
19
21
|
PostHogPersistedProperty["InstalledAppBuild"] = "installed_app_build";
|
|
20
22
|
PostHogPersistedProperty["InstalledAppVersion"] = "installed_app_version";
|
|
21
23
|
PostHogPersistedProperty["SessionReplay"] = "session_replay";
|
|
24
|
+
PostHogPersistedProperty["DecideEndpointWasHit"] = "decide_endpoint_was_hit";
|
|
22
25
|
})(PostHogPersistedProperty || (PostHogPersistedProperty = {}));
|
|
23
26
|
|
|
24
27
|
function assert(truthyValue, message) {
|
|
@@ -1442,12 +1445,14 @@ class PostHogCore extends PostHogCoreStateless {
|
|
|
1442
1445
|
.filter((flag) => !!bootstrapfeatureFlags[flag])
|
|
1443
1446
|
.reduce((res, key) => ((res[key] = bootstrapfeatureFlags[key] || false), res), {});
|
|
1444
1447
|
if (Object.keys(bootstrapFlags).length) {
|
|
1448
|
+
this.setPersistedProperty(PostHogPersistedProperty.BootstrapFeatureFlags, bootstrapFlags);
|
|
1445
1449
|
const currentFlags = this.getPersistedProperty(PostHogPersistedProperty.FeatureFlags) || {};
|
|
1446
1450
|
const newFeatureFlags = { ...bootstrapFlags, ...currentFlags };
|
|
1447
1451
|
this.setKnownFeatureFlags(newFeatureFlags);
|
|
1448
1452
|
}
|
|
1449
1453
|
const bootstrapFlagPayloads = bootstrap.featureFlagPayloads;
|
|
1450
1454
|
if (bootstrapFlagPayloads && Object.keys(bootstrapFlagPayloads).length) {
|
|
1455
|
+
this.setPersistedProperty(PostHogPersistedProperty.BootstrapFeatureFlagPayloads, bootstrapFlagPayloads);
|
|
1451
1456
|
const currentFlagPayloads = this.getPersistedProperty(PostHogPersistedProperty.FeatureFlagPayloads) || {};
|
|
1452
1457
|
const newFeatureFlagPayloads = { ...bootstrapFlagPayloads, ...currentFlagPayloads };
|
|
1453
1458
|
this.setKnownFeatureFlagPayloads(newFeatureFlagPayloads);
|
|
@@ -1763,6 +1768,8 @@ class PostHogCore extends PostHogCoreStateless {
|
|
|
1763
1768
|
}
|
|
1764
1769
|
this.setKnownFeatureFlags(newFeatureFlags);
|
|
1765
1770
|
this.setKnownFeatureFlagPayloads(Object.fromEntries(Object.entries(newFeatureFlagPayloads || {}).map(([k, v]) => [k, this._parsePayload(v)])));
|
|
1771
|
+
// Mark that we hit the /decide endpoint so we can capture this in the $feature_flag_called event
|
|
1772
|
+
this.setPersistedProperty(PostHogPersistedProperty.DecideEndpointWasHit, true);
|
|
1766
1773
|
const sessionReplay = res?.sessionRecording;
|
|
1767
1774
|
if (sessionReplay) {
|
|
1768
1775
|
this.setPersistedProperty(PostHogPersistedProperty.SessionReplay, sessionReplay);
|
|
@@ -1809,6 +1816,10 @@ class PostHogCore extends PostHogCoreStateless {
|
|
|
1809
1816
|
this.capture('$feature_flag_called', {
|
|
1810
1817
|
$feature_flag: key,
|
|
1811
1818
|
$feature_flag_response: response,
|
|
1819
|
+
$feature_flag_bootstrapped_response: this.getPersistedProperty(PostHogPersistedProperty.BootstrapFeatureFlags)?.[key],
|
|
1820
|
+
$feature_flag_bootstrapped_payload: this.getPersistedProperty(PostHogPersistedProperty.BootstrapFeatureFlagPayloads)?.[key],
|
|
1821
|
+
// If we haven't yet received a response from the /decide endpoint, we must have used the bootstrapped value
|
|
1822
|
+
$used_bootstrap_value: !this.getPersistedProperty(PostHogPersistedProperty.DecideEndpointWasHit),
|
|
1812
1823
|
});
|
|
1813
1824
|
}
|
|
1814
1825
|
// If we have flags we either return the value (true or string) or false
|
|
@@ -1906,7 +1917,7 @@ class PostHogCore extends PostHogCoreStateless {
|
|
|
1906
1917
|
}
|
|
1907
1918
|
}
|
|
1908
1919
|
|
|
1909
|
-
var version = "3.
|
|
1920
|
+
var version = "3.2.0";
|
|
1910
1921
|
|
|
1911
1922
|
function getContext(window) {
|
|
1912
1923
|
let context = {};
|