Skip to content

Commit

Permalink
feat(bitpay): add more analytic events
Browse files Browse the repository at this point in the history
  • Loading branch information
schnogz authored and jjBlockchain committed Sep 5, 2019
1 parent 1e206e4 commit 2bb541a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ export const TRANSACTION_EVENTS = {
PAYMENT_REQUEST: ['transactions', 'payment_request'],
SEND_FAILURE: ['send_failure'],
VIEW_TX_ON_EXPLORER: ['transactions', 'view_tx_explorer'],
BITPAY_INITIALIZED: ['transactions', 'bitpay', 'initialized'],
BITPAY_SENT: ['transactions', 'bitpay', 'sent']
BITPAY_URL_DEEPLINK: ['transactions', 'bitpay', 'bitpay_url_deeplink'],
BITPAY_FAILURE: ['transactions', 'bitpay', 'bitpay_payment_failure'],
BITPAY_SUCCESS: ['transactions', 'bitpay', 'bitpay_payment_success']
}
export const WALLET_EVENTS = {
ADD_NEW: ['wallets', 'add_new'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ export default ({ api, coreSagas, networks }) => {
const bitpayInvoiceExpired = function * () {
yield put(actions.modals.closeAllModals())
yield put(actions.modals.showModal('BitPayExpired'))
yield put(
actions.analytics.logEvent([
...TRANSACTION_EVENTS.BITPAY_FAILURE,
'invoice expired'
])
)
}

const firstStepSubmitClicked = function * () {
Expand Down Expand Up @@ -463,7 +469,17 @@ export default ({ api, coreSagas, networks }) => {
])
)
if (payPro) {
yield put(actions.analytics.logEvent(TRANSACTION_EVENTS.BITPAY_SENT))
const coinAmount = Exchange.convertCoinToCoin({
value: payment.value().amount,
coin: 'BTC',
baseToStandard: true
}).value
yield put(
actions.analytics.logEvent([
...TRANSACTION_EVENTS.BITPAY_SUCCESS,
`${coinAmount} BTC`
])
)
}
yield put(actions.modals.closeAllModals())
yield put(destroy(FORM))
Expand Down Expand Up @@ -492,6 +508,14 @@ export default ({ api, coreSagas, networks }) => {
coinName: 'Bitcoin'
})
)
if (payPro) {
yield put(
actions.analytics.logEvent([
...TRANSACTION_EVENTS.BITPAY_FAILURE,
e
])
)
}
}
}
}
Expand Down
14 changes: 13 additions & 1 deletion packages/blockchain-wallet-v4-frontend/src/data/goals/sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,13 @@ export default ({ api }) => {
const runPaymentProtocolGoal = function * (goal) {
const { id, data } = goal
yield put(actions.goals.deleteGoal(id))
yield put(actions.analytics.logEvent(TRANSACTION_EVENTS.BITPAY_INITIALIZED))
// TODO: pass coin type once more deeplink types are supported
yield put(
actions.analytics.logEvent([
...TRANSACTION_EVENTS.BITPAY_URL_DEEPLINK,
'BTC'
])
)

yield call(getBtcBalance)
const { r } = data
Expand Down Expand Up @@ -215,6 +221,12 @@ export default ({ api }) => {
)
} catch (e) {
yield put(actions.alerts.displayInfo(C.BITPAY_INVOICE_NOT_FOUND_ERROR))
yield put(
actions.analytics.logEvent([
...TRANSACTION_EVENTS.BITPAY_FAILURE,
'invoice not found'
])
)
yield put(
actions.logs.logErrorMessage(logLocation, 'runPaymentProtocolGoal', e)
)
Expand Down

0 comments on commit 2bb541a

Please sign in to comment.