mirror of
https://github.com/uetchy/namae.git
synced 2025-03-17 12:30:32 +09:00
fix: track route event
This commit is contained in:
parent
df71825ab7
commit
3c4fae81c4
@ -1,21 +1,22 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import {BrowserRouter as Router} from 'react-router-dom';
|
import {Router} from 'react-router-dom';
|
||||||
|
|
||||||
import App from './App';
|
import App from './App';
|
||||||
import * as serviceWorker from './serviceWorker';
|
import * as serviceWorker from './serviceWorker';
|
||||||
import {FullScreenSuspense} from './util/suspense';
|
import {FullScreenSuspense} from './util/suspense';
|
||||||
import {initGA, initSentry} from './util/analytics';
|
import {initHistoryWithGA, initSentry} from './util/analytics';
|
||||||
import {initCrisp} from './util/crip';
|
import {initCrisp} from './util/crip';
|
||||||
import './util/i18n';
|
import './util/i18n';
|
||||||
|
|
||||||
initGA();
|
|
||||||
initSentry();
|
initSentry();
|
||||||
initCrisp();
|
initCrisp();
|
||||||
|
|
||||||
|
const history = initHistoryWithGA();
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<FullScreenSuspense>
|
<FullScreenSuspense>
|
||||||
<Router>
|
<Router history={history}>
|
||||||
<App />
|
<App />
|
||||||
</Router>
|
</Router>
|
||||||
</FullScreenSuspense>,
|
</FullScreenSuspense>,
|
||||||
|
@ -1,13 +1,20 @@
|
|||||||
import ReactGA from 'react-ga';
|
import ReactGA from 'react-ga';
|
||||||
import * as Sentry from '@sentry/browser';
|
import * as Sentry from '@sentry/browser';
|
||||||
|
import {createBrowserHistory} from 'history';
|
||||||
|
|
||||||
const isProduction = process.env.NODE_ENV !== 'development';
|
const isProduction = process.env.NODE_ENV !== 'development';
|
||||||
|
|
||||||
export function initGA(): void {
|
export function initHistoryWithGA() {
|
||||||
|
const history = createBrowserHistory();
|
||||||
if (isProduction) {
|
if (isProduction) {
|
||||||
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);
|
||||||
|
history.listen((location) => {
|
||||||
|
ReactGA.set({page: location.pathname});
|
||||||
|
ReactGA.pageview(location.pathname);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
return history;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function track({
|
export function track({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user