Skip to content

Commit

Permalink
fix(analytics): add device origin field
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLeoB committed May 16, 2022
1 parent b3c0818 commit 25c9692
Show file tree
Hide file tree
Showing 16 changed files with 90 additions and 23 deletions.
2 changes: 1 addition & 1 deletion config/mocks/wallet-options-v4.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"addStripePaymentProvider": false,
"coinViewV2": false,
"completeYourProfile": true,
"createExchangeUserOnSignupOrLogin": true,
"createExchangeUserOnSignupOrLogin": false,
"developerMobilePairing": true,
"eddInterestFileUpload": true,
"flexiblePricingModel": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ type EmailVerifiedAction = {
type ExchangeSignedUpAction = {
key: Events.ONBOARDING_EXCHANGE_SIGNED_UP
properties: {
device: string
device_origin: string
}
}

Expand Down Expand Up @@ -241,8 +241,9 @@ type VerificationSubmissionFailedAction = {
type WalletSignedUpAction = {
key: Events.ONBOARDING_WALLET_SIGNED_UP
properties: {
country: String
country_state: String
country: string
country_state: string
device_origin: string
}
}

Expand Down
11 changes: 10 additions & 1 deletion packages/blockchain-wallet-v4-frontend/src/data/auth/sagas.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import base64url from 'base64url'
import { platform } from 'os'
import { find, propEq } from 'ramda'
import { startSubmit, stopSubmit } from 'redux-form'
import { call, fork, put, select, take } from 'redux-saga/effects'
Expand Down Expand Up @@ -103,6 +104,7 @@ export default ({ api, coreSagas, networks }) => {
actions.analytics.trackEvent({
key: Analytics.LOGIN_TWO_STEP_VERIFICATION_ENTERED,
properties: {
device_origin: platform,
site_redirect: product,
unified: false
}
Expand All @@ -113,6 +115,7 @@ export default ({ api, coreSagas, networks }) => {
actions.analytics.trackEvent({
key: Analytics.LOGIN_PASSWORD_ENTERED,
properties: {
device_origin: platform,
site_redirect: product,
unified: false
}
Expand Down Expand Up @@ -178,6 +181,7 @@ export default ({ api, coreSagas, networks }) => {
key: Analytics.LOGIN_SIGNED_IN,
properties: {
authentication_type: 'PASSWORD',
device_origin: platform,
has_cloud_backup: magicLinkData.wallet?.has_cloud_backup,
is_mobile_setup: magicLinkData.wallet?.is_mobile_setup,
mergeable: magicLinkData.mergeable,
Expand All @@ -202,6 +206,7 @@ export default ({ api, coreSagas, networks }) => {
actions.analytics.trackEvent({
key: Analytics.LOGIN_TWO_STEP_VERIFICATION_DENIED,
properties: {
device_origin: platform,
site_redirect: product,
unified: false
}
Expand Down Expand Up @@ -390,7 +395,7 @@ export default ({ api, coreSagas, networks }) => {
const { email, emailToken } = formValues
const accountUpgradeFlow = yield select(S.getAccountUnificationFlowType)
const product = yield select(S.getProduct)
const { sessionIdMobile } = yield select(S.getProductAuthMetadata)
const { platform, sessionIdMobile } = yield select(S.getProductAuthMetadata)
let session
// if user is opening from mobile webview
if (sessionIdMobile) {
Expand All @@ -405,6 +410,7 @@ export default ({ api, coreSagas, networks }) => {
actions.analytics.trackEvent({
key: Analytics.LOGIN_TWO_STEP_VERIFICATION_ENTERED,
properties: {
device_origin: platform,
site_redirect: product,
unified: unifiedAccount
}
Expand All @@ -415,6 +421,7 @@ export default ({ api, coreSagas, networks }) => {
actions.analytics.trackEvent({
key: Analytics.LOGIN_PASSWORD_ENTERED,
properties: {
device_origin: platform,
site_redirect: product,
unified: unifiedAccount
}
Expand Down Expand Up @@ -482,6 +489,7 @@ export default ({ api, coreSagas, networks }) => {
key: Analytics.LOGIN_SIGNED_IN,
properties: {
authentication_type: 'PASSWORD',
device_origin: platform,
has_cloud_backup: magicLinkData.wallet?.has_cloud_backup,
is_mobile_setup: magicLinkData.wallet?.is_mobile_setup,
mergeable: magicLinkData.mergeable,
Expand Down Expand Up @@ -596,6 +604,7 @@ export default ({ api, coreSagas, networks }) => {
actions.analytics.trackEvent({
key: Analytics.LOGIN_TWO_STEP_VERIFICATION_DENIED,
properties: {
device_origin: platform,
site_redirect: product,
unified: unifiedAccount
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ export const determineAuthenticationFlow = function* (
actions.analytics.trackEvent({
key: Analytics.LOGIN_DEVICE_VERIFIED,
properties: {
device_origin: platformType,
exchange: exchangeData,
mergeable: authMagicLink.mergeable,
site_redirect: product,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,14 @@ export default ({ api, socket }) => {
key: Analytics.LOGIN_SIGNED_IN,
properties: {
authentication_type: 'SECURE_CHANNEL',
has_cloud_backup: magicLinkData.wallet?.has_cloud_backup,
is_mobile_setup: magicLinkData.wallet?.is_mobile_setup,
mergeable: magicLinkData.mergeable,
nabu_id: magicLinkData.wallet?.nabu?.user_id,
device_origin: 'WEB',
has_cloud_backup: magicLinkData?.wallet?.has_cloud_backup,
is_mobile_setup: magicLinkData?.wallet?.is_mobile_setup,
mergeable: magicLinkData?.mergeable,
nabu_id: magicLinkData?.wallet?.nabu?.user_id,
site_redirect: product,
unified: magicLinkData.upgradeable,
upgradeable: magicLinkData.upgradeable
unified: magicLinkData?.upgradeable,
upgradeable: magicLinkData?.upgradeable
}
})
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ export default ({ api, coreSagas, networks }) => {
key: Analytics.ONBOARDING_WALLET_SIGNED_UP,
properties: {
country,
country_state: state
country_state: `${country}-${state}`,
device_origin: platform
}
})
)
Expand All @@ -111,7 +112,7 @@ export default ({ api, coreSagas, networks }) => {
actions.analytics.trackEvent({
key: Analytics.ONBOARDING_EXCHANGE_SIGNED_UP,
properties: {
device: platform
device_origin: platform
}
})
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ const analyticsMiddleware = () => (store) => (next) => (action) => {
}
case '/login': {
const state = store.getState()
const { platform } = state.auth.getProductAuthMetadata
const nabuId = state.profile.userData.getOrElse({})?.id ?? null
const email = state.profile.userData.getOrElse({})?.emailVerified
? state.profile.userData.getOrElse({})?.email
Expand All @@ -147,6 +148,7 @@ const analyticsMiddleware = () => (store) => (next) => (action) => {

analytics.push(AnalyticsKey.LOGIN_VIEWED, {
properties: {
device_origin: platform,
originalTimestamp: getOriginalTimestamp()
},
traits: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { BSPaymentTypes } from '@core/types'
import { RecurringBuyOrigins, RecurringBuyPeriods, SetPeriodPayload } from 'data/types'
import {
PlatformTypes,
RecurringBuyOrigins,
RecurringBuyPeriods,
SetPeriodPayload
} from 'data/types'

enum AnalyticsKey {
ADDRESS_VERIFY_MESSAGE_CLICKED = 'Address Verify Message Clicked',
Expand Down Expand Up @@ -341,6 +346,10 @@ type LoginRequestApprovedOrFailedPayload = BasePayload & {
method: 'SECURE_CHANNEL' | 'MAGIC_LINK'
}

type LoginViewed = BasePayload & {
device_origin: string
}

type SignUpCountrySelectPayload = BasePayload & {
country: string
}
Expand Down Expand Up @@ -699,6 +708,7 @@ type AnalyticsProperties =
| LoginMethodSelectedPayload
| LoginRequestPayload
| LoginRequestApprovedOrFailedPayload
| LoginViewed
| ManageTabSelectionClickedPayload
| NotificationPreferencesUpdatedPayload
| PrivateKeysShownPayload
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,16 @@ const LoginWrapper = styled(Wrapper)`
`

const EnterEmail = (props: Props) => {
const { busy, cache, formValues, invalid, magicLinkData, submitting, walletTabClicked } = props
const {
busy,
cache,
formValues,
invalid,
magicLinkData,
productAuthMetadata,
submitting,
walletTabClicked
} = props

return (
<LoginWrapper>
Expand Down Expand Up @@ -75,6 +84,7 @@ const EnterEmail = (props: Props) => {
</ActionButton>
<NeedHelpLink
origin='IDENTIFIER'
platform={productAuthMetadata.platform}
product={ProductAuthOptions.EXCHANGE}
unified={cache.unifiedAccount}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const EnterPasswordExchange = (props: Props) => {
handleBackArrowClickExchange,
invalid,
magicLinkData,
productAuthMetadata,
submitting,
walletTabClicked
} = props
Expand Down Expand Up @@ -101,6 +102,7 @@ const EnterPasswordExchange = (props: Props) => {
</ActionButton>
<NeedHelpLink
origin='PASSWORD'
platform={productAuthMetadata.platform}
product={ProductAuthOptions.EXCHANGE}
unified={cache.unifiedAccount}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const InstitutionalPortal = (props: Props) => {
handleBackArrowClickExchange,
invalid,
magicLinkData,
productAuthMetadata,
routerActions,
submitting
} = props
Expand Down Expand Up @@ -135,7 +136,11 @@ const InstitutionalPortal = (props: Props) => {
</Text>
)}
</ActionButton>
<NeedHelpLink origin='IDENTIFIER' product={ProductAuthOptions.EXCHANGE} />
<NeedHelpLink
origin='IDENTIFIER'
platform={productAuthMetadata.platform}
product={ProductAuthOptions.EXCHANGE}
/>
</LinkRow>
</WrapperWithPadding>
<SignupLink platform={magicLinkData?.platform_type} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const TwoFAExchange = (props: Props) => {
handleBackArrowClickExchange,
invalid,
magicLinkData,
productAuthMetadata,
submitting
} = props
const twoFactorError = exchangeError && exchangeError === ExchangeErrorCodes.WRONG_2FA
Expand Down Expand Up @@ -104,6 +105,7 @@ const TwoFAExchange = (props: Props) => {
</ActionButton>
<NeedHelpLink
origin='2FA'
platform={productAuthMetadata.platform}
product={ProductAuthOptions.EXCHANGE}
unified={cache.unifiedAccount}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,16 @@ const LoginWrapper = styled(Wrapper)`
`

const EnterEmailOrGuid = (props: Props) => {
const { busy, exchangeTabClicked, formValues, invalid, magicLinkData, submitting, walletError } =
props
const {
busy,
exchangeTabClicked,
formValues,
invalid,
magicLinkData,
productAuthMetadata,
submitting,
walletError
} = props
const guidError = walletError && walletError.toLowerCase().includes('unknown wallet id')

return (
Expand Down Expand Up @@ -82,7 +90,11 @@ const EnterEmailOrGuid = (props: Props) => {
</Text>
)}
</ActionButton>
<NeedHelpLink origin='IDENTIFIER' product={ProductAuthOptions.WALLET} />
<NeedHelpLink
origin='IDENTIFIER'
platform={productAuthMetadata.platform}
product={ProductAuthOptions.WALLET}
/>
</LinkRow>
</WrapperWithPadding>
<SignupLink platform={magicLinkData?.platform_type} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ const EnterPasswordWallet = (props: Props) => {
initialRedirect,
invalid,
magicLinkData,
productAuthMetadata,
qrData,
submitting,
walletError
Expand Down Expand Up @@ -179,7 +180,11 @@ const EnterPasswordWallet = (props: Props) => {
</Text>
)}
</ActionButton>
<NeedHelpLink origin='PASSWORD' product={ProductAuthOptions.WALLET} />
<NeedHelpLink
origin='PASSWORD'
platform={productAuthMetadata.platform}
product={ProductAuthOptions.WALLET}
/>
</CenteredColumn>
</WrapperWithPadding>
<SignupLink platform={magicLinkData?.platform_type} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,11 @@ const TwoFAWallet = (props: Props) => {
</Text>
)}
</ActionButton>
<NeedHelpLink origin='2FA' product={ProductAuthOptions.WALLET} />
<NeedHelpLink
origin='2FA'
platform={productAuthMetadata.platform}
product={ProductAuthOptions.WALLET}
/>
</CenteredColumn>
</WrapperWithPadding>
<SignupLink platform={magicLinkData?.platform_type} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ import { bindActionCreators } from 'redux'
import { Link } from 'blockchain-info-components'
import { actions } from 'data'
import { Analytics } from 'data/analytics/types'
import { ProductAuthOptions } from 'data/auth/types'
import { PlatformTypes, ProductAuthOptions } from 'data/types'

const NeedHelpLink = ({ analyticsActions, origin, product, unified }: Props) => (
const NeedHelpLink = ({ analyticsActions, origin, platform, product, unified }: Props) => (
<LinkContainer
to={product === ProductAuthOptions.WALLET || unified ? '/recover' : '/help-exchange'}
onClick={() => {
analyticsActions.trackEvent({
key: Analytics.LOGIN_HELP_CLICKED,
properties: {
device_origin: platform,
origin,
site_redirect: product,
unified
Expand All @@ -37,6 +38,7 @@ const connector = connect(null, mapDispatchToProps)

type OwnProps = {
origin: string
platform?: PlatformTypes
product: ProductAuthOptions
unified?: boolean
}
Expand Down

0 comments on commit 25c9692

Please sign in to comment.