Skip to content

Commit

Permalink
feat(analytics): add oops client error tracking to brokerage quote en…
Browse files Browse the repository at this point in the history
…dpoint
  • Loading branch information
blockdylanb committed Apr 22, 2022
1 parent fbf2b6d commit b6d64a9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import {
Events as DepositWithdrawalClientEvents,
TrackEventAction as DepositWithdrawalClientEventAction
} from './depositWithdrawalClient'
import {
Events as ClientErrorEvents,
TrackEventAction as ClientErrorTrackEventAction
} from './errors'
import {
AnalyticsProperties as InterestClientProperties,
Events as InterestClientEvents,
Expand All @@ -33,6 +37,7 @@ const TRACK_EVENT = 'trackEvent'

type AnalyticsKey =
| AccountRecoveryEvents
| ClientErrorEvents
| OnboardingAndVerificationEvents
| ViewAndClickEvents
| LoginEvents
Expand All @@ -42,7 +47,7 @@ type AnalyticsKey =
| TaxCenterEvents

const Analytics = {
...AccountRecoveryEvents,
...ClientErrorEvents,
...OnboardingAndVerificationEvents,
...ViewAndClickEvents,
...LoginEvents,
Expand All @@ -62,6 +67,7 @@ type AnalyticsProperties =
// event actions
type TrackEventAction =
| AccountRecoveryTrackEventAction
| ClientErrorTrackEventAction
| OnboardingAndVerificationTrackEventAction
| ViewAndClickTrackEventAction
| LoginTrackEventAction
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { act } from '@testing-library/react-hooks'
import BigNumber from 'bignumber.js'
import { getQuote } from 'blockchain-wallet-v4-frontend/src/modals/BuySell/EnterAmount/Checkout/validation'
import moment from 'moment'
Expand Down Expand Up @@ -31,6 +32,7 @@ import { actions, selectors } from 'data'
import { generateProvisionalPaymentAmount } from 'data/coins/utils'
import {
AddBankStepType,
Analytics,
BankPartners,
BankTransferAccountType,
BrokerageModalOriginType,
Expand Down Expand Up @@ -1124,6 +1126,21 @@ export default ({ api, coreSagas, networks }: { api: APIType; coreSagas: any; ne
} catch (e) {
const error = errorHandler(e)
yield put(A.fetchBuyQuoteFailure(error))
yield put(
actions.analytics.trackEvent({
key: Analytics.CLIENT_ERROR,
properties: {
device: 'WEB',
error: 'OOPS_ERROR',
network_endpoint: '/brokerage/quote',
network_error_code: e.code,
network_error_description: error,
platform: 'WALLET',
source: 'NABU',
title: 'Oops! Something went wrong'
}
})
)
yield delay(FALLBACK_DELAY)
yield put(A.startPollBuyQuote(payload))
}
Expand Down

0 comments on commit b6d64a9

Please sign in to comment.