Skip to content

Commit

Permalink
fix(analytics): add properties
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLeoB committed May 9, 2022
1 parent c2f7b03 commit 8f5a445
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 29 deletions.
48 changes: 36 additions & 12 deletions packages/blockchain-wallet-v4-frontend/src/data/auth/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ export default ({ api, coreSagas, networks }) => {
actions.analytics.trackEvent({
key: Analytics.LOGIN_TWO_STEP_VERIFICATION_ENTERED,
properties: {
site_redirect: product
site_redirect: product,
unified: false
}
})
)
Expand All @@ -106,7 +107,8 @@ export default ({ api, coreSagas, networks }) => {
actions.analytics.trackEvent({
key: Analytics.LOGIN_PASSWORD_ENTERED,
properties: {
site_redirect: product
site_redirect: product,
unified: false
}
})
)
Expand Down Expand Up @@ -164,7 +166,13 @@ export default ({ api, coreSagas, networks }) => {
key: Analytics.LOGIN_SIGNED_IN,
properties: {
authentication_type: 'PASSWORD',
site_redirect: product
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: false,
upgradeable: magicLinkData.upgradeable
}
})
)
Expand All @@ -179,7 +187,8 @@ export default ({ api, coreSagas, networks }) => {
actions.analytics.trackEvent({
key: Analytics.LOGIN_TWO_STEP_VERIFICATION_DENIED,
properties: {
site_redirect: product
site_redirect: product,
unified: false
}
})
)
Expand All @@ -189,7 +198,8 @@ export default ({ api, coreSagas, networks }) => {
actions.analytics.trackEvent({
key: Analytics.LOGIN_PASSWORD_DENIED,
properties: {
site_redirect: product
site_redirect: product,
unified: false
}
})
)
Expand Down Expand Up @@ -358,7 +368,7 @@ export default ({ api, coreSagas, networks }) => {
const login = function* (action) {
const { code, guid, password, sharedKey } = action.payload
const formValues = yield select(selectors.form.getFormValues(LOGIN_FORM))
const exchangeEmail = yield select(selectors.cache.getExchangeEmail)
const { exchangeEmail, unifiedAccount } = yield select(selectors.cache.getCache)
const { email, emailToken } = formValues
const accountUpgradeFlow = yield select(S.getAccountUnificationFlowType)
const product = yield select(S.getProduct)
Expand All @@ -377,7 +387,8 @@ export default ({ api, coreSagas, networks }) => {
actions.analytics.trackEvent({
key: Analytics.LOGIN_TWO_STEP_VERIFICATION_ENTERED,
properties: {
site_redirect: product
site_redirect: product,
unified: unifiedAccount
}
})
)
Expand All @@ -386,7 +397,8 @@ export default ({ api, coreSagas, networks }) => {
actions.analytics.trackEvent({
key: Analytics.LOGIN_PASSWORD_ENTERED,
properties: {
site_redirect: product
site_redirect: product,
unified: unifiedAccount
}
})
)
Expand Down Expand Up @@ -421,6 +433,8 @@ export default ({ api, coreSagas, networks }) => {
})
// Check which unification flow we're running
// to determine what we want to do after authing user
const magicLinkData: AuthMagicLink = yield select(S.getMagicLinkData)

switch (true) {
// case accountUpgradeFlow === AccountUnificationFlows.WALLET_MERGE:
// yield put(actions.form.change(LOGIN_FORM, 'step', LoginSteps.UPGRADE_CONFIRM))
Expand All @@ -444,12 +458,19 @@ export default ({ api, coreSagas, networks }) => {
yield call(loginRoutineSaga, {})
break
}

yield put(
actions.analytics.trackEvent({
key: Analytics.LOGIN_SIGNED_IN,
properties: {
authentication_type: 'PASSWORD',
site_redirect: product
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: unifiedAccount,
upgradeable: magicLinkData.upgradeable
}
})
)
Expand Down Expand Up @@ -525,7 +546,8 @@ export default ({ api, coreSagas, networks }) => {
actions.analytics.trackEvent({
key: Analytics.LOGIN_PASSWORD_DENIED,
properties: {
site_redirect: product
site_redirect: product,
unified: unifiedAccount
}
})
)
Expand Down Expand Up @@ -556,7 +578,8 @@ export default ({ api, coreSagas, networks }) => {
actions.analytics.trackEvent({
key: Analytics.LOGIN_TWO_STEP_VERIFICATION_DENIED,
properties: {
site_redirect: product
site_redirect: product,
unified: unifiedAccount
}
})
)
Expand Down Expand Up @@ -788,7 +811,8 @@ export default ({ api, coreSagas, networks }) => {
key: Analytics.LOGIN_IDENTIFIER_ENTERED,
properties: {
identifier_type: isGuid(guidOrEmail) ? 'WALLET_ID' : 'EMAIL',
site_redirect: product
site_redirect: product,
unified
}
})
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,12 @@ export const determineAuthenticationFlow = function* (
actions.analytics.trackEvent({
key: Analytics.LOGIN_DEVICE_VERIFIED,
properties: {
site_redirect: product
exchange: exchangeData,
mergeable: authMagicLink.mergeable,
site_redirect: product,
unified,
upgradeable: authMagicLink.upgradeable,
wallet: walletData
}
})
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,19 @@ export default ({ api, socket }) => {
})
)
const product = yield select(selectors.auth.getProduct)
const magicLinkData = yield select(selectors.auth.getMagicLinkData)
yield put(
actions.analytics.trackEvent({
key: Analytics.LOGIN_SIGNED_IN,
properties: {
authentication_type: 'SECURE_CHANNEL',
site_redirect: product
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
}
})
)
Expand Down
18 changes: 9 additions & 9 deletions packages/blockchain-wallet-v4-frontend/src/data/session/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ export default ({ api }) => {

const logout = function* () {
try {
yield put(
actions.analytics.trackEvent({
key: Analytics.LOGIN_SIGNED_OUT,
properties: {
origin: 'SETTINGS',
site_redirect: 'WALLET'
}
})
)
yield put(actions.modules.profile.clearSession())
yield put(actions.middleware.webSocket.rates.stopSocket())
yield put(actions.middleware.webSocket.coins.stopSocket())
Expand All @@ -34,15 +43,6 @@ export default ({ api }) => {
} else {
yield call(logoutClearReduxStore)
}
yield put(
actions.analytics.trackEvent({
key: Analytics.LOGIN_SIGNED_OUT,
properties: {
origin: 'SETTINGS',
site_redirect: 'WALLET'
}
})
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ const NeedHelpLink = ({ analyticsActions, origin, product, unified }: Props) =>
key: Analytics.LOGIN_HELP_CLICKED,
properties: {
origin,
site_redirect: product
site_redirect: product,
unified
}
})
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const BuyGoal = (props: InjectedFormProps<{}> & SubviewProps) => {

<SignupForm {...props} />
</PaddingWrapper>
<LoginLink analyticsActions={props.analyticsActions} />
<LoginLink analyticsActions={props.analyticsActions} unified={props.unified} />
</BuyCard>
</CardsWrapper>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ const SignupCard = (props: InjectedFormProps<{}> & SubviewProps) => {
</>
)}
</PaddingWrapper>
<LoginLink analyticsActions={props.analyticsActions} />
<LoginLink analyticsActions={props.analyticsActions} unified={props.unified} />
</Card>
</CardWrapper>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,16 @@ align-items: center;
`}
`

export const LoginLink = (props: { analyticsActions }) => (
export const LoginLink = (props: { analyticsActions; unified }) => (
<LoginCard>
<LinkContainer data-e2e='signupLink' to='/login'>
<LoginLinkRow
onClick={() =>
props.analyticsActions.trackEvent({
key: Analytics.LOGIN_CLICKED,
properties: {
origin: 'SIGN_UP_FLOW'
origin: 'SIGN_UP_FLOW',
unified: props.unified
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ const mapStateToProps = (state: RootState): LinkStatePropsType => ({
goals: selectors.goals.getGoals(state) as GoalDataType,
isLoadingR: selectors.signup.getRegistering(state) as RemoteDataType<string, undefined>,
language: selectors.preferences.getLanguage(state),
search: selectors.router.getSearch(state) as string
search: selectors.router.getSearch(state) as string,
unified: selectors.cache.getUnifiedAccountStatus(state) as boolean
})

const mapDispatchToProps = (dispatch: Dispatch) => ({
Expand All @@ -173,6 +174,7 @@ type LinkStatePropsType = {
isLoadingR: RemoteDataType<string, undefined>
language: string
search: string
unified: boolean
}
type StateProps = {
showForm: boolean
Expand Down

0 comments on commit 8f5a445

Please sign in to comment.