fix(core): checkout event (#7844)

This commit is contained in:
forehalo 2024-08-13 03:35:38 +00:00
parent dc41ffbe2f
commit 69c64b2fc2
No known key found for this signature in database
GPG Key ID: 56709255DC7EC728
3 changed files with 12 additions and 5 deletions

View File

@ -129,7 +129,7 @@ export const useSubscriptionNotifyReader = () => {
upgradeNotify(link);
localStorage.removeItem(localStorageKey);
track.$.$.$.checkout({
track.$.settingsPanel.plans.subscribe({
plan,
recurring,
});

View File

@ -96,6 +96,7 @@ type PaymentEvents =
| 'viewPlans'
| 'bookDemo'
| 'checkout'
| 'subscribe'
| 'changeSubscriptionRecurring'
| 'confirmChangingSubscriptionRecurring'
| 'cancelSubscription'
@ -155,6 +156,7 @@ const PageEvents = {
accountSettings: ['uploadAvatar', 'removeAvatar', 'updateUserName'],
plans: [
'checkout',
'subscribe',
'changeSubscriptionRecurring',
'confirmChangingSubscriptionRecurring',
'cancelSubscription',
@ -346,6 +348,7 @@ export type EventArgs = {
oauth: { provider: string };
viewPlans: PaymentEventArgs;
checkout: PaymentEventArgs;
subscribe: PaymentEventArgs;
cancelSubscription: PaymentEventArgs;
confirmCancelingSubscription: PaymentEventArgs;
resumeSubscription: PaymentEventArgs;

View File

@ -70,10 +70,7 @@ export const Component = () => {
: !!subscriptionService.subscription.pro$.value;
if (!subscribed) {
setMessage('Creating checkout...');
track.subscriptionLanding.$.$.checkout({
plan: receivedPlan,
recurring: receivedRecurring,
});
try {
const account = authService.session.account$.value;
// should never reach
@ -88,6 +85,13 @@ export const Component = () => {
: receivedRecurring === 'yearly'
? SubscriptionRecurring.Yearly
: SubscriptionRecurring.Lifetime;
track.subscriptionLanding.$.$.checkout({
control: 'pricing',
plan: targetPlan,
recurring: targetRecurring,
});
const checkout = await subscriptionService.createCheckoutSession({
idempotencyKey,
plan: targetPlan,