Skip to content

Commit

Permalink
feat(quiz): send event on quiz start (#6279)
Browse files Browse the repository at this point in the history
  • Loading branch information
mperdomo-bc committed Feb 9, 2024
1 parent 44dd129 commit 70bdfd1
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,10 @@ type AnalyticsKey =
| NftsEvents
| OnboardingAndVerificationEvents
| PlaidClientEvents
| SellEvents
| SofiEvents
| ExchangePromoEvents
| RecommendedSweepEvents
| SellEvents
| SendCryptoEvents
| SofiEvents
| SpinnerEvents
| SwapEvents
| TaxCenterEvents
Expand All @@ -98,6 +97,7 @@ type AnalyticsKey =

const Analytics = {
...AccountRecoveryEvents,
...BuyEvents,
...ClientErrorEvents,
...CoinViewEvents,
...CowboysPromoEvents,
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -107,7 +108,7 @@ type EmailVerificationSkippedAction = {
type EmailVerifiedAction = {
key: Events.ONBOARDING_EMAIL_VERIFIED
properties: {
email_changed: Boolean
email_changed: boolean
}
}

Expand Down Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand All @@ -375,6 +382,6 @@ type ProductFlowProperties = BasePayload & {
// analytics properties to be used for analytics queue typing
export type AnalyticsProperties =
| BasePayload
| CurrentStepProperties
| ButtonClickProperties
| CurrentStepProperties
| ProductFlowProperties
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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()
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 70bdfd1

Please sign in to comment.