fix: set custom dimension on chainId change (#2440)

* set custom dimension on chainId change

* make it more clear that 1 is mainnet

* 0 fallback chainId
This commit is contained in:
Jordan Frankfurt 2021-09-27 12:02:56 -04:00 committed by GitHub
parent 6085284ed6
commit 81b8afdd3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,3 +1,5 @@
import { SupportedChainId } from 'constants/chains'
import { useActiveWeb3React } from 'hooks/web3'
import { useEffect } from 'react' import { useEffect } from 'react'
import ReactGA from 'react-ga' import ReactGA from 'react-ga'
import { RouteComponentProps } from 'react-router-dom' import { RouteComponentProps } from 'react-router-dom'
@ -21,6 +23,11 @@ export default function GoogleAnalyticsReporter({ location: { pathname, search }
getCLS(reportWebVitals) getCLS(reportWebVitals)
}, []) }, [])
const { chainId } = useActiveWeb3React()
useEffect(() => {
ReactGA.set({ ['Chain ID']: chainId ?? 0 })
}, [chainId])
useEffect(() => { useEffect(() => {
ReactGA.pageview(`${pathname}${search}`) ReactGA.pageview(`${pathname}${search}`)
}, [pathname, search]) }, [pathname, search])