@funnelsgrove/runtime 0.1.53 → 0.1.55
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.
|
@@ -189,22 +189,6 @@ export function useFunnelFlowController({ analytics, initialStepId, initialAttri
|
|
|
189
189
|
}
|
|
190
190
|
setActiveStepId(safeStepId);
|
|
191
191
|
}, [getPathForStep, resolveRenderableStepId, safeInitialStepId, shouldLockToInitialStep]);
|
|
192
|
-
useEffect(() => {
|
|
193
|
-
if (!activeExperimentForStep ||
|
|
194
|
-
renderSuspended ||
|
|
195
|
-
shouldLockToInitialStep ||
|
|
196
|
-
renderedStepId === safeActiveStepId) {
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
goToStep(renderedStepId);
|
|
200
|
-
}, [
|
|
201
|
-
activeExperimentForStep,
|
|
202
|
-
goToStep,
|
|
203
|
-
renderSuspended,
|
|
204
|
-
renderedStepId,
|
|
205
|
-
safeActiveStepId,
|
|
206
|
-
shouldLockToInitialStep,
|
|
207
|
-
]);
|
|
208
192
|
const setAnswer = useCallback((key, value) => {
|
|
209
193
|
setAttributes((prev) => (Object.assign(Object.assign({}, prev), { [key]: value })));
|
|
210
194
|
}, []);
|
|
@@ -512,7 +496,7 @@ export function useFunnelFlowController({ analytics, initialStepId, initialAttri
|
|
|
512
496
|
safeActiveStepId,
|
|
513
497
|
safeInitialStepId,
|
|
514
498
|
]);
|
|
515
|
-
const choiceTargets = getChoiceTargetsForStep(
|
|
499
|
+
const choiceTargets = getChoiceTargetsForStep(renderedStepId);
|
|
516
500
|
const actionBar = (_a = renderedStepMeta === null || renderedStepMeta === void 0 ? void 0 : renderedStepMeta.actionBar) !== null && _a !== void 0 ? _a : activeStepMeta === null || activeStepMeta === void 0 ? void 0 : activeStepMeta.actionBar;
|
|
517
501
|
const isAutoAdvanceStep = typeof (actionBar === null || actionBar === void 0 ? void 0 : actionBar.autoAdvanceMs) === 'number';
|
|
518
502
|
const autoAdvanceMs = actionBar === null || actionBar === void 0 ? void 0 : actionBar.autoAdvanceMs;
|
|
@@ -551,12 +535,12 @@ export function useFunnelFlowController({ analytics, initialStepId, initialAttri
|
|
|
551
535
|
}, [goToStep, isFunnelStepId]);
|
|
552
536
|
const goChoice = useCallback((choice, stepId) => {
|
|
553
537
|
var _a, _b;
|
|
554
|
-
const sourceStepId = (_a = resolveRenderableStepId(stepId)) !== null && _a !== void 0 ? _a :
|
|
538
|
+
const sourceStepId = (_a = resolveRenderableStepId(stepId)) !== null && _a !== void 0 ? _a : renderedStepId;
|
|
555
539
|
setAttributes((prev) => writeStepChoice(prev, sourceStepId, choice));
|
|
556
540
|
const sourceChoiceTargets = getChoiceTargetsForStep(sourceStepId);
|
|
557
541
|
const choiceTarget = (_b = resolveRenderableStepId(sourceChoiceTargets === null || sourceChoiceTargets === void 0 ? void 0 : sourceChoiceTargets[choice])) !== null && _b !== void 0 ? _b : resolveNextStepId(sourceStepId);
|
|
558
542
|
goToStep(choiceTarget);
|
|
559
|
-
}, [getChoiceTargetsForStep, goToStep, resolveNextStepId, resolveRenderableStepId
|
|
543
|
+
}, [getChoiceTargetsForStep, goToStep, renderedStepId, resolveNextStepId, resolveRenderableStepId]);
|
|
560
544
|
usePreviewBridge({
|
|
561
545
|
activeStepId: safeActiveStepId,
|
|
562
546
|
onGoToStep: goToStepFromContext,
|
|
@@ -600,7 +584,7 @@ export function useFunnelFlowController({ analytics, initialStepId, initialAttri
|
|
|
600
584
|
return ((_a = experiment.variants[0]) === null || _a === void 0 ? void 0 : _a.variantKey) || '';
|
|
601
585
|
}, [editorVariantOverrides, postHogReady]);
|
|
602
586
|
const contextValue = useMemo(() => ({
|
|
603
|
-
activeStepId:
|
|
587
|
+
activeStepId: renderedStepId,
|
|
604
588
|
featureFlags: postHogFeatureFlags,
|
|
605
589
|
isBuilder: isPreviewRuntime,
|
|
606
590
|
goToStep: goToStepFromContext,
|
|
@@ -608,7 +592,7 @@ export function useFunnelFlowController({ analytics, initialStepId, initialAttri
|
|
|
608
592
|
goChoice,
|
|
609
593
|
getChoiceTargets: (stepId) => {
|
|
610
594
|
var _a;
|
|
611
|
-
const sourceStepId = (_a = resolveRenderableStepId(stepId)) !== null && _a !== void 0 ? _a :
|
|
595
|
+
const sourceStepId = (_a = resolveRenderableStepId(stepId)) !== null && _a !== void 0 ? _a : renderedStepId;
|
|
612
596
|
return getChoiceTargetsForStep(sourceStepId);
|
|
613
597
|
},
|
|
614
598
|
setAnswer,
|
|
@@ -630,8 +614,8 @@ export function useFunnelFlowController({ analytics, initialStepId, initialAttri
|
|
|
630
614
|
goToStepFromContext,
|
|
631
615
|
isPreviewRuntime,
|
|
632
616
|
postHogFeatureFlags,
|
|
617
|
+
renderedStepId,
|
|
633
618
|
resolveRenderableStepId,
|
|
634
|
-
safeActiveStepId,
|
|
635
619
|
setAnswer,
|
|
636
620
|
setAttribute,
|
|
637
621
|
user,
|
|
@@ -98,6 +98,26 @@ export type FunnelSdkCreateSubscriptionCheckoutResponse = {
|
|
|
98
98
|
stripePublishableKey?: string;
|
|
99
99
|
environment?: FunnelSdkRuntimeMode;
|
|
100
100
|
};
|
|
101
|
+
export type FunnelSdkCreateOneTimeCheckoutInput = {
|
|
102
|
+
planId: string;
|
|
103
|
+
amountCents: number;
|
|
104
|
+
returnUrl: string;
|
|
105
|
+
analyticsMetadata?: Record<string, unknown> | null;
|
|
106
|
+
couponId?: string | null;
|
|
107
|
+
customerEmail?: string | null;
|
|
108
|
+
description?: string | null;
|
|
109
|
+
environment?: FunnelSdkRuntimeMode;
|
|
110
|
+
providerPlanId?: string | null;
|
|
111
|
+
runtimeConfig?: FunnelSdkRuntimeConfigOverrides;
|
|
112
|
+
title?: string | null;
|
|
113
|
+
userId?: string | null;
|
|
114
|
+
};
|
|
115
|
+
export type FunnelSdkCreateOneTimeCheckoutResponse = {
|
|
116
|
+
clientSecret: string;
|
|
117
|
+
checkoutSessionId?: string;
|
|
118
|
+
stripePublishableKey?: string;
|
|
119
|
+
environment?: FunnelSdkRuntimeMode;
|
|
120
|
+
};
|
|
101
121
|
export type FunnelSdkUpdateSubscriptionCheckoutPlanInput = {
|
|
102
122
|
checkoutSessionId: string;
|
|
103
123
|
planId: string;
|
|
@@ -131,6 +151,9 @@ export type FunnelSdkVerifySubscriptionCheckoutResponse = {
|
|
|
131
151
|
environment?: FunnelSdkRuntimeMode;
|
|
132
152
|
analyticsMetadata?: Record<string, unknown>;
|
|
133
153
|
};
|
|
154
|
+
/**
|
|
155
|
+
* @deprecated Use FunnelSdkCreateOneTimeCheckoutInput for one-time paywall checkout.
|
|
156
|
+
*/
|
|
134
157
|
export type FunnelSdkCreateOneTimePaymentIntentInput = {
|
|
135
158
|
planId: string;
|
|
136
159
|
amountCents: number;
|
|
@@ -140,6 +163,9 @@ export type FunnelSdkCreateOneTimePaymentIntentInput = {
|
|
|
140
163
|
runtimeConfig?: FunnelSdkRuntimeConfigOverrides;
|
|
141
164
|
userId?: string | null;
|
|
142
165
|
};
|
|
166
|
+
/**
|
|
167
|
+
* @deprecated Use FunnelSdkCreateOneTimeCheckoutResponse for one-time paywall checkout.
|
|
168
|
+
*/
|
|
143
169
|
export type FunnelSdkCreateOneTimePaymentIntentResponse = {
|
|
144
170
|
clientSecret: string;
|
|
145
171
|
stripePublishableKey?: string;
|
|
@@ -196,8 +222,12 @@ declare class FunnelSdkService {
|
|
|
196
222
|
}): Promise<FunnelSdkListPaymentPlansResponse>;
|
|
197
223
|
createHostedCheckoutSession(input: FunnelSdkCreateHostedCheckoutSessionInput): Promise<FunnelSdkCreateHostedCheckoutSessionResponse>;
|
|
198
224
|
createSubscriptionCheckout(input: FunnelSdkCreateSubscriptionCheckoutInput): Promise<FunnelSdkCreateSubscriptionCheckoutResponse>;
|
|
225
|
+
createOneTimeCheckout(input: FunnelSdkCreateOneTimeCheckoutInput): Promise<FunnelSdkCreateOneTimeCheckoutResponse>;
|
|
199
226
|
updateSubscriptionCheckoutPlan(input: FunnelSdkUpdateSubscriptionCheckoutPlanInput): Promise<FunnelSdkUpdateSubscriptionCheckoutPlanResponse>;
|
|
200
227
|
verifySubscriptionCheckout(input: FunnelSdkVerifySubscriptionCheckoutInput): Promise<FunnelSdkVerifySubscriptionCheckoutResponse>;
|
|
228
|
+
/**
|
|
229
|
+
* @deprecated Use createOneTimeCheckout for one-time paywall checkout.
|
|
230
|
+
*/
|
|
201
231
|
createOneTimePaymentIntent(input: FunnelSdkCreateOneTimePaymentIntentInput): Promise<FunnelSdkCreateOneTimePaymentIntentResponse>;
|
|
202
232
|
chargeOneClickPayment(input: FunnelSdkChargeOneClickPaymentInput): Promise<FunnelSdkChargeOneClickPaymentResponse>;
|
|
203
233
|
updateSubscription<ResponsePayload>(input: FunnelSdkUpdateSubscriptionInput): Promise<ResponsePayload>;
|
|
@@ -226,6 +226,25 @@ class FunnelSdkService {
|
|
|
226
226
|
errorMessage: 'Unable to create subscription checkout',
|
|
227
227
|
});
|
|
228
228
|
}
|
|
229
|
+
async createOneTimeCheckout(input) {
|
|
230
|
+
return this.postJson('/sdk/public/payments/one-time-checkout', {
|
|
231
|
+
runtimeConfig: input.runtimeConfig,
|
|
232
|
+
body: {
|
|
233
|
+
planId: input.planId,
|
|
234
|
+
providerPlanId: input.providerPlanId,
|
|
235
|
+
title: input.title,
|
|
236
|
+
description: input.description,
|
|
237
|
+
amountCents: input.amountCents,
|
|
238
|
+
couponId: input.couponId,
|
|
239
|
+
analyticsMetadata: input.analyticsMetadata,
|
|
240
|
+
customerEmail: input.customerEmail,
|
|
241
|
+
returnUrl: input.returnUrl,
|
|
242
|
+
user_id: input.userId,
|
|
243
|
+
environment: input.environment,
|
|
244
|
+
},
|
|
245
|
+
errorMessage: 'Unable to create one-time checkout',
|
|
246
|
+
});
|
|
247
|
+
}
|
|
229
248
|
async updateSubscriptionCheckoutPlan(input) {
|
|
230
249
|
return this.postJson('/sdk/public/payments/subscriptions/update-plan', {
|
|
231
250
|
runtimeConfig: input.runtimeConfig,
|
|
@@ -257,6 +276,9 @@ class FunnelSdkService {
|
|
|
257
276
|
errorMessage: 'Unable to verify subscription checkout',
|
|
258
277
|
});
|
|
259
278
|
}
|
|
279
|
+
/**
|
|
280
|
+
* @deprecated Use createOneTimeCheckout for one-time paywall checkout.
|
|
281
|
+
*/
|
|
260
282
|
async createOneTimePaymentIntent(input) {
|
|
261
283
|
return this.postJson('/sdk/public/payments/intents', {
|
|
262
284
|
runtimeConfig: input.runtimeConfig,
|