Fix configs loading #470

Merged
bones7242 merged 15 commits from fix-configs-loading into master 2018-06-07 19:40:01 +02:00
2 changed files with 28 additions and 11 deletions
Showing only changes of commit 98ea4d226f - Show all commits

View file

@ -36,12 +36,18 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.getPrototypeOf || functio
var googleId = null;
if (!_siteConfig.default) {
console.log('no site config found for GAListener');
console.log('WARNING: no site config found for GAListener');
}
if (_siteConfig.default.analytics) {
googleId = _siteConfig.default.analytics.googleId;
if (!_siteConfig.default.analytics) {
console.log('WARNING: no analytics configs found in siteConfig.json');
}
if (_siteConfig.default && _siteConfig.default.analytics) {
googleId = _siteConfig.default.analytics.googleId;
}
if (googleId) {
_reactGa.default.initialize(googleId);
}
@ -63,12 +69,14 @@ function (_React$Component) {
}, {
key: "sendPageView",
value: function sendPageView(location) {
if (googleId) {
_reactGa.default.set({
page: location.pathname
});
_reactGa.default.pageview(location.pathname);
}
}
}, {
key: "render",
value: function render() {

View file

@ -7,11 +7,18 @@ import siteConfig from '@config/siteConfig.json';
let googleId = null;
if (!siteConfig) {
console.log('no site config found for GAListener');
console.log('WARNING: no site config found for GAListener');
}
if (siteConfig.analytics) {
if (!siteConfig.analytics) {
console.log('WARNING: no analytics configs found in siteConfig.json');
}
if (siteConfig && siteConfig.analytics) {
({ googleId } = siteConfig.analytics);
}
if (googleId) {
GoogleAnalytics.initialize(googleId);
}
@ -22,9 +29,11 @@ class GAListener extends React.Component {
}
sendPageView (location) {
if (googleId) {
GoogleAnalytics.set({ page: location.pathname });
GoogleAnalytics.pageview(location.pathname);
}
}
render () {
return this.props.children;