Skip to content

Commit

Permalink
import and init react-ga only for production
Browse files Browse the repository at this point in the history
  • Loading branch information
spitfire1236 committed Jan 30, 2019
1 parent 1e856db commit de3df55
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable react/jsx-filename-extension */
import React from 'react';
import createHistory from 'history/createBrowserHistory';
import ReactGA from 'react-ga';
import { hydrate, render } from 'react-dom';
import { Provider } from 'react-redux';
import { Route, Router } from 'react-router-dom';
Expand All @@ -19,12 +18,17 @@ store.dispatch(getHeroAbilities());
store.dispatch(getNeutralAbilities());
store.dispatch(getAbilityIds());

ReactGA.initialize('UA-55757642-1');
ReactGA.pageview(window.location.pathname + window.location.search);
const history = createHistory();
history.listen((location) => {
ReactGA.pageview(location.pathname);
});

if (process.env.NODE_ENV === 'production') {
const ReactGA = require('react-ga'); // eslint-disable-line global-require
ReactGA.initialize('UA-55757642-1');
ReactGA.pageview(window.location.pathname + window.location.search);

history.listen((location) => {
ReactGA.pageview(location.pathname);
});
}

const rootElement = document.getElementById('root');
const app = (
Expand Down

0 comments on commit de3df55

Please sign in to comment.