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

fix: optimize analytics

This commit is contained in:
uetchy 2019-08-07 17:42:07 +09:00
parent 4cd10945b5
commit 102b98b76a
10 changed files with 1642 additions and 11247 deletions

View File

@ -4,9 +4,9 @@ exports.fetch = (url, method = 'HEAD') => {
return fetch(url, { method })
}
exports.send = (res, obj) => {
res.setHeader('Cache-Control', 'maxage=0, s-maxage=3600')
res.json(obj)
exports.send = (res, data) => {
res.setHeader('Cache-Control', 'maxage=0, s-maxage=43200')
res.json(data)
}
exports.sendError = (res, error) => {

1190
api/yarn.lock Normal file

File diff suppressed because it is too large Load Diff

View File

@ -4,17 +4,9 @@
"author": "Yasuaki Uechi <y@uechi.io> (https://uechi.io/)",
"scripts": {
"start": "now dev",
"test": "yarn workspaces run test"
"ship": "now"
},
"dependencies": {},
"devDependencies": {
"@types/node": "^12.6.9",
"typescript": "^3.5.3"
},
"license": "MIT",
"private": true,
"workspaces": [
"api",
"web"
]
"private": true
}

View File

@ -2,7 +2,7 @@
"name": "@namae/web",
"version": "0.1.0",
"scripts": {
"build": "react-scripts build",
"build": "NODE_ENV=production react-scripts build",
"eject": "react-scripts eject",
"now-build": "yarn build",
"now-dev": "BROWSER=none react-scripts start",
@ -30,7 +30,8 @@
},
"devDependencies": {
"@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": {
"production": [

View File

@ -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 />
</>
)
}

View File

@ -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()
})

View File

@ -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
}

View File

@ -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()

File diff suppressed because it is too large Load Diff

11086
yarn.lock

File diff suppressed because it is too large Load Diff