Make use of settings to prevent tracking in analytics module

`SettingsService` is injected manually using `$injector` to a void a
circular dependency over `$rootScope` by `$localStorage`.
This commit is contained in:
Juan Cruz Viotti 2016-03-01 12:24:34 -04:00
parent 61a1527c7e
commit f208d2e34d
6 changed files with 36 additions and 12 deletions

View File

@ -5984,5 +5984,5 @@ body {
.btn-navigation {
position: fixed;
top: 10px;
right: 15px;
right: 10px;
font-size: 15px; }

View File

@ -32,7 +32,8 @@ window.MIXPANEL_CUSTOM_LIB_URL = '../bower_components/mixpanel/mixpanel.js';
require('../../../bower_components/mixpanel/mixpanel-jslib-snippet.js');
require('../../../bower_components/angular-mixpanel/src/angular-mixpanel');
const analytics = angular.module('Etcher.analytics', [
'analytics.mixpanel'
'analytics.mixpanel',
'Etcher.settings'
]);
analytics.config(function($mixpanelProvider) {
@ -55,21 +56,32 @@ analytics.config(function($mixpanelProvider) {
// TrackJS integration
// http://docs.trackjs.com/tracker/framework-integrations
analytics.config(function($provide) {
$provide.decorator('$exceptionHandler', function($delegate, $window) {
$provide.decorator('$exceptionHandler', function($delegate, $window, $injector) {
return function(exception, cause) {
$window.trackJs.track(exception);
const SettingsService = $injector.get('SettingsService');
if (SettingsService.data.errorReporting) {
$window.trackJs.track(exception);
}
$delegate(exception, cause);
};
});
$provide.decorator('$log', function($delegate, $window) {
$provide.decorator('$log', function($delegate, $window, $injector) {
// Save the original $log.debug()
let debugFn = $delegate.debug;
$delegate.debug = function(message) {
message = new Date() + ' ' + message;
$window.trackJs.console.debug(message);
const SettingsService = $injector.get('SettingsService');
if (SettingsService.data.errorReporting) {
$window.trackJs.console.debug(message);
}
debugFn.call(null, message);
};
@ -77,7 +89,7 @@ analytics.config(function($provide) {
});
});
analytics.service('AnalyticsService', function($log, $mixpanel) {
analytics.service('AnalyticsService', function($log, $mixpanel, SettingsService) {
let self = this;
/**
@ -115,10 +127,14 @@ analytics.service('AnalyticsService', function($log, $mixpanel) {
*/
this.logEvent = function(message, data) {
// Clone data before passing it to `mixpanel.track`
// since this function mutates the object adding
// some custom private Mixpanel properties.
$mixpanel.track(message, _.clone(data));
if (SettingsService.data.errorReporting) {
// Clone data before passing it to `mixpanel.track`
// since this function mutates the object adding
// some custom private Mixpanel properties.
$mixpanel.track(message, _.clone(data));
}
if (data) {
message += ` (${JSON.stringify(data)})`;

View File

@ -34,3 +34,7 @@ body {
overflow: auto;
-webkit-overflow-scrolling: touch;
}
button:focus {
outline: none !important;
}

View File

@ -26,6 +26,10 @@
</head>
<body ng-app="Etcher" ng-controller="AppController as app" style="display: none">
<div class="content row middle-xs space-horizontal-large" ng-hide="app.settings.isConfiguring()">
<button class="btn btn-link btn-navigation" ng-click="app.settings.enter()">
<span class="glyphicon glyphicon-cog"></span>
</button>
<div class="col-xs">
<div class="row around-xs space-bottom-huge" ng-hide="app.state.progress == 100 && !app.writer.isBurning()">
<div class="col-xs">

View File

@ -187,6 +187,6 @@ body {
.btn-navigation {
position: fixed;
top: 10px;
right: 15px;
right: 10px;
font-size: 15px;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 113 KiB

After

Width:  |  Height:  |  Size: 114 KiB