Skip to content

Commit

Permalink
Fix: WalletConnect - track only tx and signature requests (#2732)
Browse files Browse the repository at this point in the history
* Fix: WalletConnect - track only tx and signature requests

* Rm href=# from address book upload
  • Loading branch information
katspaugh authored Nov 2, 2023
1 parent bdd207e commit 054b53b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
5 changes: 1 addition & 4 deletions src/components/common/FileUpload/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,7 @@ const FileUpload = ({
sx={{ fill: 'none', color: ({ palette }) => palette.primary.light }}
/>
<Typography>
Drag and drop a {fileType} file or{' '}
<Link href="#" color="secondary">
choose a file
</Link>
Drag and drop a {fileType} file or <Link color="secondary">choose a file</Link>
</Typography>
</Box>
</Box>
Expand Down
8 changes: 5 additions & 3 deletions src/components/walletconnect/WcSessionMananger/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,12 @@ const WcSessionManager = ({ sessions, uri }: WcSessionManagerProps) => {

// Track errors
useEffect(() => {
if (error && open) {
trackEvent({ ...WALLETCONNECT_EVENTS.SHOW_ERROR, label: splitError(error.message || '')[0] })
if (error) {
// The summary of the error
const label = splitError(error.message || '')[0]
trackEvent({ ...WALLETCONNECT_EVENTS.SHOW_ERROR, label })
}
}, [error, open])
}, [error])

//
// UI states
Expand Down
7 changes: 3 additions & 4 deletions src/services/walletconnect/WalletConnectContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import WalletConnectWallet from './WalletConnectWallet'
import { asError } from '../exceptions/utils'
import { getPeerName, stripEip155Prefix } from './utils'
import { IS_PRODUCTION } from '@/config/constants'
import { trackEvent } from '../analytics'
import { WALLETCONNECT_EVENTS } from '../analytics/events/walletconnect'
import { SafeAppsTag } from '@/config/constants'
import { useRemoteSafeApps } from '@/hooks/safe-apps/useRemoteSafeApps'
import { trackRequest } from './tracking'

enum Errors {
WRONG_CHAIN = '%%dappName%% made a request on a different chain than the one you are connected to',
Expand Down Expand Up @@ -82,9 +81,9 @@ export const WalletConnectProvider = ({ children }: { children: ReactNode }) =>
const session = walletConnect.getActiveSessions().find((s) => s.topic === topic)
const requestChainId = stripEip155Prefix(event.params.chainId)

// Track all requests
// Track requests
if (session) {
trackEvent({ ...WALLETCONNECT_EVENTS.REQUEST, label: session.peer.metadata.url })
trackRequest(session.peer.metadata.url, event.params.request.method)
}

const getResponse = () => {
Expand Down
16 changes: 16 additions & 0 deletions src/services/walletconnect/tracking.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { trackEvent } from '../analytics'
import { WALLETCONNECT_EVENTS } from '../analytics/events/walletconnect'

const trackedRequests = [
'personal_sign',
'eth_sign',
'eth_signTypedData',
'eth_signTypedData_v4',
'eth_sendTransaction',
]

export const trackRequest = (peerUrl: string, method: string) => {
if (trackedRequests.includes(method)) {
trackEvent({ ...WALLETCONNECT_EVENTS.REQUEST, label: peerUrl })
}
}

1 comment on commit 054b53b

@github-actions
Copy link

Choose a reason for hiding this comment

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

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 75.17% 9461/12586
🔴 Branches 49.45% 1934/3911
🔴 Functions 58% 1425/2457
🟡 Lines 76.84% 8565/11147

Test suite run success

1046 tests passing in 143 suites.

Report generated by 🧪jest coverage report action from 054b53b

Please sign in to comment.