-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-browser.js
40 lines (31 loc) · 1 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
35
36
37
38
39
40
/* eslint-disable import/prefer-default-export */
import ReactGA from 'react-ga';
import { config } from './data';
import installFontAwesome from './src/api/installFontAwesome';
import 'prismjs/themes/prism-solarizedlight.css';
const {
url, gaTrackId, gaOptimizeId,
} = config;
installFontAwesome();
const isLocalDevelopment = () => window && window.location && window.location.origin !== url;
if (isLocalDevelopment() === false) {
ReactGA.initialize(gaTrackId);
// Google Optimizer
if (gaOptimizeId) {
ReactGA.ga('require', gaOptimizeId);
}
console.log('Welcome to online environment.');
}
// Inspired by APlayer
console.log(
`${'\n'} %c CALPA %c https://calpa.me ${'\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');
}
};