feat(#2464): integrated stats code mamoto

keep-around/a8af4bab7b74ecead3e0cdc1842e4ad1ad6e1c3f
Rakov Roman 4 years ago
parent 28cb0681f2
commit a8af4bab7b
  1. 30
      package-lock.json
  2. 1
      package.json
  3. 1
      src/config/pages.tsx
  4. 36
      src/features/App/index.tsx
  5. 28
      src/features/GlobalStores/index.tsx

30
package-lock.json generated

@ -8,6 +8,7 @@
"name": "spa_instat_tv", "name": "spa_instat_tv",
"version": "0.1.0", "version": "0.1.0",
"dependencies": { "dependencies": {
"@jonkoops/matomo-tracker-react": "^0.7.0",
"@stripe/react-stripe-js": "^1.4.0", "@stripe/react-stripe-js": "^1.4.0",
"@stripe/stripe-js": "^1.13.2", "@stripe/stripe-js": "^1.13.2",
"babel-polyfill": "^6.26.0", "babel-polyfill": "^6.26.0",
@ -3711,6 +3712,22 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/@jonkoops/matomo-tracker": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/@jonkoops/matomo-tracker/-/matomo-tracker-0.7.0.tgz",
"integrity": "sha512-ppCXiDaVytTQOP6hNZIBwjUph5IrGgDoQw4IF5sBoA3PBpMAc5tWtPExbVWTR5pJWpTcp11dv2M83n9pm7LpeQ=="
},
"node_modules/@jonkoops/matomo-tracker-react": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/@jonkoops/matomo-tracker-react/-/matomo-tracker-react-0.7.0.tgz",
"integrity": "sha512-3iwG/QM1T6KokU/NZNCkhOccIkhaNnO1+0bTv2JsLbsS7u7hWxpio20gfBjCRd/9N1AMiGidvytG2FK9tu7WFw==",
"dependencies": {
"@jonkoops/matomo-tracker": "^0.7.0"
},
"peerDependencies": {
"react": ">= 16.8.0"
}
},
"node_modules/@mdx-js/loader": { "node_modules/@mdx-js/loader": {
"version": "1.6.22", "version": "1.6.22",
"resolved": "https://registry.npmjs.org/@mdx-js/loader/-/loader-1.6.22.tgz", "resolved": "https://registry.npmjs.org/@mdx-js/loader/-/loader-1.6.22.tgz",
@ -36087,6 +36104,19 @@
} }
} }
}, },
"@jonkoops/matomo-tracker": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/@jonkoops/matomo-tracker/-/matomo-tracker-0.7.0.tgz",
"integrity": "sha512-ppCXiDaVytTQOP6hNZIBwjUph5IrGgDoQw4IF5sBoA3PBpMAc5tWtPExbVWTR5pJWpTcp11dv2M83n9pm7LpeQ=="
},
"@jonkoops/matomo-tracker-react": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/@jonkoops/matomo-tracker-react/-/matomo-tracker-react-0.7.0.tgz",
"integrity": "sha512-3iwG/QM1T6KokU/NZNCkhOccIkhaNnO1+0bTv2JsLbsS7u7hWxpio20gfBjCRd/9N1AMiGidvytG2FK9tu7WFw==",
"requires": {
"@jonkoops/matomo-tracker": "^0.7.0"
}
},
"@mdx-js/loader": { "@mdx-js/loader": {
"version": "1.6.22", "version": "1.6.22",
"resolved": "https://registry.npmjs.org/@mdx-js/loader/-/loader-1.6.22.tgz", "resolved": "https://registry.npmjs.org/@mdx-js/loader/-/loader-1.6.22.tgz",

@ -18,6 +18,7 @@
"lff": "REACT_APP_CLIENT=lff react-scripts start" "lff": "REACT_APP_CLIENT=lff react-scripts start"
}, },
"dependencies": { "dependencies": {
"@jonkoops/matomo-tracker-react": "^0.7.0",
"@stripe/react-stripe-js": "^1.4.0", "@stripe/react-stripe-js": "^1.4.0",
"@stripe/stripe-js": "^1.13.2", "@stripe/stripe-js": "^1.13.2",
"babel-polyfill": "^6.26.0", "babel-polyfill": "^6.26.0",

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

@ -1,10 +1,13 @@
import { Suspense } from 'react' import { Suspense } from 'react'
import { Router } from 'react-router-dom' import { Router } from 'react-router-dom'
import { createInstance, MatomoProvider } from '@jonkoops/matomo-tracker-react'
import { history } from 'config/history' import { history } from 'config/history'
import { client } from 'config/clients' import { client } from 'config/clients'
import { setClientTitleAndDescription } from 'helpers/setClientHeads' import { PAGES } from 'config/pages'
import { setClientTitleAndDescription } from 'helpers/setClientHeads'
import { isMatchPage } from 'helpers/isMatchPage' import { isMatchPage } from 'helpers/isMatchPage'
import { GlobalStores } from 'features/GlobalStores' import { GlobalStores } from 'features/GlobalStores'
@ -18,6 +21,11 @@ import { AuthenticatedApp } from './AuthenticatedApp'
setClientTitleAndDescription(client.title, client.description) setClientTitleAndDescription(client.title, client.description)
const matomoInstance = createInstance({
siteId: 1,
urlBase: PAGES.matomoBaseUrl,
})
const Main = () => { const Main = () => {
const { loadingUser, user } = useAuthStore() const { loadingUser, user } = useAuthStore()
@ -32,18 +40,20 @@ const Main = () => {
} }
const OTTApp = () => ( const OTTApp = () => (
<Router history={history}> <MatomoProvider value={matomoInstance}>
<Theme> <Router history={history}>
<GlobalStyles /> <Theme>
<GlobalStores> <GlobalStyles />
<Background> <GlobalStores>
<Suspense fallback={null}> <Background>
<Main /> <Suspense fallback={null}>
</Suspense> <Main />
</Background> </Suspense>
</GlobalStores> </Background>
</Theme> </GlobalStores>
</Router> </Theme>
</Router>
</MatomoProvider>
) )
export default OTTApp export default OTTApp

@ -1,9 +1,12 @@
import { ReactNode } from 'react' import { ReactNode, useEffect } from 'react'
import { useMatomo } from '@jonkoops/matomo-tracker-react'
import { getLanguageUrlParam } from 'helpers/languageUrlParam' import { getLanguageUrlParam } from 'helpers/languageUrlParam'
import { AuthStore } from 'features/AuthStore' import { AuthStore } from 'features/AuthStore'
import { LexicsStore } from 'features/LexicsStore' import { LexicsStore } from 'features/LexicsStore'
import { useLocation } from 'react-router'
const initialLanguage = getLanguageUrlParam() const initialLanguage = getLanguageUrlParam()
@ -11,10 +14,19 @@ type Props = {
children: ReactNode, children: ReactNode,
} }
export const GlobalStores = ({ children }: Props) => ( export const GlobalStores = ({ children }: Props) => {
<LexicsStore initialLanguage={initialLanguage}> const { pathname, search } = useLocation()
<AuthStore> const { trackPageView } = useMatomo()
{children}
</AuthStore> useEffect(() => {
</LexicsStore> trackPageView()
) }, [trackPageView, pathname, search])
return (
<LexicsStore initialLanguage={initialLanguage}>
<AuthStore>
{children}
</AuthStore>
</LexicsStore>
)
}

Loading…
Cancel
Save