@posthog/browser-common 0.10.4 → 0.10.5
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/dist/config.js +1 -1
- package/dist/config.mjs +1 -1
- package/dist/feature-flags.d.ts +4 -0
- package/dist/feature-flags.js +25 -5
- package/dist/feature-flags.mjs +25 -5
- package/package.json +3 -3
package/dist/config.js
CHANGED
package/dist/config.mjs
CHANGED
package/dist/feature-flags.d.ts
CHANGED
|
@@ -76,6 +76,8 @@ export declare class PostHogFeatureFlags implements Extension {
|
|
|
76
76
|
private _additionalReloadRequested;
|
|
77
77
|
private _reloadDebouncer;
|
|
78
78
|
private _firingFeatureFlagsCallbacks;
|
|
79
|
+
private _flagCallsPendingCapture;
|
|
80
|
+
private _sendingFlagCallsPendingCapture;
|
|
79
81
|
private _flagsLoadedFromRemote;
|
|
80
82
|
private _staleCacheRefreshTriggered;
|
|
81
83
|
private _consecutiveStatusZeroFailures;
|
|
@@ -153,6 +155,8 @@ export declare class PostHogFeatureFlags implements Extension {
|
|
|
153
155
|
setAnonymousDistinctId(anon_distinct_id: string | undefined): void;
|
|
154
156
|
setReloadingPaused(isPaused: boolean): void;
|
|
155
157
|
resetFlagCallReported(): void;
|
|
158
|
+
/** Sends `$feature_flag_called` for the flags read while capture was off, once the client can capture. */
|
|
159
|
+
sendFlagCallsPendingCapture(): void;
|
|
156
160
|
_callFlagsEndpoint(options?: {
|
|
157
161
|
disableFlags?: boolean;
|
|
158
162
|
}): void;
|
package/dist/feature-flags.js
CHANGED
|
@@ -207,6 +207,8 @@ class PostHogFeatureFlags {
|
|
|
207
207
|
this._reloadingDisabled = false;
|
|
208
208
|
this._additionalReloadRequested = false;
|
|
209
209
|
this._firingFeatureFlagsCallbacks = false;
|
|
210
|
+
this._flagCallsPendingCapture = new Map();
|
|
211
|
+
this._sendingFlagCallsPendingCapture = false;
|
|
210
212
|
this._flagsLoadedFromRemote = false;
|
|
211
213
|
this._staleCacheRefreshTriggered = false;
|
|
212
214
|
this._consecutiveStatusZeroFailures = 0;
|
|
@@ -650,6 +652,19 @@ class PostHogFeatureFlags {
|
|
|
650
652
|
}
|
|
651
653
|
resetFlagCallReported() {
|
|
652
654
|
this._remove(external_constants_js_namespaceObject.FLAG_CALL_REPORTED);
|
|
655
|
+
this._flagCallsPendingCapture = new Map();
|
|
656
|
+
}
|
|
657
|
+
sendFlagCallsPendingCapture() {
|
|
658
|
+
if (0 === this._flagCallsPendingCapture.size || this._sendingFlagCallsPendingCapture || !this._client?.canCapture) return;
|
|
659
|
+
this._sendingFlagCallsPendingCapture = true;
|
|
660
|
+
try {
|
|
661
|
+
this._flagCallsPendingCapture.forEach((readBy, key)=>{
|
|
662
|
+
if (readBy === this._client?.distinctId) this.getFeatureFlagResult(key);
|
|
663
|
+
else this._flagCallsPendingCapture.delete(key);
|
|
664
|
+
});
|
|
665
|
+
} finally{
|
|
666
|
+
this._sendingFlagCallsPendingCapture = false;
|
|
667
|
+
}
|
|
653
668
|
}
|
|
654
669
|
_callFlagsEndpoint(options) {
|
|
655
670
|
this._clearDebouncer();
|
|
@@ -813,11 +828,15 @@ class PostHogFeatureFlags {
|
|
|
813
828
|
});
|
|
814
829
|
} else {
|
|
815
830
|
const canCapture = this._client?.canCapture;
|
|
816
|
-
if (
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
831
|
+
if (canCapture) this._flagCallsPendingCapture.delete(key);
|
|
832
|
+
else {
|
|
833
|
+
if (Object.keys(flagCallReported).length > 0) {
|
|
834
|
+
flagCallReported = {};
|
|
835
|
+
this._set({
|
|
836
|
+
[external_constants_js_namespaceObject.FLAG_CALL_REPORTED]: flagCallReported
|
|
837
|
+
});
|
|
838
|
+
}
|
|
839
|
+
this._flagCallsPendingCapture.set(key, this._client?.distinctId);
|
|
821
840
|
}
|
|
822
841
|
if (canCapture && !flagCallReported[key]?.includes(flagReportValue)) {
|
|
823
842
|
if ((0, core_namespaceObject.isArray)(flagCallReported[key])) flagCallReported[key].push(flagReportValue);
|
|
@@ -1215,6 +1234,7 @@ class PostHogFeatureFlags {
|
|
|
1215
1234
|
this._clearDebouncer();
|
|
1216
1235
|
this._override_warning = false;
|
|
1217
1236
|
this._consecutiveStatusZeroFailures = 0;
|
|
1237
|
+
this._flagCallsPendingCapture = new Map();
|
|
1218
1238
|
}
|
|
1219
1239
|
}
|
|
1220
1240
|
exports.FeatureFlagError = __webpack_exports__.FeatureFlagError;
|
package/dist/feature-flags.mjs
CHANGED
|
@@ -171,6 +171,8 @@ class PostHogFeatureFlags {
|
|
|
171
171
|
this._reloadingDisabled = false;
|
|
172
172
|
this._additionalReloadRequested = false;
|
|
173
173
|
this._firingFeatureFlagsCallbacks = false;
|
|
174
|
+
this._flagCallsPendingCapture = new Map();
|
|
175
|
+
this._sendingFlagCallsPendingCapture = false;
|
|
174
176
|
this._flagsLoadedFromRemote = false;
|
|
175
177
|
this._staleCacheRefreshTriggered = false;
|
|
176
178
|
this._consecutiveStatusZeroFailures = 0;
|
|
@@ -614,6 +616,19 @@ class PostHogFeatureFlags {
|
|
|
614
616
|
}
|
|
615
617
|
resetFlagCallReported() {
|
|
616
618
|
this._remove(FLAG_CALL_REPORTED);
|
|
619
|
+
this._flagCallsPendingCapture = new Map();
|
|
620
|
+
}
|
|
621
|
+
sendFlagCallsPendingCapture() {
|
|
622
|
+
if (0 === this._flagCallsPendingCapture.size || this._sendingFlagCallsPendingCapture || !this._client?.canCapture) return;
|
|
623
|
+
this._sendingFlagCallsPendingCapture = true;
|
|
624
|
+
try {
|
|
625
|
+
this._flagCallsPendingCapture.forEach((readBy, key)=>{
|
|
626
|
+
if (readBy === this._client?.distinctId) this.getFeatureFlagResult(key);
|
|
627
|
+
else this._flagCallsPendingCapture.delete(key);
|
|
628
|
+
});
|
|
629
|
+
} finally{
|
|
630
|
+
this._sendingFlagCallsPendingCapture = false;
|
|
631
|
+
}
|
|
617
632
|
}
|
|
618
633
|
_callFlagsEndpoint(options) {
|
|
619
634
|
this._clearDebouncer();
|
|
@@ -777,11 +792,15 @@ class PostHogFeatureFlags {
|
|
|
777
792
|
});
|
|
778
793
|
} else {
|
|
779
794
|
const canCapture = this._client?.canCapture;
|
|
780
|
-
if (
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
795
|
+
if (canCapture) this._flagCallsPendingCapture.delete(key);
|
|
796
|
+
else {
|
|
797
|
+
if (Object.keys(flagCallReported).length > 0) {
|
|
798
|
+
flagCallReported = {};
|
|
799
|
+
this._set({
|
|
800
|
+
[FLAG_CALL_REPORTED]: flagCallReported
|
|
801
|
+
});
|
|
802
|
+
}
|
|
803
|
+
this._flagCallsPendingCapture.set(key, this._client?.distinctId);
|
|
785
804
|
}
|
|
786
805
|
if (canCapture && !flagCallReported[key]?.includes(flagReportValue)) {
|
|
787
806
|
if (isArray(flagCallReported[key])) flagCallReported[key].push(flagReportValue);
|
|
@@ -1179,6 +1198,7 @@ class PostHogFeatureFlags {
|
|
|
1179
1198
|
this._clearDebouncer();
|
|
1180
1199
|
this._override_warning = false;
|
|
1181
1200
|
this._consecutiveStatusZeroFailures = 0;
|
|
1201
|
+
this._flagCallsPendingCapture = new Map();
|
|
1182
1202
|
}
|
|
1183
1203
|
}
|
|
1184
1204
|
export { FeatureFlagError, PostHogFeatureFlags, QuotaLimitedResource, filterActiveFeatureFlags, parseFlagsResponse };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@posthog/browser-common",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.5",
|
|
4
4
|
"description": "Internal shared browser utilities and extension primitives for PostHog Browser SDKs",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -241,8 +241,8 @@
|
|
|
241
241
|
"dependencies": {
|
|
242
242
|
"dompurify": "^3.4.13",
|
|
243
243
|
"preact": "^10.29.3",
|
|
244
|
-
"@posthog/
|
|
245
|
-
"@posthog/
|
|
244
|
+
"@posthog/core": "^1.63.1",
|
|
245
|
+
"@posthog/types": "^1.419.0"
|
|
246
246
|
},
|
|
247
247
|
"devDependencies": {
|
|
248
248
|
"@rsbuild/plugin-react": "^2.1.0",
|