Commit 7edd170e authored by Sean Roberts's avatar Sean Roberts

Add Google Analytics if settings supply it

parent 697d50d7
'use strict';
var queryString = require('query-string');
var addAnalytics = require('./ga');
require('../shared/polyfills');
......@@ -37,6 +38,10 @@ if (settings.raven) {
angular.module('ngRaven', []);
}
if(settings.googleAnalytics){
addAnalytics(settings.googleAnalytics);
}
// Fetch external state that the app needs before it can run. This includes the
// authenticated user state, the API endpoint URLs and WebSocket connection.
var resolve = {
......
'use strict';
let loaded = false;
module.exports = function(trackingId){
// small measure to make we do not accidentally
// load the analytics scripts more than once
if(loaded){
return;
}
loaded = true;
/* eslint-disable */
// Google Analytics snippet to load the analytics script
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', trackingId, 'auto');
// overrides helper that requires http or https protocols.
// obvious issue when it comes to extensions with protocols
// like "chrome-extension://" but isn't a huge need for us
// anywhere else as well.
// https://developers.google.com/analytics/devguides/collection/analyticsjs/tasks#disabling
ga('set', 'checkProtocolTask', null);
/* eslint-enable */
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment