Skip to content

Commit

Permalink
Analytics: track successfull QR scans (#3018)
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh authored Dec 15, 2023
1 parent 9967dae commit 85a7dea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/components/common/ScanQRModal/ScanQRButton.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React, { lazy, useState, Suspense, type ReactElement } from 'react'
import QrCodeIcon from '@/public/images/common/qr.svg'
import { IconButton, SvgIcon } from '@mui/material'
import Track from '../Track'
import { MODALS_EVENTS } from '@/services/analytics'
import { MODALS_EVENTS, trackEvent } from '@/services/analytics'

const ScanQRModal = lazy(() => import('.'))

Expand All @@ -15,6 +14,7 @@ const ScanQRButton = ({ onScan }: Props): ReactElement => {

const openQrModal = () => {
setOpen(true)
trackEvent(MODALS_EVENTS.SCAN_QR)
}

const closeQrModal = () => {
Expand All @@ -24,15 +24,14 @@ const ScanQRButton = ({ onScan }: Props): ReactElement => {
const onScanFinished = (value: string) => {
onScan(value)
closeQrModal()
trackEvent(MODALS_EVENTS.SCAN_QR_FINISHED)
}

return (
<>
<Track {...MODALS_EVENTS.SCAN_QR}>
<IconButton data-testid="address-qr-scan" onClick={openQrModal}>
<SvgIcon component={QrCodeIcon} inheritViewBox color="primary" fontSize="small" />
</IconButton>
</Track>
<IconButton data-testid="address-qr-scan" onClick={openQrModal}>
<SvgIcon component={QrCodeIcon} inheritViewBox color="primary" fontSize="small" />
</IconButton>

{open && (
<Suspense>
Expand Down
4 changes: 4 additions & 0 deletions src/services/analytics/events/modals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export const MODALS_EVENTS = {
action: 'Scan QR',
category: MODALS_CATEGORY,
},
SCAN_QR_FINISHED: {
action: 'Scan QR finished',
category: MODALS_CATEGORY,
},
TX_DETAILS: {
action: 'Transaction details',
category: MODALS_CATEGORY,
Expand Down

0 comments on commit 85a7dea

Please sign in to comment.