From 70bdfd158849e1af697da68a45c3b2c56e7e8322 Mon Sep 17 00:00:00 2001 From: mperdomo-bc <97296851+mperdomo-bc@users.noreply.github.com> Date: Fri, 9 Feb 2024 13:13:27 -0300 Subject: [PATCH] feat(quiz): send event on quiz start (#6279) --- .../src/data/analytics/types/index.ts | 15 +++-- .../types/onboardingAndVerification.ts | 55 +++++++++++-------- .../FinProms/SelfAssessment/index.tsx | 16 +++++- 3 files changed, 52 insertions(+), 34 deletions(-) diff --git a/packages/blockchain-wallet-v4-frontend/src/data/analytics/types/index.ts b/packages/blockchain-wallet-v4-frontend/src/data/analytics/types/index.ts index cf783330426..7ceb00aef4b 100644 --- a/packages/blockchain-wallet-v4-frontend/src/data/analytics/types/index.ts +++ b/packages/blockchain-wallet-v4-frontend/src/data/analytics/types/index.ts @@ -85,11 +85,10 @@ type AnalyticsKey = | NftsEvents | OnboardingAndVerificationEvents | PlaidClientEvents - | SellEvents - | SofiEvents - | ExchangePromoEvents | RecommendedSweepEvents + | SellEvents | SendCryptoEvents + | SofiEvents | SpinnerEvents | SwapEvents | TaxCenterEvents @@ -98,6 +97,7 @@ type AnalyticsKey = const Analytics = { ...AccountRecoveryEvents, + ...BuyEvents, ...ClientErrorEvents, ...CoinViewEvents, ...CowboysPromoEvents, @@ -108,17 +108,16 @@ const Analytics = { ...MiscEvents, ...NftsEvents, ...OnboardingAndVerificationEvents, - ...RecommendedSweepEvents, ...PlaidClientEvents, + ...RecommendedSweepEvents, + ...SellEvents, ...SendCryptoEvents, - ...SpinnerEvents, ...SofiEvents, + ...SpinnerEvents, ...SwapEvents, ...TaxCenterEvents, ...ViewAndClickEvents, - ...WalletEarnEvents, - ...BuyEvents, - ...SellEvents + ...WalletEarnEvents } // event properties diff --git a/packages/blockchain-wallet-v4-frontend/src/data/analytics/types/onboardingAndVerification.ts b/packages/blockchain-wallet-v4-frontend/src/data/analytics/types/onboardingAndVerification.ts index dc232c0aae7..63389634fcb 100644 --- a/packages/blockchain-wallet-v4-frontend/src/data/analytics/types/onboardingAndVerification.ts +++ b/packages/blockchain-wallet-v4-frontend/src/data/analytics/types/onboardingAndVerification.ts @@ -18,6 +18,7 @@ export enum Events { ONBOARDING_PRE_VERIFICATION_CTA_CLICKED = 'Pre Verification CTA Clicked', ONBOARDING_PRE_VERIFICATION_DISMISSED = 'Pre Verification Dismissed', ONBOARDING_PRE_VERIFICATION_VIEWED = 'Pre Verification Viewed', + ONBOARDING_QUIZ_STARTED = 'Onboarding Quiz Started', ONBOARDING_SIGNED_UP = 'Signed Up', ONBOARDING_SIGNUP_CLICKED = 'Sign Up Clicked', ONBOARDING_SIGNUP_COUNTRY_SELECTED = 'Sign Up Country Selected', @@ -107,7 +108,7 @@ type EmailVerificationSkippedAction = { type EmailVerifiedAction = { key: Events.ONBOARDING_EMAIL_VERIFIED properties: { - email_changed: Boolean + email_changed: boolean } } @@ -183,21 +184,21 @@ type SignUpClickedAction = { type CountrySelectedAction = { key: Events.ONBOARDING_SIGNUP_COUNTRY_SELECTED properties: { - country: String + country: string } } type CountryStateSelectedAction = { key: Events.ONBOARDING_SIGNUP_COUNTRY_STATE_SELECTED properties: { - country_state: String + country_state: string } } type SignedUpAction = { key: Events.ONBOARDING_SIGNED_UP properties: { - is_from_linking: Boolean + is_from_linking: boolean } } @@ -245,8 +246,8 @@ type VerificationSubmissionFailedAction = { type WalletSignedUpAction = { key: Events.ONBOARDING_WALLET_SIGNED_UP properties: { - country: String - country_state: String + country: string + country_state: string device_origin: string unified?: boolean } @@ -320,41 +321,47 @@ type AccountInfoScreenSubmitted = { properties: {} } +type OnboardingQuizStarted = { + key: Events.ONBOARDING_QUIZ_STARTED + properties: {} +} + // track event actions to be used inside codebase when we do trigger event export type TrackEventAction = - | AddressEnteredAction - | AccountInfoScreenViewed | AccountInfoScreenSubmitted + | AccountInfoScreenViewed + | AddressEnteredAction + | CompleteProfileBannerClickedAction + | CompleteProfileDismissAction + | CompleteProfileModalButtonClickedAction + | CompleteProfileModalViewedAction + | CountrySelectedAction + | CountryStateSelectedAction | EmailVerificationRequestAction | EmailVerificationSkippedAction | EmailVerifiedAction | ExchangeSignedUpAction | GetMoreAccessWhenYouVerify | ManualVerificationRequiredAction - | CompleteProfileDismissAction - | CompleteProfileModalViewedAction - | CompleteProfileModalButtonClickedAction - | CompleteProfileBannerClickedAction + | OnboardingQuizStarted | PersonalInformationEnteredAction - | SignUpClickedAction - | CountrySelectedAction - | CountryStateSelectedAction - | SignedUpAction - | TradingLimitsViewed - | TradingLimitsDismissed - | TradingLimitsVerifiedCtaClicked - | TradingLimitsBasicCtaClicked | PreVerificationCtaClicked | PreVerificationDismissed | PreVerificationViewed + | SignedUpAction + | SignUpClickedAction + | TradingLimitsBasicCtaClicked + | TradingLimitsDismissed + | TradingLimitsVerifiedCtaClicked + | TradingLimitsViewed | UpgradeVerificationClickedAction | VerificationCompletedAction - | VerificationRejectedAction - | VerificationStartedAction - | VerificationSubmissionFailedAction | VerificationNowCtaClicked | VerificationNowDismissed | VerificationNowViewed + | VerificationRejectedAction + | VerificationStartedAction + | VerificationSubmissionFailedAction | WalletSignedUpAction // shared types @@ -375,6 +382,6 @@ type ProductFlowProperties = BasePayload & { // analytics properties to be used for analytics queue typing export type AnalyticsProperties = | BasePayload - | CurrentStepProperties | ButtonClickProperties + | CurrentStepProperties | ProductFlowProperties diff --git a/packages/blockchain-wallet-v4-frontend/src/modals/Onboarding/FinProms/SelfAssessment/index.tsx b/packages/blockchain-wallet-v4-frontend/src/modals/Onboarding/FinProms/SelfAssessment/index.tsx index 71fe2d5fa61..159718b5ab5 100644 --- a/packages/blockchain-wallet-v4-frontend/src/modals/Onboarding/FinProms/SelfAssessment/index.tsx +++ b/packages/blockchain-wallet-v4-frontend/src/modals/Onboarding/FinProms/SelfAssessment/index.tsx @@ -7,9 +7,10 @@ import { getDomainApi } from '@core/redux/walletOptions/selectors' import Flyout, { duration, FlyoutChild } from 'components/Flyout' import { FlyoutOopsError } from 'components/Flyout/Errors' import { modals } from 'data/actions' +import { trackEvent } from 'data/analytics/slice' import { identityVerification } from 'data/components/actions' import { getUserApiToken } from 'data/modules/profile/selectors' -import { ModalName } from 'data/types' +import { Analytics, ModalName } from 'data/types' import ModalEnhancer from 'providers/ModalEnhancer' import { Loading, LoadingTextEnum } from '../../../components' @@ -31,7 +32,7 @@ const SelfAssessmentModal = ({ close, position, total, userClickedOutside }: Mod const api = useSelector(getDomainApi).getOrElse('') const nabuToken = useSelector(getUserApiToken) - const [step, setStep] = useState(-1) + const [step, setStep] = useState(-1) // This is to show the intro page first const [show, setShow] = useState(false) const [loading, setLoading] = useState(false) const [errorMessage, setErrorMessage] = useState() @@ -89,6 +90,17 @@ const SelfAssessmentModal = ({ close, position, total, userClickedOutside }: Mod setShow(true) }, []) + useEffect(() => { + if (step === 0) { + dispatch( + trackEvent({ + key: Analytics.ONBOARDING_QUIZ_STARTED, + properties: {} + }) + ) + } + }, [step]) + useEffect(() => { // When the questionnaire is done, it returns an empty string and a 204 status // Not sure if I can discern if it has already been completed and the user is getting here by