diff --git a/.travis.yml b/.travis.yml index e697c99e..c457b9d3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ if: (branch = development) OR (branch = master) OR (type = pull_request) OR (tag IS present) -sudo: required -dist: bionic +dist: focal language: node_js node_js: - '12' @@ -51,7 +50,7 @@ before_script: before_install: # Needed to deploy pull request and releases - sudo apt-get update - - sudo apt-get -y install python-pip python-dev libusb-1.0-0-dev libudev-dev + - sudo apt-get -y install python3-pip python3-dev libusb-1.0-0-dev libudev-dev - pip install awscli --upgrade --user script: - yarn lint:check diff --git a/package.json b/package.json index d943721d..0e99e973 100644 --- a/package.json +++ b/package.json @@ -212,7 +212,7 @@ "react-dom": "16.13.1", "react-final-form": "^6.5.2", "react-final-form-listeners": "^1.0.2", - "react-ga": "3.2.1", + "react-ga": "3.3.0", "react-hot-loader": "4.13.0", "react-qr-reader": "^2.2.1", "react-redux": "7.2.2", diff --git a/src/routes/index.tsx b/src/routes/index.tsx index 6d439d1d..6f038e12 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useState } from 'react' import { useSelector } from 'react-redux' -import { Redirect, Route, Switch, withRouter } from 'react-router-dom' +import { Redirect, Route, Switch, useLocation, useRouteMatch } from 'react-router-dom' import { LOAD_ADDRESS, OPEN_ADDRESS, SAFELIST_ADDRESS, SAFE_PARAM_ADDRESS, WELCOME_ADDRESS } from './routes' @@ -19,8 +19,13 @@ const Load = React.lazy(() => import('./load/container/Load')) const SAFE_ADDRESS = `${SAFELIST_ADDRESS}/:${SAFE_PARAM_ADDRESS}` -const Routes = ({ location }) => { +const Routes = (): React.ReactElement => { const [isInitialLoad, setInitialLoad] = useState(true) + const location = useLocation() + const matchSafeWithAction = useRouteMatch<{ safeAddress: string; safeAction: string }>({ + path: `${SAFELIST_ADDRESS}/:safeAddress/:safeAction`, + }) + const defaultSafe = useSelector(defaultSafeSelector) const { trackPage } = useAnalytics() @@ -31,9 +36,18 @@ const Routes = ({ location }) => { }, [location.pathname, isInitialLoad]) useEffect(() => { - const page = location.pathname + location.search - trackPage(page) - }, [location.pathname, location.search, trackPage]) + if (matchSafeWithAction) { + // prevent logging safeAddress + let safePage = `${SAFELIST_ADDRESS}/SAFE_ADDRESS` + if (matchSafeWithAction.params?.safeAction) { + safePage += `/${matchSafeWithAction.params?.safeAction}` + } + trackPage(safePage) + } else { + const page = `${location.pathname}${location.search}` + trackPage(page) + } + }, [location, matchSafeWithAction, trackPage]) return ( @@ -65,4 +79,4 @@ const Routes = ({ location }) => { ) } -export default withRouter(Routes) +export default Routes diff --git a/src/routes/open/container/Open.tsx b/src/routes/open/container/Open.tsx index 1af17613..62aa7fc2 100644 --- a/src/routes/open/container/Open.tsx +++ b/src/routes/open/container/Open.tsx @@ -150,7 +150,6 @@ const Open = (): React.ReactElement => { ReactGA.event({ category: 'User', action: 'Created a safe', - value: safeAddress, }) removeFromStorage(SAFE_PENDING_CREATION_STORAGE_KEY) diff --git a/src/utils/googleAnalytics.ts b/src/utils/googleAnalytics.ts index 6db5ebfa..c8db0ea5 100644 --- a/src/utils/googleAnalytics.ts +++ b/src/utils/googleAnalytics.ts @@ -1,5 +1,5 @@ import { useCallback, useEffect, useState } from 'react' -import GoogleAnalytics, { EventArgs } from 'react-ga' +import ReactGA, { EventArgs } from 'react-ga' import { getNetworkInfo } from 'src/config' import { getGoogleAnalyticsTrackingID } from 'src/config' @@ -20,8 +20,8 @@ export const loadGoogleAnalytics = (): void => { if (!trackingID) { console.error('[GoogleAnalytics] - In order to use google analytics you need to add an trackingID') } else { - GoogleAnalytics.initialize(trackingID) - GoogleAnalytics.set({ + ReactGA.initialize(trackingID) + ReactGA.set({ anonymizeIp: true, appName: `Gnosis Safe Multisig (${networkInfo.label})`, appId: `io.gnosis.safe.${networkInfo.label.toLowerCase()}`, @@ -50,22 +50,19 @@ export const useAnalytics = (): UseAnalyticsResponse => { fetchCookiesFromStorage() }, []) - const trackPage = useCallback( - (page) => { - if (!analyticsAllowed || !analyticsLoaded) { - return - } - GoogleAnalytics.pageview(page) - }, - [analyticsAllowed], - ) + const trackPage = (page) => { + if (!analyticsAllowed || !analyticsLoaded) { + return + } + ReactGA.pageview(page) + } const trackEvent = useCallback( (event: EventArgs) => { if (!analyticsAllowed || !analyticsLoaded) { return } - GoogleAnalytics.event(event) + ReactGA.event(event) }, [analyticsAllowed], ) diff --git a/yarn.lock b/yarn.lock index 9aa36d72..2a41f69d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -16649,10 +16649,10 @@ react-focus-lock@^2.1.0: use-callback-ref "^1.2.1" use-sidecar "^1.0.1" -react-ga@3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/react-ga/-/react-ga-3.2.1.tgz#ad2a6f848cc9555d63c188d37d6e11798393e4ed" - integrity sha512-uRwNVd7seL2I2lZBE7et8Ul0r/xNDIQkZ43QmnMrcZwY8dNB5UgPjPJA6E18xFtArLgDK/dy/O0TzYqWCsMHDg== +react-ga@3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/react-ga/-/react-ga-3.3.0.tgz#c91f407198adcb3b49e2bc5c12b3fe460039b3ca" + integrity sha512-o8RScHj6Lb8cwy3GMrVH6NJvL+y0zpJvKtc0+wmH7Bt23rszJmnqEQxRbyrqUzk9DTJIHoP42bfO5rswC9SWBQ== react-helmet-async@^1.0.2: version "1.0.7"