@funnelsgrove/runtime 0.7.10 → 0.7.11
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.
|
@@ -270,7 +270,7 @@ export function resolveRenderedExperimentStepId(input) {
|
|
|
270
270
|
return variantStepId !== null && variantStepId !== void 0 ? variantStepId : safeActiveStepId;
|
|
271
271
|
}
|
|
272
272
|
export function useFunnelFlowController({ api = apiService, analytics, stepContractVersion, initialStepId, initialAttributes, lockToInitialStep = false, defaultStepId, stepSequence, stepById, stepComponentById, funnelExperiments, getPathForStep, getStepIdFromPath, getSequentialNextStepId, getChoiceTargetsForStep, isFunnelStepId, resolveConfiguredNextStep, resolveRuntimeInitialStepId, }) {
|
|
273
|
-
var _a, _b;
|
|
273
|
+
var _a, _b, _c;
|
|
274
274
|
const [runtimeMode] = useRuntimeMode();
|
|
275
275
|
const [editorModeEnabled, setEditorModeEnabled] = useState(() => isEditorEnabled());
|
|
276
276
|
const [editorPanelExpanded, setEditorPanelExpanded] = useState(false);
|
|
@@ -278,7 +278,6 @@ export function useFunnelFlowController({ api = apiService, analytics, stepContr
|
|
|
278
278
|
const [editorVariantOverrides, setEditorVariantOverrides] = useState({});
|
|
279
279
|
const shouldLockToInitialStep = lockToInitialStep || isPreviewStepLockRequested();
|
|
280
280
|
const isPreviewRuntime = useMemo(() => isPreviewFrameRuntime(), []);
|
|
281
|
-
const lifecycleEventsSuppressed = isPreviewRuntime || editorModeEnabled;
|
|
282
281
|
const resolveRenderableStepId = useCallback((stepId) => {
|
|
283
282
|
if (!stepId || !isFunnelStepId(stepId)) {
|
|
284
283
|
return null;
|
|
@@ -308,10 +307,14 @@ export function useFunnelFlowController({ api = apiService, analytics, stepContr
|
|
|
308
307
|
});
|
|
309
308
|
return resolveFallbackStepId(requestedStepId);
|
|
310
309
|
}, [initialStepId, resolveFallbackStepId, resolveRuntimeInitialStepId]);
|
|
310
|
+
const isSubscriptionManagementRuntime = ((_a = stepById[safeInitialStepId]) === null || _a === void 0 ? void 0 : _a.kind) === 'manage-subscription';
|
|
311
|
+
const lifecycleEventsSuppressed = isPreviewRuntime || editorModeEnabled || isSubscriptionManagementRuntime;
|
|
311
312
|
const [activeStepId, setActiveStepId] = useState(safeInitialStepId);
|
|
312
313
|
const [attributes, setAttributes] = useState(() => (Object.assign({}, (initialAttributes || {}))));
|
|
313
314
|
const [user, setUser] = useState(() => ({
|
|
314
|
-
id:
|
|
315
|
+
id: isSubscriptionManagementRuntime
|
|
316
|
+
? resolveUrlUserAttributes().userId || ''
|
|
317
|
+
: api.getOrCreateClientUserId(),
|
|
315
318
|
name: '',
|
|
316
319
|
email: '',
|
|
317
320
|
attributes: {},
|
|
@@ -503,8 +506,16 @@ export function useFunnelFlowController({ api = apiService, analytics, stepContr
|
|
|
503
506
|
safeInitialStepId,
|
|
504
507
|
]);
|
|
505
508
|
useEffect(() => {
|
|
506
|
-
const localUserId = api.getOrCreateClientUserId();
|
|
507
509
|
const urlUserAttributes = resolveUrlUserAttributes();
|
|
510
|
+
if (isSubscriptionManagementRuntime) {
|
|
511
|
+
initialAttributionRef.current = collectCurrentFunnelAttribution();
|
|
512
|
+
setUser((prev) => (Object.assign(Object.assign({}, prev), { id: urlUserAttributes.userId || '' })));
|
|
513
|
+
setUserBootstrapped(true);
|
|
514
|
+
setAttributionReady(true);
|
|
515
|
+
setPostHogReady(true);
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
const localUserId = api.getOrCreateClientUserId();
|
|
508
519
|
const bootstrapCandidateUserId = api.getBootstrapCandidateUserId(localUserId);
|
|
509
520
|
const initialAttribution = collectCurrentFunnelAttribution();
|
|
510
521
|
initialAttributionRef.current = initialAttribution;
|
|
@@ -578,7 +589,7 @@ export function useFunnelFlowController({ api = apiService, analytics, stepContr
|
|
|
578
589
|
logger.error('Failed to identify PostHog user:', error);
|
|
579
590
|
});
|
|
580
591
|
return cancelAttributionFailOpen;
|
|
581
|
-
}, [api, isPreviewRuntime]);
|
|
592
|
+
}, [api, isPreviewRuntime, isSubscriptionManagementRuntime]);
|
|
582
593
|
const recordStepCompletion = useCallback((intent, options = {}) => {
|
|
583
594
|
var _a;
|
|
584
595
|
const meta = stepById[intent.visit.stepId];
|
|
@@ -1198,10 +1209,10 @@ export function useFunnelFlowController({ api = apiService, analytics, stepContr
|
|
|
1198
1209
|
safeInitialStepId,
|
|
1199
1210
|
]);
|
|
1200
1211
|
const choiceTargets = getChoiceTargetsForStep(renderedStepId);
|
|
1201
|
-
const actionBar = (
|
|
1212
|
+
const actionBar = (_b = renderedStepMeta === null || renderedStepMeta === void 0 ? void 0 : renderedStepMeta.actionBar) !== null && _b !== void 0 ? _b : activeStepMeta === null || activeStepMeta === void 0 ? void 0 : activeStepMeta.actionBar;
|
|
1202
1213
|
const isAutoAdvanceStep = typeof (actionBar === null || actionBar === void 0 ? void 0 : actionBar.autoAdvanceMs) === 'number';
|
|
1203
1214
|
const autoAdvanceMs = actionBar === null || actionBar === void 0 ? void 0 : actionBar.autoAdvanceMs;
|
|
1204
|
-
const buttonVariant = (
|
|
1215
|
+
const buttonVariant = (_c = actionBar === null || actionBar === void 0 ? void 0 : actionBar.buttonVariant) !== null && _c !== void 0 ? _c : null;
|
|
1205
1216
|
const buttonText = (actionBar === null || actionBar === void 0 ? void 0 : actionBar.buttonText) || 'Continue';
|
|
1206
1217
|
const hideActionBar = (actionBar === null || actionBar === void 0 ? void 0 : actionBar.hidden) === true;
|
|
1207
1218
|
useEffect(() => {
|
|
@@ -512,9 +512,6 @@ class ApiService {
|
|
|
512
512
|
if (!payload.user) {
|
|
513
513
|
throw new Error(SUBSCRIPTION_MANAGEMENT_LINK_ERROR);
|
|
514
514
|
}
|
|
515
|
-
if (userId) {
|
|
516
|
-
persistUserId(payload.user.user_id || userId, FUNNEL_ID);
|
|
517
|
-
}
|
|
518
515
|
return payload;
|
|
519
516
|
}
|
|
520
517
|
async updateSubscription(input) {
|