Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Wallet] Add balance and contact tracking #4209

Merged
merged 4 commits into from
Jun 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/mobile/src/analytics/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ export enum CustomEventNames {
import_contacts = 'import_contacts',
import_contact_error = 'import_contact_error',
import_contacts_skip = 'import_contacts_skip',
fetched_contacts = 'fetched_contacts',
add_contact_match = 'add_contact_match',

// Escrowed payments
escrowed_payment_review = 'escrowed_payment_review',
Expand Down Expand Up @@ -293,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',

Expand Down Expand Up @@ -323,6 +326,8 @@ export type EventPropertyType = {
export enum PropertyPathWhitelist {
address = 'address',
component = 'component',
contacts = 'contacts',
contactsMatched = 'contactsMatched',
context = 'context',
countryCode = 'countryCode',
cta = 'cta',
Expand All @@ -335,6 +340,7 @@ export enum PropertyPathWhitelist {
error = 'error',
exchangeInputAmount = 'exchangeInputAmount',
exchangeRate = 'exchangeRate',
fee = 'fee',
feeType = 'feeType',
fullName = 'fullName',
gethOutcome = 'gethOutcome',
Expand Down
1 change: 1 addition & 0 deletions packages/mobile/src/identity/contactMapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ function* doImportContacts(doMatchmaking: boolean) {
yield put(updateImportContactsProgress(ImportContactsStatus.Importing))

const contacts: MinimalContact[] = yield call(getAllContacts)
CeloAnalytics.track(CustomEventNames.fetched_contacts, { contacts: contacts.length })
if (!contacts || !contacts.length) {
Logger.warn(TAG, 'Empty contacts list. Skipping import.')
return true
Expand Down
8 changes: 7 additions & 1 deletion packages/mobile/src/identity/reducer.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions packages/mobile/src/send/SendConfirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ export class SendConfirmation extends React.Component<Props, State> {
// 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,
Expand Down
9 changes: 8 additions & 1 deletion packages/mobile/src/tokens/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

balance is a big number, i think we want a string or number representation?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also it might be nice to just have a balance field and then a separate currency field. Makes empty columns less prevalent

}
: { goldBalance: balance }
)
yield put(actionCreator(balance.toString()))
} catch (error) {
Logger.error(tag, 'Error fetching balance', error)
Expand Down