Skip to content

Commit

Permalink
feat(analytics): adding events for deposit_v1
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroapfilho committed Jun 8, 2021
1 parent 72fffce commit 6865b3b
Show file tree
Hide file tree
Showing 4 changed files with 149 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export default ({ api, coreSagas, networks }: { api: APIType; coreSagas: any; ne
default:
throw new Error('retry active account check')
}
throw new Error('retry active account check')
}

const conditionalRetry = function* (id: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
AnalyticsKey,
AnalyticsType,
CoinType,
DepositMethodType,
OrderType
} from 'middleware/analyticsMiddleware/types'
import {
Expand All @@ -16,7 +17,7 @@ import {

import { actionTypes as AT } from 'data'
import { convertBaseToStandard } from 'data/components/exchange/services'
import { ModalNamesType } from 'data/types'
import { BankDWStepType, ModalNamesType } from 'data/types'

const analyticsMiddleware = () => (store) => (next) => (action) => {
try {
Expand Down Expand Up @@ -152,6 +153,33 @@ const analyticsMiddleware = () => (store) => (next) => (action) => {

break
}
case 'BANK_DEPOSIT_MODAL': {
const { origin } = action.payload.props
const { href, pathname, search } = window.location
const { referrer, title } = document

analytics.push(AnalyticsKey.DEPOSIT_CLICKED, {
analyticsType: AnalyticsType.EVENT,
id,
nabuId,
origin,
originalTimestamp: getOriginalTimestamp()
})

analytics.push(AnalyticsKey.DEPOSIT_VIEWED, {
analyticsType: AnalyticsType.EVENT,
id,
nabuId,
originalTimestamp: getOriginalTimestamp(),
path: pathname,
referrer,
search,
title,
url: href
})

break
}
default: {
break
}
Expand Down Expand Up @@ -750,6 +778,55 @@ const analyticsMiddleware = () => (store) => (next) => (action) => {
})
break
}
case AT.components.brokerage.SET_D_W_STEP: {
const state = store.getState()
const nabuId = state.profile.userData.getOrElse({})?.id
const id = state.walletPath.wallet.guid
const stepName = action.payload.dwStep as BankDWStepType

switch (stepName) {
case BankDWStepType.CONFIRM: {
const depositMethod = DepositMethodType.BANK_TRANSFER // we only have it for now
const { amount, currency } = state.form.brokerageTx.values

analytics.push(AnalyticsKey.DEPOSIT_AMOUNT_ENTERED, {
amount,
analyticsType: AnalyticsType.EVENT,
currency,
deposit_method: depositMethod,
id,
nabuId,
originalTimestamp: getOriginalTimestamp()
})

break
}

default: {
break
}
}

break
}
case AT.components.brokerage.SET_BANK_DETAILS: {
const state = store.getState()
const nabuId = state.profile.userData.getOrElse({})?.id
const id = state.walletPath.wallet.guid
const depositMethod = DepositMethodType.BANK_TRANSFER // we only have it for now
const { currency } = state.form.brokerageTx.values

analytics.push(AnalyticsKey.DEPOSIT_METHOD_SELECTED, {
analyticsType: AnalyticsType.EVENT,
currency,
deposit_method: depositMethod,
id,
nabuId,
originalTimestamp: getOriginalTimestamp()
})

break
}

default: {
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ enum AnalyticsKey {
BUY_SELL_VIEWED = 'Buy Sell Viewed',
DASHBOARD_CLICKED = 'Dashboard Clicked',
DASHBOARD_VIEWED = 'Dashboard Viewed',
DEPOSIT_AMOUNT_ENTERED = 'Deposit Amount Entered', // not implemented
DEPOSIT_CLICKED = 'Deposit Clicked',
DEPOSIT_METHOD_SELECTED = 'Deposit Method Selected', // not implemented
DEPOSIT_VIEWED = 'Deposit Viewed',
EMAIL_VERIFICATION_REQUESTED = 'Email Verification Requested',
RECEIVE_CURRENCY_SELECTED = 'Receive Currency Selected',
RECEIVE_DETAILS_COPIED = 'Receive Details Copied',
Expand Down Expand Up @@ -69,6 +73,10 @@ enum FeeRateType {
PRIORITY = 'PRIORITY'
}

enum DepositMethodType {
BANK_TRANSFER = 'BANK_TRANSFER'
}

type BasePayload = {
analyticsType: AnalyticsType
id: string
Expand Down Expand Up @@ -127,7 +135,24 @@ type DashboardClickedPayload = BasePayload & {

type DashboardViewedPayload = BasePayload & PageViewPayload & {}

type EmailVerificationClicked = BasePayload & {
type DepositAmountEnteredPayload = BasePayload & {
amount: number
currency: string
deposit_method: DepositMethodType
}

type DepositClickedPayload = BasePayload & {
origin: 'CURRENCY_PAGE' | 'PORTFOLIO'
}

type DepositMethodSelectedPayload = BasePayload & {
currency: string
deposit_method: DepositMethodType
}

type DepositViewedPayload = BasePayload & PageViewPayload & {}

type EmailVerificationClickedPayload = BasePayload & {
// origin: 'SIGN_UP' | 'VERIFICATION'
}

Expand Down Expand Up @@ -249,7 +274,7 @@ type SwapReceiveSelectedPayload = BasePayload & {
input_type: Omit<AccountType, AccountType.SAVINGS>
}

type SwapRequested = BasePayload & {
type SwapRequestedPayload = BasePayload & {
exchange_rate: number
input_amount: number
input_currency: string
Expand Down Expand Up @@ -286,7 +311,11 @@ type AnalyticsPayload =
| BuySellViewedPayload
| DashboardClickedPayload
| DashboardViewedPayload
| EmailVerificationClicked
| DepositAmountEnteredPayload
| DepositClickedPayload
| DepositMethodSelectedPayload
| DepositViewedPayload
| EmailVerificationClickedPayload
| ReceiveCurrencySelectedPayload
| ReceiveDetailsCopiedPayload
| SellAmountEnteredPayload
Expand All @@ -309,7 +338,7 @@ type AnalyticsPayload =
| SwapAmountMinClickedPayload
| SwapFromSelectedPayload
| SwapReceiveSelectedPayload
| SwapRequested
| SwapRequestedPayload
| UpgradeVerificationClickedPayload

type PageNamesType = '/home'
Expand All @@ -320,4 +349,13 @@ type PageNamesType = '/home'

export type { AnalyticsPayload, PageNamesType }

export { AccountType, AnalyticsKey, AnalyticsType, CoinType, FeeRateType, OrderType, PaymentType }
export {
AccountType,
AnalyticsKey,
AnalyticsType,
CoinType,
DepositMethodType,
FeeRateType,
OrderType,
PaymentType
}

0 comments on commit 6865b3b

Please sign in to comment.