From 19ab2d7c82623515f36d620b7501b25e0fdd9eed Mon Sep 17 00:00:00 2001 From: Ramiro Saenz Date: Tue, 28 Aug 2018 16:15:30 -0300 Subject: [PATCH] Disable send anonymous usage statistics by default and added option in Preferences --- app/Application.js | 15 +++++++++++++++ app/view/preferences/Preferences.js | 6 ++++++ electron/main.js | 7 ++++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/app/Application.js b/app/Application.js index 32aed8e3..fd44edca 100644 --- a/app/Application.js +++ b/app/Application.js @@ -26,6 +26,21 @@ Ext.define('Rambox.Application', { } ,launch: function () { + // Prevent track if the user have disabled this option (default: false) + if ( !ipc.sendSync('sendStatistics') ) { + ga_storage = { + _enableSSL: Ext.emptyFn + ,_disableSSL: Ext.emptyFn + ,_setAccount: Ext.emptyFn + ,_setDomain: Ext.emptyFn + ,_setLocale: Ext.emptyFn + ,_setCustomVar: Ext.emptyFn + ,_deleteCustomVar: Ext.emptyFn + ,_trackPageview: Ext.emptyFn + ,_trackEvent: Ext.emptyFn + } + } + // Set Google Analytics events ga_storage._setAccount('UA-80680424-1'); ga_storage._trackPageview('/index.html', 'main'); diff --git a/app/view/preferences/Preferences.js b/app/view/preferences/Preferences.js index 5f5c1ffc..5e32aa14 100644 --- a/app/view/preferences/Preferences.js +++ b/app/view/preferences/Preferences.js @@ -337,6 +337,12 @@ Ext.define('Rambox.view.preferences.Preferences',{ } ] } + ,{ + xtype: 'checkbox' + ,name: 'sendStatistics' + ,boxLabel: locale['preferences[27]'] + ,value: config.sendStatistics + } ] } ]; diff --git a/electron/main.js b/electron/main.js index 3688498a..9c05582a 100644 --- a/electron/main.js +++ b/electron/main.js @@ -38,6 +38,7 @@ const config = new Config({ ,locale: 'en' ,enable_hidpi_support: false ,default_service: 'ramboxTab' + ,sendStatistics: false ,x: undefined ,y: undefined @@ -277,7 +278,7 @@ function updateBadge(title) { title = title.split(" - ")[0]; //Discard service name if present, could also contain digits var messageCount = title.match(/\d+/g) ? parseInt(title.match(/\d+/g).join("")) : 0; messageCount = isNaN(messageCount) ? 0 : messageCount; - + tray.setBadge(messageCount, config.get('systemtray_indicator')); if (process.platform === 'win32') { // Windows @@ -336,6 +337,10 @@ ipcMain.on('setConfig', function(event, values) { } }); +ipcMain.on('sendStatistics', function(event) { + event.returnValue = config.get('sendStatistics'); +}); + ipcMain.on('validateMasterPassword', function(event, pass) { if ( config.get('master_password') === require('crypto').createHash('md5').update(pass).digest('hex') ) { createWindow();