Skip to content
Snippets Groups Projects
Commit 6089012e authored by Allen Gilliland's avatar Allen Gilliland
Browse files

have the frontend app disable/enable GA tracking based on the users choice on...

have the frontend app disable/enable GA tracking based on the users choice on the `anon-tracking-enabled` setting.
parent edf87ee8
Branches
Tags
No related merge requests found
......@@ -3,8 +3,8 @@
var SettingsAdminControllers = angular.module('corvusadmin.settings.controllers', ['corvusadmin.settings.services']);
SettingsAdminControllers.controller('SettingsAdminController', ['$scope', '$q', 'SettingsAdminServices',
function($scope, $q, SettingsAdminServices) {
SettingsAdminControllers.controller('SettingsAdminController', ['$scope', '$q', 'AppState', 'SettingsAdminServices',
function($scope, $q, AppState, SettingsAdminServices) {
$scope.settings = [];
SettingsAdminServices.list(function(results) {
......@@ -36,6 +36,10 @@ SettingsAdminControllers.controller('SettingsAdminController', ['$scope', '$q',
}
})).then(function(results) {
$scope.$broadcast("form:api-success", "Successfully saved!");
// refresh the app-wide settings now as the user may have just changed some of them
AppState.refreshSiteSettings();
}, function(error) {
$scope.$broadcast("form:api-error", error);
throw error;
......
......@@ -212,6 +212,18 @@ CorvusServices.factory('AppState', ['$rootScope', '$q', '$location', '$timeout',
/* eslint-enable */
});
// enable / disable GA based on opt-out of anonymous tracking
$rootScope.$on("appstate:site-settings", function(event, settings) {
var tracking = settings['anon-tracking-enabled']['value'];
if (tracking === "true" || tracking === null) {
// we are doing tracking
window['ga-disable-UA-60817802-1'] = null;
} else {
// tracking is disabled
window['ga-disable-UA-60817802-1'] = true;
}
});
// NOTE: the below events are generated from the http-auth-interceptor which listens on our $http calls
// and intercepts calls that result in a 401 or 403 so that we can handle them here. You must be
// careful to consider the implications of this because any endpoint that returns a 401/403 can
......
......@@ -131,6 +131,9 @@
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
// start off with tracking disabled (the angular app will re-enable this once we know the app runtime settings)
window['ga-disable-UA-60817802-1'] = true;
ga('create', 'UA-60817802-1', 'auto');
</script>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment