mirror of
https://github.com/uetchy/namae.git
synced 2025-03-17 04:30:31 +09:00
fix: track route event
This commit is contained in:
parent
df71825ab7
commit
3c4fae81c4
@ -1,21 +1,22 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import {BrowserRouter as Router} from 'react-router-dom';
|
||||
import {Router} from 'react-router-dom';
|
||||
|
||||
import App from './App';
|
||||
import * as serviceWorker from './serviceWorker';
|
||||
import {FullScreenSuspense} from './util/suspense';
|
||||
import {initGA, initSentry} from './util/analytics';
|
||||
import {initHistoryWithGA, initSentry} from './util/analytics';
|
||||
import {initCrisp} from './util/crip';
|
||||
import './util/i18n';
|
||||
|
||||
initGA();
|
||||
initSentry();
|
||||
initCrisp();
|
||||
|
||||
const history = initHistoryWithGA();
|
||||
|
||||
ReactDOM.render(
|
||||
<FullScreenSuspense>
|
||||
<Router>
|
||||
<Router history={history}>
|
||||
<App />
|
||||
</Router>
|
||||
</FullScreenSuspense>,
|
||||
|
@ -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({
|
||||
|
Loading…
x
Reference in New Issue
Block a user