mirror of
https://github.com/uetchy/namae.git
synced 2025-08-20 09:58:13 +09:00
fix: optimize analytics
This commit is contained in:
@@ -19,7 +19,6 @@ import GithubSearchCard from './components/cards/GithubSearchCard'
|
||||
import AppStoreCard from './components/cards/AppStoreCard'
|
||||
import GoogleCard from './components/cards/GoogleCard'
|
||||
|
||||
import { EventReporter } from './components/Analytics'
|
||||
import Welcome from './components/Welcome'
|
||||
import Footer from './components/Footer'
|
||||
import Suggestion from './components/Suggestion'
|
||||
@@ -111,13 +110,13 @@ export default function App() {
|
||||
<AppStoreCard query={query} />
|
||||
<GoogleCard query={query} />
|
||||
</Cards>
|
||||
<EventReporter query={query} />
|
||||
</SearchResult>
|
||||
) : !isStandalone() ? (
|
||||
<Welcome />
|
||||
) : null}
|
||||
{!isStandalone() ? <Footer /> : null}
|
||||
) : (
|
||||
!isStandalone() && <Welcome />
|
||||
)}
|
||||
</Content>
|
||||
|
||||
<Footer />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
@@ -4,5 +4,5 @@ import App from './App'
|
||||
|
||||
it('renders welcome message', () => {
|
||||
const { getByText } = render(<App />)
|
||||
expect(getByText('name new project')).toBeInTheDocument()
|
||||
expect(getByText('namæ')).toBeInTheDocument()
|
||||
})
|
||||
|
@@ -1,13 +0,0 @@
|
||||
import { useEffect } from 'react'
|
||||
import ReactGA from 'react-ga'
|
||||
|
||||
export function EventReporter({ query }) {
|
||||
useEffect(() => {
|
||||
ReactGA.event({
|
||||
category: 'Navigation',
|
||||
action: 'Send a request',
|
||||
})
|
||||
}, [query])
|
||||
|
||||
return null
|
||||
}
|
@@ -1,7 +1,6 @@
|
||||
import React, { Suspense } from 'react'
|
||||
import styled from 'styled-components'
|
||||
import ReactDOM from 'react-dom'
|
||||
import ReactGA from 'react-ga'
|
||||
import BarLoader from 'react-spinners/BarLoader'
|
||||
import App from './App'
|
||||
import * as serviceWorker from './serviceWorker'
|
||||
@@ -30,7 +29,11 @@ ReactDOM.render(
|
||||
document.getElementById('root')
|
||||
)
|
||||
|
||||
ReactGA.initialize('UA-28919359-15')
|
||||
ReactGA.pageview(window.location.pathname + window.location.search)
|
||||
if (process.env.NODE_ENV !== 'development') {
|
||||
import('react-ga').then((ReactGA) => {
|
||||
ReactGA.initialize('UA-28919359-15')
|
||||
ReactGA.pageview(window.location.pathname + window.location.search)
|
||||
})
|
||||
}
|
||||
|
||||
serviceWorker.register()
|
||||
|
Reference in New Issue
Block a user