Skip to content

Commit

Permalink
analytics for firefox are disabled by default
Browse files Browse the repository at this point in the history
  • Loading branch information
kspearrin committed Feb 25, 2017
1 parent 6c5786c commit 895fee0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
16 changes: 13 additions & 3 deletions src/popup/app/settings/settingsFeaturesController.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
angular
.module('bit.settings')

.controller('settingsFeaturesController', function ($scope, i18nService, $analytics, constantsService) {
.controller('settingsFeaturesController', function ($scope, i18nService, $analytics, constantsService, utilsService) {
$scope.i18n = i18nService;
$scope.disableGa = false;
$scope.disableAddLoginNotification = false;

chrome.storage.local.get(constantsService.disableGaKey, function (obj) {
if (obj && obj[constantsService.disableGaKey]) {
// Default for Firefox is disabled.
if ((utilsService.isFirefox() && obj[constantsService.disableGaKey] === undefined) ||
obj[constantsService.disableGaKey]) {
$scope.disableGa = true;
}
else {
$scope.disableGa = false;
}

$scope.$apply();
});

chrome.storage.local.get(constantsService.disableAddLoginNotificationKey, function (obj) {
Expand All @@ -22,11 +26,15 @@
else {
$scope.disableAddLoginNotification = false;
}

$scope.$apply();
});

$scope.updateGa = function () {
chrome.storage.local.get(constantsService.disableGaKey, function (obj) {
if (obj[constantsService.disableGaKey]) {
// Default for Firefox is disabled.
if ((utilsService.isFirefox() && obj[constantsService.disableGaKey] === undefined) ||
obj[constantsService.disableGaKey]) {
// enable
obj[constantsService.disableGaKey] = false;
}
Expand All @@ -38,6 +46,7 @@

chrome.storage.local.set(obj, function () {
$scope.disableGa = obj[constantsService.disableGaKey];
$scope.$apply();
if (!obj[constantsService.disableGaKey]) {
$analytics.eventTrack('Enabled Google Analytics');
}
Expand All @@ -59,6 +68,7 @@

chrome.storage.local.set(obj, function () {
$scope.disableAddLoginNotification = obj[constantsService.disableAddLoginNotificationKey];
$scope.$apply();
if (!obj[constantsService.disableAddLoginNotificationKey]) {
$analytics.eventTrack('Enabled Add Login Notification');
}
Expand Down
4 changes: 3 additions & 1 deletion src/scripts/analytics.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var gaTrackingId = chrome.extension.getBackgroundPage().utilsService.analyticsId();
var gaFunc = null;
var isFirefox = chrome.extension.getBackgroundPage().utilsService.isFirefox();

window.GoogleAnalyticsObject = 'ga';
window[window.GoogleAnalyticsObject] = function (action, param1, param2, param3, param4) {
Expand All @@ -8,7 +9,8 @@ window[window.GoogleAnalyticsObject] = function (action, param1, param2, param3,
}

chrome.storage.local.get('disableGa', function (obj) {
if (obj && obj['disableGa']) {
// Default for Firefox is disabled.
if ((isFirefox && obj['disableGa'] === undefined) || obj['disableGa']) {
return;
}

Expand Down

1 comment on commit 895fee0

@chrissnell
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this forever remain the case? Any plans to expose the opt-out in the UI?

Please sign in to comment.