Skip to content
This repository was archived by the owner on Nov 10, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
26 changes: 20 additions & 6 deletions src/routes/index.tsx
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -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()

Expand All @@ -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}`
Copy link
Contributor

Choose a reason for hiding this comment

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

could we use template literals instead?

}
trackPage(safePage)
} else {
const page = `${location.pathname}${location.search}`
trackPage(page)
}
}, [location, matchSafeWithAction, trackPage])

return (
<Switch>
Expand Down Expand Up @@ -65,4 +79,4 @@ const Routes = ({ location }) => {
)
}

export default withRouter(Routes)
export default Routes
1 change: 0 additions & 1 deletion src/routes/open/container/Open.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ const Open = (): React.ReactElement => {
ReactGA.event({
category: 'User',
action: 'Created a safe',
value: safeAddress,
})

removeFromStorage(SAFE_PENDING_CREATION_STORAGE_KEY)
Expand Down
23 changes: 10 additions & 13 deletions src/utils/googleAnalytics.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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()}`,
Expand Down Expand Up @@ -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],
)
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down