From 18953ed70257bfb7487f9fe05af82f5c99f2fbd8 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Thu, 7 Jun 2018 10:33:15 -0700 Subject: [PATCH] escape hatch for analytics events and removed unnecessary console logs --- client/build/components/GAListener/index.js | 8 -------- client/src/components/GAListener/index.jsx | 8 -------- server/utils/googleAnalytics.js | 8 ++++++-- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/client/build/components/GAListener/index.js b/client/build/components/GAListener/index.js index e1c1a5d4..2e5d81bd 100644 --- a/client/build/components/GAListener/index.js +++ b/client/build/components/GAListener/index.js @@ -35,14 +35,6 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.getPrototypeOf || functio var googleId = null; -if (!_siteConfig.default) { - console.log('WARNING: no site config found for GAListener'); -} - -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; } diff --git a/client/src/components/GAListener/index.jsx b/client/src/components/GAListener/index.jsx index 31ed6395..718fb4ca 100644 --- a/client/src/components/GAListener/index.jsx +++ b/client/src/components/GAListener/index.jsx @@ -6,14 +6,6 @@ import siteConfig from '@config/siteConfig.json'; let googleId = null; -if (!siteConfig) { - console.log('WARNING: no site config found for GAListener'); -} - -if (!siteConfig.analytics) { - console.log('WARNING: no analytics configs found in siteConfig.json'); -} - if (siteConfig && siteConfig.analytics) { ({ googleId } = siteConfig.analytics); } diff --git a/server/utils/googleAnalytics.js b/server/utils/googleAnalytics.js index 6907d347..a193155b 100644 --- a/server/utils/googleAnalytics.js +++ b/server/utils/googleAnalytics.js @@ -24,7 +24,9 @@ const createTimingEventParams = (category, variable, label, startTime, endTime) }; const sendGoogleAnalyticsEvent = (ip, params) => { - logger.debug('googleId', googleId); + if (!googleId) { + return logger.debug('Skipping analytics event because no GoogleId present in configs'); + } const visitorId = ip.replace(/\./g, '-'); const visitor = ua(googleId, visitorId, { strictCidFormat: false, https: true }); visitor.event(params, (err) => { @@ -36,7 +38,9 @@ const sendGoogleAnalyticsEvent = (ip, params) => { }; const sendGoogleAnalyticsTiming = (siteTitle, params) => { - logger.debug('googleId', googleId); + if (!googleId) { + return logger.debug('Skipping analytics timing because no GoogleId present in configs'); + } const visitor = ua(googleId, siteTitle, { strictCidFormat: false, https: true }); visitor.timing(params, (err) => { if (err) {