From 43759182623e74291e1cb8362b35859c530e2204 Mon Sep 17 00:00:00 2001 From: annakaz Date: Wed, 24 Jun 2020 15:45:12 -0700 Subject: [PATCH 1/3] Add balance and contact tracking --- packages/mobile/src/analytics/constants.ts | 4 ++++ packages/mobile/src/identity/contactMapping.ts | 1 + packages/mobile/src/identity/reducer.ts | 8 +++++++- packages/mobile/src/tokens/saga.ts | 9 ++++++++- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/packages/mobile/src/analytics/constants.ts b/packages/mobile/src/analytics/constants.ts index a5e7914e2c3..3024bbf5381 100644 --- a/packages/mobile/src/analytics/constants.ts +++ b/packages/mobile/src/analytics/constants.ts @@ -261,6 +261,8 @@ export enum CustomEventNames { import_contacts = 'import_contacts', import_contact_error = 'import_contact_error', import_contacts_skip = 'import_contacts_skip', + fetched_raw_contacts = 'fetched_raw_contacts', + add_contact_match = 'add_contact_match', // Escrowed payments escrowed_payment_review = 'escrowed_payment_review', @@ -323,6 +325,8 @@ export type EventPropertyType = { export enum PropertyPathWhitelist { address = 'address', component = 'component', + contacts = 'contacts', + contactsMatched = 'contactsMatched', context = 'context', countryCode = 'countryCode', cta = 'cta', diff --git a/packages/mobile/src/identity/contactMapping.ts b/packages/mobile/src/identity/contactMapping.ts index b9bf2a45578..844295dca2a 100644 --- a/packages/mobile/src/identity/contactMapping.ts +++ b/packages/mobile/src/identity/contactMapping.ts @@ -88,6 +88,7 @@ function* doImportContacts(doMatchmaking: boolean) { yield put(updateImportContactsProgress(ImportContactsStatus.Importing)) const contacts: MinimalContact[] = yield call(getAllContacts) + CeloAnalytics.track(CustomEventNames.fetched_raw_contacts, { contacts: contacts.length }) if (!contacts || !contacts.length) { Logger.warn(TAG, 'Empty contacts list. Skipping import.') return true diff --git a/packages/mobile/src/identity/reducer.ts b/packages/mobile/src/identity/reducer.ts index 2c7592bfef3..7aeb8f907da 100644 --- a/packages/mobile/src/identity/reducer.ts +++ b/packages/mobile/src/identity/reducer.ts @@ -1,5 +1,7 @@ import dotProp from 'dot-prop-immutable' import { RehydrateAction } from 'redux-persist' +import CeloAnalytics from 'src/analytics/CeloAnalytics' +import { CustomEventNames } from 'src/analytics/constants' import { Actions, ActionTypes } from 'src/identity/actions' import { ContactMatches, ImportContactsStatus, VerificationStatus } from 'src/identity/types' import { AttestationCode } from 'src/identity/verification' @@ -176,9 +178,13 @@ export const reducer = ( askedContactsPermission: true, } case Actions.ADD_CONTACT_MATCHES: + const matchedContacts = { ...state.matchedContacts, ...action.matches } + CeloAnalytics.track(CustomEventNames.add_contact_match, { + contactsMatched: Object.keys(matchedContacts).length, + }) return { ...state, - matchedContacts: { ...state.matchedContacts, ...action.matches }, + matchedContacts, } case Actions.VALIDATE_RECIPIENT_ADDRESS: return { diff --git a/packages/mobile/src/tokens/saga.ts b/packages/mobile/src/tokens/saga.ts index 8df17024785..22ca8903746 100644 --- a/packages/mobile/src/tokens/saga.ts +++ b/packages/mobile/src/tokens/saga.ts @@ -73,7 +73,14 @@ export function tokenFetchFactory({ actionName, token, actionCreator, tag }: Tok const tokenContract = yield call(getTokenContract, token) const balanceInWei: BigNumber = yield call([tokenContract, tokenContract.balanceOf], account) const balance: BigNumber = yield call(convertFromContractDecimals, balanceInWei, token) - CeloAnalytics.track(CustomEventNames.fetch_balance) + CeloAnalytics.track( + CustomEventNames.fetch_balance, + token === CURRENCY_ENUM.DOLLAR + ? { + dollarBalance: balance, + } + : { goldBalance: balance } + ) yield put(actionCreator(balance.toString())) } catch (error) { Logger.error(tag, 'Error fetching balance', error) From b488e8be3157b09f15a06fbec7b4079a084e2fdc Mon Sep 17 00:00:00 2001 From: annakaz Date: Wed, 24 Jun 2020 17:48:10 -0700 Subject: [PATCH 2/3] Add fee tracking --- packages/mobile/src/analytics/constants.ts | 4 +++- packages/mobile/src/send/SendConfirmation.tsx | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/mobile/src/analytics/constants.ts b/packages/mobile/src/analytics/constants.ts index 3024bbf5381..2bfac82dc31 100644 --- a/packages/mobile/src/analytics/constants.ts +++ b/packages/mobile/src/analytics/constants.ts @@ -295,7 +295,8 @@ export enum CustomEventNames { transaction_error = 'transaction_error', transaction_exception = 'transaction_exception', - // Fee errors + // Fee + fee_rendered = 'fee_rendered', estimate_fee_failed = 'estimate_fee_failed', fetch_tobin_tax_failed = 'fetch_tobin_tax_failed', @@ -339,6 +340,7 @@ export enum PropertyPathWhitelist { error = 'error', exchangeInputAmount = 'exchangeInputAmount', exchangeRate = 'exchangeRate', + fee = 'fee', feeType = 'feeType', fullName = 'fullName', gethOutcome = 'gethOutcome', diff --git a/packages/mobile/src/send/SendConfirmation.tsx b/packages/mobile/src/send/SendConfirmation.tsx index c3f156a7092..220b88273cc 100644 --- a/packages/mobile/src/send/SendConfirmation.tsx +++ b/packages/mobile/src/send/SendConfirmation.tsx @@ -288,6 +288,7 @@ export class SendConfirmation extends React.Component { // so we adjust it here const securityFee = isInvite && fee ? fee.minus(inviteFee) : fee + CeloAnalytics.track(CustomEventNames.fee_rendered, { feeType: 'Security', fee: securityFee }) const totalAmount = { value: amountWithFee, currencyCode: CURRENCIES[CURRENCY_ENUM.DOLLAR].code, From 2744efa3457c6a346cf8809fc8b984103cf33219 Mon Sep 17 00:00:00 2001 From: annakaz Date: Wed, 24 Jun 2020 17:50:01 -0700 Subject: [PATCH 3/3] Rename fetch contacts --- packages/mobile/src/analytics/constants.ts | 2 +- packages/mobile/src/identity/contactMapping.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/mobile/src/analytics/constants.ts b/packages/mobile/src/analytics/constants.ts index 2bfac82dc31..5d9d87444e9 100644 --- a/packages/mobile/src/analytics/constants.ts +++ b/packages/mobile/src/analytics/constants.ts @@ -261,7 +261,7 @@ export enum CustomEventNames { import_contacts = 'import_contacts', import_contact_error = 'import_contact_error', import_contacts_skip = 'import_contacts_skip', - fetched_raw_contacts = 'fetched_raw_contacts', + fetched_contacts = 'fetched_contacts', add_contact_match = 'add_contact_match', // Escrowed payments diff --git a/packages/mobile/src/identity/contactMapping.ts b/packages/mobile/src/identity/contactMapping.ts index 844295dca2a..391cc0cb398 100644 --- a/packages/mobile/src/identity/contactMapping.ts +++ b/packages/mobile/src/identity/contactMapping.ts @@ -88,7 +88,7 @@ function* doImportContacts(doMatchmaking: boolean) { yield put(updateImportContactsProgress(ImportContactsStatus.Importing)) const contacts: MinimalContact[] = yield call(getAllContacts) - CeloAnalytics.track(CustomEventNames.fetched_raw_contacts, { contacts: contacts.length }) + CeloAnalytics.track(CustomEventNames.fetched_contacts, { contacts: contacts.length }) if (!contacts || !contacts.length) { Logger.warn(TAG, 'Empty contacts list. Skipping import.') return true