@funnelsgrove/runtime 0.1.42 → 0.1.43
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.
|
@@ -3,6 +3,7 @@ import { runtimePublicConfig } from '../services/public-env.js';
|
|
|
3
3
|
let initialized = false;
|
|
4
4
|
let readyPromise = null;
|
|
5
5
|
export const POSTHOG_FEATURE_FLAG_READY_TIMEOUT_MS = 2500;
|
|
6
|
+
export const POSTHOG_SCOPED_FLAG_RELOAD_RETRY_MS = 300;
|
|
6
7
|
const STORED_PERSON_PROPERTIES_KEY = '$stored_person_properties';
|
|
7
8
|
const buildFlagScopeProperties = (config) => {
|
|
8
9
|
var _a, _b;
|
|
@@ -84,7 +85,17 @@ export const bootstrapPostHog = (config) => {
|
|
|
84
85
|
bootstrap: { distinctID: config.distinctId },
|
|
85
86
|
loaded: () => {
|
|
86
87
|
let unsubscribe = null;
|
|
87
|
-
|
|
88
|
+
let scopedReloadRetried = false;
|
|
89
|
+
unsubscribe = posthog.onFeatureFlags((flags) => {
|
|
90
|
+
if (Object.keys(scopeProperties).length > 0 &&
|
|
91
|
+
flags.length === 0 &&
|
|
92
|
+
!scopedReloadRetried) {
|
|
93
|
+
scopedReloadRetried = true;
|
|
94
|
+
setTimeout(() => {
|
|
95
|
+
posthog.reloadFeatureFlags();
|
|
96
|
+
}, POSTHOG_SCOPED_FLAG_RELOAD_RETRY_MS);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
88
99
|
unsubscribe === null || unsubscribe === void 0 ? void 0 : unsubscribe();
|
|
89
100
|
markReady();
|
|
90
101
|
});
|
|
@@ -227,7 +227,7 @@ const subscribeRuntimeMode = (listener) => {
|
|
|
227
227
|
};
|
|
228
228
|
};
|
|
229
229
|
export const useRuntimeMode = () => {
|
|
230
|
-
const [mode, setMode] = useState(
|
|
230
|
+
const [mode, setMode] = useState('live');
|
|
231
231
|
useEffect(() => {
|
|
232
232
|
const syncMode = () => {
|
|
233
233
|
setMode(getRuntimeMode());
|