fix(matomo): fixed matomo scope for production

keep-around/7f2e0999b7523804cd20738ec956a5b295bd82b4
Rakov Roman 4 years ago
parent bdb316c794
commit 7f2e0999b7
  1. 25
      src/config/matomo.tsx
  2. 2
      src/config/pages.tsx
  3. 9
      src/features/App/index.tsx
  4. 4
      src/features/GlobalStores/index.tsx

@ -0,0 +1,25 @@
import { createInstance } from '@jonkoops/matomo-tracker-react'
import { InstanceParams } from '@jonkoops/matomo-tracker-react/lib/types'
import { PAGES } from 'config/pages'
const getMatomoInstance = () => {
let matomoInstance: InstanceParams = {
siteId: 999,
urlBase: 'link.to.domain',
}
switch (process.env.REACT_APP_CLIENT) {
case 'instat':
matomoInstance = {
...matomoInstance,
siteId: 1,
urlBase: PAGES.matomoInstatBaseUrl,
}
break
}
return createInstance(matomoInstance)
}
export const matomoInstance = getMatomoInstance()

@ -2,7 +2,7 @@ export const PAGES = {
about_the_project: 'https://instatsport.com/InStatTV/ott_platform',
home: '/',
match: '/matches',
matomoBaseUrl: 'https://matomo.instat.tv/',
matomoInstatBaseUrl: 'https://matomo.instat.tv/',
player: '/players',
team: '/teams',
tournament: '/tournaments',

@ -1,11 +1,11 @@
import { Suspense } from 'react'
import { Router } from 'react-router-dom'
import { createInstance, MatomoProvider } from '@jonkoops/matomo-tracker-react'
import { MatomoProvider } from '@jonkoops/matomo-tracker-react'
import { history } from 'config/history'
import { client } from 'config/clients'
import { PAGES } from 'config/pages'
import { matomoInstance } from 'config/matomo'
import { setClientTitleAndDescription } from 'helpers/setClientHeads'
import { isMatchPage } from 'helpers/isMatchPage'
@ -21,11 +21,6 @@ import { AuthenticatedApp } from './AuthenticatedApp'
setClientTitleAndDescription(client.title, client.description)
const matomoInstance = createInstance({
siteId: 1,
urlBase: PAGES.matomoBaseUrl,
})
const Main = () => {
const { loadingUser, user } = useAuthStore()

@ -19,7 +19,9 @@ export const GlobalStores = ({ children }: Props) => {
const { trackPageView } = useMatomo()
useEffect(() => {
trackPageView()
const isProduction = process.env.REACT_APP_ENV === 'production'
if (isProduction) trackPageView()
}, [trackPageView, pathname, search])
return (

Loading…
Cancel
Save