@funnelsgrove/runtime 0.7.23 → 0.7.25
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.
|
@@ -5,6 +5,7 @@ export declare const writeWindowStorageValue: (storageKey: string, value: string
|
|
|
5
5
|
export declare const removeWindowStorageValue: (storageKey: string) => void;
|
|
6
6
|
export declare const dispatchWindowCustomEvent: <Detail>(eventType: string, detail: Detail) => void;
|
|
7
7
|
export declare const dispatchFunnelLocationChange: () => void;
|
|
8
|
+
export declare const updateFunnelHistory: (method: "push" | "replace", state: Record<string, unknown>, location: string) => void;
|
|
8
9
|
export declare const buildHostedStepLocation: (input: {
|
|
9
10
|
currentHref: string;
|
|
10
11
|
stepPath: string;
|
|
@@ -51,6 +51,15 @@ export const dispatchFunnelLocationChange = () => {
|
|
|
51
51
|
href: window.location.href,
|
|
52
52
|
});
|
|
53
53
|
};
|
|
54
|
+
export const updateFunnelHistory = (method, state, location) => {
|
|
55
|
+
const historyPrototype = Object.getPrototypeOf(window.history);
|
|
56
|
+
const update = method === 'replace'
|
|
57
|
+
? historyPrototype.replaceState
|
|
58
|
+
: historyPrototype.pushState;
|
|
59
|
+
const currentState = window.history.state;
|
|
60
|
+
update.call(window.history, Object.assign(Object.assign({}, (currentState && typeof currentState === 'object' ? currentState : {})), state), '', location);
|
|
61
|
+
dispatchFunnelLocationChange();
|
|
62
|
+
};
|
|
54
63
|
const getHostedFunnelBaseSegments = (pathname) => {
|
|
55
64
|
const pathSegments = pathname.split('/').filter(Boolean);
|
|
56
65
|
if (pathSegments[0] === 'published' && pathSegments[1] === 'f' && pathSegments[2]) {
|
|
@@ -120,6 +120,7 @@ export const bootstrapPostHog = (config) => {
|
|
|
120
120
|
}
|
|
121
121
|
if (sessionReplayEnabled) {
|
|
122
122
|
posthog.startSessionRecording();
|
|
123
|
+
posthog.capture('funnelsgrove_session_replay_scope', scopeProperties);
|
|
123
124
|
}
|
|
124
125
|
let unsubscribe = null;
|
|
125
126
|
let scopedReloadRetried = false;
|
|
@@ -5,7 +5,7 @@ import { writeStepChoice } from '../sdk/userAnswers.js';
|
|
|
5
5
|
import { apiService } from '../services/api.service.js';
|
|
6
6
|
import { logger } from '../services/logger.js';
|
|
7
7
|
import { FUNNEL_ID, POSTHOG_API_HOST, POSTHOG_PROJECT_API_KEY, PROJECT_ID, } from '../services/runtime-api.config.js';
|
|
8
|
-
import { buildHostedStepLocation,
|
|
8
|
+
import { buildHostedStepLocation, dispatchWindowCustomEvent, updateFunnelHistory, } from './browser-helpers.js';
|
|
9
9
|
import { isPreviewStepLockRequested, resolveNextStepFromContext, shouldRunAutoAdvanceTimer, } from './funnel-flow.js';
|
|
10
10
|
import { usePreviewBridge } from './preview-bridge.js';
|
|
11
11
|
import { resolveExperimentAssignment, resolveForcedExperimentAssignment, } from './experiment-assignment.js';
|
|
@@ -433,13 +433,7 @@ export function useFunnelFlowController({ api = apiService, analytics, stepContr
|
|
|
433
433
|
});
|
|
434
434
|
const currentLocation = `${window.location.pathname}${window.location.search}${window.location.hash}`;
|
|
435
435
|
if (currentLocation !== nextLocation) {
|
|
436
|
-
|
|
437
|
-
window.history.replaceState({ stepId: safeStepId }, '', nextLocation);
|
|
438
|
-
}
|
|
439
|
-
else {
|
|
440
|
-
window.history.pushState({ stepId: safeStepId }, '', nextLocation);
|
|
441
|
-
}
|
|
442
|
-
dispatchFunnelLocationChange();
|
|
436
|
+
updateFunnelHistory(isPreviewFrameRuntime() ? 'replace' : 'push', { stepId: safeStepId }, nextLocation);
|
|
443
437
|
}
|
|
444
438
|
setActiveStepId(safeStepId);
|
|
445
439
|
}, [getPathForStep]);
|