diff --git a/src/lib/analytics.js b/src/lib/analytics.js index 7a233ff328e0f2b2b4041ac93f0733238a7e239b..cd08719dd3c519d91b9092ddaf1f11f0f96d7da4 100644 --- a/src/lib/analytics.js +++ b/src/lib/analytics.js @@ -8,6 +8,13 @@ if (GA_ID) { sampleRate: (process.env.NODE_ENV === 'production') ? 100 : 0, forceSSL: true }); +} else { + window.ga = () => { + // The `react-ga` module calls this function to implement all Google Analytics calls. Providing an empty + // function effectively disables `react-ga`. This is similar to the `testModeAPI` feature of `react-ga` except + // that `testModeAPI` logs the arguments of every call into an array. That's nice for testing purposes but + // would look like a memory leak in a live program. + }; } export default GoogleAnalytics;