1
0
mirror of https://github.com/uetchy/namae.git synced 2025-03-17 04:30:31 +09:00

feat: add event reporter

This commit is contained in:
uetchy 2019-08-01 01:10:09 +09:00
parent 19ffa22c29
commit 88a67e45fc
3 changed files with 19 additions and 8 deletions

View File

@ -16,6 +16,7 @@ import JsOrgCard from './components/cards/JsOrgCard'
import PypiCard from './components/cards/PypiCard'
import S3Card from './components/cards/S3Card'
import CratesioCard from './components/cards/CratesioCard'
import { EventReporter } from './components/Analytics'
export default function App() {
const [query, setQuery] = useDeferredState(1000)
@ -47,6 +48,7 @@ export default function App() {
<S3Card name={query} />
<JsOrgCard name={query} />
</CardContainer>
<EventReporter query={query} />
</Cards>
) : null}
@ -80,7 +82,7 @@ const Input = styled.input.attrs({
spellcheck: 'false',
})`
width: 100%;
margin-top: 20px;
margin-top: 30px;
padding: 20px;
outline: none;
text-align: center;
@ -88,11 +90,7 @@ const Input = styled.input.attrs({
font-family: monospace;
border: none;
transition: box-shadow 0.5s ease-out;
&:hover {
box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
}
box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
${mobile} {
font-size: 2rem;

View File

@ -0,0 +1,13 @@
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
}

View File

@ -5,9 +5,9 @@ import './index.css'
import App from './App'
import * as serviceWorker from './serviceWorker'
ReactDOM.render(<App />, document.getElementById('root'))
ReactGA.initialize('UA-28919359-15')
ReactGA.pageview(window.location.pathname + window.location.search)
ReactDOM.render(<App />, document.getElementById('root'))
serviceWorker.unregister()