Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

Commit

Permalink
fix: set custom dimension on chainId change (#2440)
Browse files Browse the repository at this point in the history
* set custom dimension on chainId change

* make it more clear that 1 is mainnet

* 0 fallback chainId
  • Loading branch information
JFrankfurt authored Sep 27, 2021
1 parent 6085284 commit 81b8afd
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/components/analytics/GoogleAnalyticsReporter.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { SupportedChainId } from 'constants/chains'
import { useActiveWeb3React } from 'hooks/web3'
import { useEffect } from 'react'
import ReactGA from 'react-ga'
import { RouteComponentProps } from 'react-router-dom'
Expand All @@ -21,6 +23,11 @@ export default function GoogleAnalyticsReporter({ location: { pathname, search }
getCLS(reportWebVitals)
}, [])

const { chainId } = useActiveWeb3React()
useEffect(() => {
ReactGA.set({ ['Chain ID']: chainId ?? 0 })
}, [chainId])

useEffect(() => {
ReactGA.pageview(`${pathname}${search}`)
}, [pathname, search])
Expand Down

0 comments on commit 81b8afd

Please sign in to comment.