Yandex metrica work
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-07-05 02:19:27 +03:00
parent ccf1aaba9b
commit 0df5022493
4 changed files with 27 additions and 19 deletions

View File

@@ -1,6 +1,8 @@
import { CssBaseline } from '@mui/material'
import { createTheme, ThemeProvider } from '@mui/material/styles'
import { appWithTranslation } from 'next-i18next'
import { useEffect } from 'react'
import ym from 'react-yandex-metrika'
import 'reset-css'
import '../styles/global.scss'
@@ -13,6 +15,15 @@ function App ({ Component, pageProps }) {
}
})
useEffect(() => {
if (typeof window !== 'undefined' && process.env.NODE_ENV === 'production') {
const url = window.location.pathname + window.location.search
ym('hit', url)
} else {
console.log('Not in production, not sending Yandex Metrika hit')
}
}, [])
return (
<ThemeProvider theme={theme}>
<CssBaseline />

View File

@@ -1,5 +1,4 @@
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
import { Component } from 'react'
import { models } from 'shared-stuff'
import dbConnect from '../../lib/dbConnect'
@@ -7,22 +6,15 @@ import dbConnect from '../../lib/dbConnect'
import Hero from './Hero'
import Table from './Table'
export default class Home extends Component {
constructor ({ scanResults }) {
super()
this.scanResults = scanResults
}
render () {
return (
<>
<Hero />
<Table
scanResults={this.scanResults}
/>
</>
)
}
export default function Home ({ scanResults }) {
return (
<>
<Hero />
<Table
scanResults={scanResults}
/>
</>
)
}
export async function getServerSideProps ({ locale }) {