-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-browser.js
34 lines (28 loc) · 1.01 KB
/
gatsby-browser.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import ReactGA from 'react-ga';
import React from 'react';
import { url, gaTrackId, gaOptimizeId } from './config.json';
import ThemeContextWrapper from './src/utils/ThemeContext';
// provide theme state to entire app
export const wrapRootElement = ({ element }) => (
<ThemeContextWrapper>{element}</ThemeContextWrapper>
);
import 'prismjs/themes/prism-solarizedlight.css';
const isLocalDevelopment = () => window && window.location && window.location.origin !== url;
if (isLocalDevelopment() === false) {
ReactGA.initialize(gaTrackId);
if (gaOptimizeId) {
ReactGA.ga('require', gaOptimizeId);
}
}
console.log(
`${'\n'} %c Leon %c https://ladc.dev ${'\n'}${'\n'}`,
'color: #6cf; background: #030307; padding:5px 0;',
'background: #6cf; padding:5px 0;',
);
export const onRouteUpdate = (state) => {
if (isLocalDevelopment() !== true) {
ReactGA.pageview(state.location.pathname);
} else {
console.log('isLocalDevelopment is true, so ReactGA is not activated');
}
};