mirror of
https://github.com/uetchy/namae.git
synced 2025-03-17 12:30:32 +09:00
fix: optimize analytics
This commit is contained in:
parent
4cd10945b5
commit
102b98b76a
@ -4,9 +4,9 @@ exports.fetch = (url, method = 'HEAD') => {
|
|||||||
return fetch(url, { method })
|
return fetch(url, { method })
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.send = (res, obj) => {
|
exports.send = (res, data) => {
|
||||||
res.setHeader('Cache-Control', 'maxage=0, s-maxage=3600')
|
res.setHeader('Cache-Control', 'maxage=0, s-maxage=43200')
|
||||||
res.json(obj)
|
res.json(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.sendError = (res, error) => {
|
exports.sendError = (res, error) => {
|
||||||
|
1190
api/yarn.lock
Normal file
1190
api/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
12
package.json
12
package.json
@ -4,17 +4,9 @@
|
|||||||
"author": "Yasuaki Uechi <y@uechi.io> (https://uechi.io/)",
|
"author": "Yasuaki Uechi <y@uechi.io> (https://uechi.io/)",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "now dev",
|
"start": "now dev",
|
||||||
"test": "yarn workspaces run test"
|
"ship": "now"
|
||||||
},
|
},
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"devDependencies": {
|
|
||||||
"@types/node": "^12.6.9",
|
|
||||||
"typescript": "^3.5.3"
|
|
||||||
},
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"private": true,
|
"private": true
|
||||||
"workspaces": [
|
|
||||||
"api",
|
|
||||||
"web"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"name": "@namae/web",
|
"name": "@namae/web",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "react-scripts build",
|
"build": "NODE_ENV=production react-scripts build",
|
||||||
"eject": "react-scripts eject",
|
"eject": "react-scripts eject",
|
||||||
"now-build": "yarn build",
|
"now-build": "yarn build",
|
||||||
"now-dev": "BROWSER=none react-scripts start",
|
"now-dev": "BROWSER=none react-scripts start",
|
||||||
@ -30,7 +30,8 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@testing-library/jest-dom": "^4.0.0",
|
"@testing-library/jest-dom": "^4.0.0",
|
||||||
"@testing-library/react": "^8.0.7"
|
"@testing-library/react": "^8.0.8",
|
||||||
|
"@types/node": "^12.7.0"
|
||||||
},
|
},
|
||||||
"browserslist": {
|
"browserslist": {
|
||||||
"production": [
|
"production": [
|
||||||
|
@ -19,7 +19,6 @@ import GithubSearchCard from './components/cards/GithubSearchCard'
|
|||||||
import AppStoreCard from './components/cards/AppStoreCard'
|
import AppStoreCard from './components/cards/AppStoreCard'
|
||||||
import GoogleCard from './components/cards/GoogleCard'
|
import GoogleCard from './components/cards/GoogleCard'
|
||||||
|
|
||||||
import { EventReporter } from './components/Analytics'
|
|
||||||
import Welcome from './components/Welcome'
|
import Welcome from './components/Welcome'
|
||||||
import Footer from './components/Footer'
|
import Footer from './components/Footer'
|
||||||
import Suggestion from './components/Suggestion'
|
import Suggestion from './components/Suggestion'
|
||||||
@ -111,13 +110,13 @@ export default function App() {
|
|||||||
<AppStoreCard query={query} />
|
<AppStoreCard query={query} />
|
||||||
<GoogleCard query={query} />
|
<GoogleCard query={query} />
|
||||||
</Cards>
|
</Cards>
|
||||||
<EventReporter query={query} />
|
|
||||||
</SearchResult>
|
</SearchResult>
|
||||||
) : !isStandalone() ? (
|
) : (
|
||||||
<Welcome />
|
!isStandalone() && <Welcome />
|
||||||
) : null}
|
)}
|
||||||
{!isStandalone() ? <Footer /> : null}
|
|
||||||
</Content>
|
</Content>
|
||||||
|
|
||||||
|
<Footer />
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -4,5 +4,5 @@ import App from './App'
|
|||||||
|
|
||||||
it('renders welcome message', () => {
|
it('renders welcome message', () => {
|
||||||
const { getByText } = render(<App />)
|
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 React, { Suspense } from 'react'
|
||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
import ReactDOM from 'react-dom'
|
import ReactDOM from 'react-dom'
|
||||||
import ReactGA from 'react-ga'
|
|
||||||
import BarLoader from 'react-spinners/BarLoader'
|
import BarLoader from 'react-spinners/BarLoader'
|
||||||
import App from './App'
|
import App from './App'
|
||||||
import * as serviceWorker from './serviceWorker'
|
import * as serviceWorker from './serviceWorker'
|
||||||
@ -30,7 +29,11 @@ ReactDOM.render(
|
|||||||
document.getElementById('root')
|
document.getElementById('root')
|
||||||
)
|
)
|
||||||
|
|
||||||
ReactGA.initialize('UA-28919359-15')
|
if (process.env.NODE_ENV !== 'development') {
|
||||||
ReactGA.pageview(window.location.pathname + window.location.search)
|
import('react-ga').then((ReactGA) => {
|
||||||
|
ReactGA.initialize('UA-28919359-15')
|
||||||
|
ReactGA.pageview(window.location.pathname + window.location.search)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
serviceWorker.register()
|
serviceWorker.register()
|
||||||
|
555
web/yarn.lock
555
web/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user