mirror of
https://github.com/uetchy/namae.git
synced 2025-03-17 12:30:32 +09:00
feat: add event reporter
This commit is contained in:
parent
19ffa22c29
commit
88a67e45fc
@ -16,6 +16,7 @@ import JsOrgCard from './components/cards/JsOrgCard'
|
|||||||
import PypiCard from './components/cards/PypiCard'
|
import PypiCard from './components/cards/PypiCard'
|
||||||
import S3Card from './components/cards/S3Card'
|
import S3Card from './components/cards/S3Card'
|
||||||
import CratesioCard from './components/cards/CratesioCard'
|
import CratesioCard from './components/cards/CratesioCard'
|
||||||
|
import { EventReporter } from './components/Analytics'
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
const [query, setQuery] = useDeferredState(1000)
|
const [query, setQuery] = useDeferredState(1000)
|
||||||
@ -47,6 +48,7 @@ export default function App() {
|
|||||||
<S3Card name={query} />
|
<S3Card name={query} />
|
||||||
<JsOrgCard name={query} />
|
<JsOrgCard name={query} />
|
||||||
</CardContainer>
|
</CardContainer>
|
||||||
|
<EventReporter query={query} />
|
||||||
</Cards>
|
</Cards>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
@ -80,7 +82,7 @@ const Input = styled.input.attrs({
|
|||||||
spellcheck: 'false',
|
spellcheck: 'false',
|
||||||
})`
|
})`
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin-top: 20px;
|
margin-top: 30px;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
outline: none;
|
outline: none;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@ -88,11 +90,7 @@ const Input = styled.input.attrs({
|
|||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
border: none;
|
border: none;
|
||||||
|
|
||||||
transition: box-shadow 0.5s ease-out;
|
box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
|
||||||
|
|
||||||
&:hover {
|
|
||||||
box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
|
|
||||||
}
|
|
||||||
|
|
||||||
${mobile} {
|
${mobile} {
|
||||||
font-size: 2rem;
|
font-size: 2rem;
|
||||||
|
13
web/src/components/Analytics.js
Normal file
13
web/src/components/Analytics.js
Normal 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
|
||||||
|
}
|
@ -5,9 +5,9 @@ import './index.css'
|
|||||||
import App from './App'
|
import App from './App'
|
||||||
import * as serviceWorker from './serviceWorker'
|
import * as serviceWorker from './serviceWorker'
|
||||||
|
|
||||||
|
ReactDOM.render(<App />, document.getElementById('root'))
|
||||||
|
|
||||||
ReactGA.initialize('UA-28919359-15')
|
ReactGA.initialize('UA-28919359-15')
|
||||||
ReactGA.pageview(window.location.pathname + window.location.search)
|
ReactGA.pageview(window.location.pathname + window.location.search)
|
||||||
|
|
||||||
ReactDOM.render(<App />, document.getElementById('root'))
|
|
||||||
|
|
||||||
serviceWorker.unregister()
|
serviceWorker.unregister()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user