-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: [IOBP-1028] Mixpanel tracking onboarding card methods events o…
…n failure (#6465) ## Short description This pull request primarily focus on adding new analytics tracking functions to mixpanel when the onboarding payment methods is failing. ## List of changes proposed in this pull request - Added new functions to track various onboarding payment method events, including authorization denied, user cancellation, duplicate error, and 3DS error - Updated the component to use a switch statement for handling different onboarding outcomes and tracking the corresponding analytics events ## How to test - Try to onboard a payment method - Try each of these outcomes: `AUTH_ERROR`, `CANCELLED_BY_USER` and `ALREADY_ONBOARDED` - Check that data are sent correctly to mixpanel
- Loading branch information
1 parent
1b268af
commit e64f8a3
Showing
2 changed files
with
82 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,81 @@ | ||
import { mixpanelTrack } from "../../../../mixpanel"; | ||
import { buildEventProperties } from "../../../../utils/analytics"; | ||
import { WalletOnboardingOutcomeEnum } from "../types/OnboardingOutcomeEnum"; | ||
|
||
export type PaymentOnboardingAnalyticsProps = { | ||
payment_method_selected: string; | ||
}; | ||
|
||
export const trackSuccessOnboardingPaymentMethod = ( | ||
const trackSuccessOnboardingPaymentMethod = ( | ||
props: Partial<PaymentOnboardingAnalyticsProps> | ||
) => { | ||
void mixpanelTrack( | ||
"ADD_PAYMENT_METHOD_UX_SUCCESS", | ||
buildEventProperties("UX", "screen_view", props) | ||
); | ||
}; | ||
|
||
const trackOnboardingPaymentMethodDenied = ( | ||
props: Partial<PaymentOnboardingAnalyticsProps> | ||
) => { | ||
void mixpanelTrack( | ||
"PAYMENT_ADD_METHOD_AUTHORIZATION_DENIED", | ||
buildEventProperties("UX", "screen_view", props) | ||
); | ||
}; | ||
|
||
const trackAddOnboardingPaymentMethodCanceled = ( | ||
props: Partial<PaymentOnboardingAnalyticsProps> | ||
) => { | ||
void mixpanelTrack( | ||
"PAYMENT_ADD_METHOD_CANCELED_BY_USER", | ||
buildEventProperties("UX", "screen_view", props) | ||
); | ||
}; | ||
|
||
const trackAddOnboardingPaymentMethodDuplicated = ( | ||
props: Partial<PaymentOnboardingAnalyticsProps> | ||
) => { | ||
void mixpanelTrack( | ||
"PAYMENT_ADD_METHOD_DUPLICATE_ERROR", | ||
buildEventProperties("UX", "screen_view", props) | ||
); | ||
}; | ||
|
||
// This function will be used in the future when we will have 3DS | ||
// const trackOnboardingPaymentMethod3dsError = ( | ||
// props: Partial<PaymentOnboardingAnalyticsProps> | ||
// ) => { | ||
// void mixpanelTrack( | ||
// "PAYMENT_ADD_METHOD_3DS_ERROR", | ||
// buildEventProperties("UX", "screen_view", props) | ||
// ); | ||
// }; | ||
|
||
export const trackAddOnboardingPaymentMethod = ( | ||
outcome: WalletOnboardingOutcomeEnum, | ||
payment_method_selected: string | undefined | ||
) => { | ||
switch (outcome) { | ||
case WalletOnboardingOutcomeEnum.SUCCESS: | ||
trackSuccessOnboardingPaymentMethod({ | ||
payment_method_selected | ||
}); | ||
break; | ||
case WalletOnboardingOutcomeEnum.AUTH_ERROR: | ||
trackOnboardingPaymentMethodDenied({ | ||
payment_method_selected | ||
}); | ||
break; | ||
case WalletOnboardingOutcomeEnum.CANCELED_BY_USER: | ||
trackAddOnboardingPaymentMethodCanceled({ | ||
payment_method_selected | ||
}); | ||
break; | ||
case WalletOnboardingOutcomeEnum.ALREADY_ONBOARDED: | ||
trackAddOnboardingPaymentMethodDuplicated({ | ||
payment_method_selected | ||
}); | ||
break; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters