1
0
mirror of https://github.com/uetchy/namae.git synced 2025-08-20 18:08:11 +09:00

fix: track route event

This commit is contained in:
2020-03-06 00:35:37 +09:00
parent df71825ab7
commit 3c4fae81c4
2 changed files with 13 additions and 5 deletions

View File

@@ -1,13 +1,20 @@
import ReactGA from 'react-ga';
import * as Sentry from '@sentry/browser';
import {createBrowserHistory} from 'history';
const isProduction = process.env.NODE_ENV !== 'development';
export function initGA(): void {
export function initHistoryWithGA() {
const history = createBrowserHistory();
if (isProduction) {
ReactGA.initialize('UA-28919359-15');
ReactGA.pageview(window.location.pathname + window.location.search);
history.listen((location) => {
ReactGA.set({page: location.pathname});
ReactGA.pageview(location.pathname);
});
}
return history;
}
export function track({