From d5ea47a9b247346b319c4e7976d3d79586cc9611 Mon Sep 17 00:00:00 2001 From: wlycdgr Date: Mon, 21 Sep 2020 13:59:25 -0400 Subject: [PATCH 01/22] Reduce scheduledTasks and autoUpdatedBugDb frequencies from once an hour to once a day --- src/background.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/background.js b/src/background.js index 4df749520..2b3fe0813 100644 --- a/src/background.js +++ b/src/background.js @@ -68,6 +68,7 @@ const IS_FIREFOX = (BROWSER_INFO.name === 'firefox'); const IS_ANDROID = (BROWSER_INFO.os === 'android'); const VERSION_CHECK_URL = `${CDN_BASE_URL}/update/version`; const REAL_ESTATE_ID = 'ghostery'; +const ONE_DAY_MSEC = 86400000; const onBeforeRequest = events.onBeforeRequest.bind(events); const { onHeadersReceived } = Events; @@ -1729,12 +1730,12 @@ function initializeGhosteryModules() { } // Check CMP and ABTest every hour. - setInterval(scheduledTasks, 3600000); + setInterval(scheduledTasks, ONE_DAY_MSEC); // Update db right away. autoUpdateBugDb(); // Schedule it to run every hour. - setInterval(autoUpdateBugDb, 3600000); + setInterval(autoUpdateBugDb, ONE_DAY_MSEC); // listen for changes to specific conf properties initializeDispatcher(); From 544043cf1ae0a3c366e415aa08025a8e1b9e23ba Mon Sep 17 00:00:00 2001 From: wlycdgr Date: Mon, 21 Sep 2020 14:07:50 -0400 Subject: [PATCH 02/22] Refactor autoUpdateBugDb so it always does the same thing when called with the same argument --- src/background.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/background.js b/src/background.js index 2b3fe0813..c3affb65e 100644 --- a/src/background.js +++ b/src/background.js @@ -146,8 +146,8 @@ function checkLibraryVersion() { * Check and fetch a new tracker library every hour as needed * @memberOf Background */ -function autoUpdateBugDb() { - if (conf.enable_autoupdate) { +function autoUpdateBugDb(isAutoUpdateEnabled) { + if (isAutoUpdateEnabled) { const result = conf.bugs_last_checked; const nowTime = Number((new Date()).getTime()); // offset by 15min so that we don't double fetch @@ -1733,9 +1733,10 @@ function initializeGhosteryModules() { setInterval(scheduledTasks, ONE_DAY_MSEC); // Update db right away. - autoUpdateBugDb(); + autoUpdateBugDb(conf.enable_autoupdate); + // Schedule it to run every hour. - setInterval(autoUpdateBugDb, ONE_DAY_MSEC); + setInterval(() => autoUpdateBugDb(conf.enable_autoupdate), ONE_DAY_MSEC); // listen for changes to specific conf properties initializeDispatcher(); From 9f2cf6c835ad4bcd5c4cf7a1e4b95863b9948b91 Mon Sep 17 00:00:00 2001 From: wlycdgr Date: Mon, 21 Sep 2020 14:12:38 -0400 Subject: [PATCH 03/22] Update autoUpdateBugDB documentation and refactor a little more to make sure it always does the same thing when called with the same args --- src/background.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/background.js b/src/background.js index c3affb65e..e04f84b97 100644 --- a/src/background.js +++ b/src/background.js @@ -143,15 +143,14 @@ function checkLibraryVersion() { } /** - * Check and fetch a new tracker library every hour as needed + * Check for db updates if auto updating is enabled and enough time has passed since the last check. * @memberOf Background */ -function autoUpdateBugDb(isAutoUpdateEnabled) { +function autoUpdateBugDb(isAutoUpdateEnabled, bugsLastChecked) { if (isAutoUpdateEnabled) { - const result = conf.bugs_last_checked; const nowTime = Number((new Date()).getTime()); // offset by 15min so that we don't double fetch - if (!result || nowTime > (Number(result) + 900000)) { + if (!bugsLastChecked || nowTime > (Number(bugsLastChecked) + 900000)) { log('autoUpdateBugDb called', new Date()); checkLibraryVersion(); } @@ -1733,10 +1732,13 @@ function initializeGhosteryModules() { setInterval(scheduledTasks, ONE_DAY_MSEC); // Update db right away. - autoUpdateBugDb(conf.enable_autoupdate); + autoUpdateBugDb(conf.enable_autoupdate, conf.bugs_last_checked); // Schedule it to run every hour. - setInterval(() => autoUpdateBugDb(conf.enable_autoupdate), ONE_DAY_MSEC); + setInterval( + () => autoUpdateBugDb(conf.enable_autoupdate, conf.bugs_last_checked), + ONE_DAY_MSEC + ); // listen for changes to specific conf properties initializeDispatcher(); From 568acea450aa18e1609d43e04811fb67fdfdbc6e Mon Sep 17 00:00:00 2001 From: wlycdgr Date: Mon, 21 Sep 2020 14:51:09 -0400 Subject: [PATCH 04/22] Clean up autoUpdateBugDB a bit more: Clarify docs, flatten, and move log statement to make sure that it is triggered every time the function is called, since the message just says that the function was called --- src/background.js | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/background.js b/src/background.js index e04f84b97..ce18f12d2 100644 --- a/src/background.js +++ b/src/background.js @@ -69,6 +69,7 @@ const IS_ANDROID = (BROWSER_INFO.os === 'android'); const VERSION_CHECK_URL = `${CDN_BASE_URL}/update/version`; const REAL_ESTATE_ID = 'ghostery'; const ONE_DAY_MSEC = 86400000; +const ONE_HOUR_MSEC = 3600000; const onBeforeRequest = events.onBeforeRequest.bind(events); const { onHeadersReceived } = Events; @@ -143,17 +144,27 @@ function checkLibraryVersion() { } /** - * Check for db updates if auto updating is enabled and enough time has passed since the last check. + * Call checkLibraryVersion if auto updating is enabled and enough time has passed since the last check. + * Do nothing otherwise. + * * @memberOf Background + * + * @param {Boolean} isAutoUpdateEnabled True if bug db auto updating is enabled in conf. False otherwise. + * @param {Number} bugsLastCheckedMsec The Unix msec timestamp to compare against to see whether to call checkLibraryVersion again. + * */ -function autoUpdateBugDb(isAutoUpdateEnabled, bugsLastChecked) { - if (isAutoUpdateEnabled) { - const nowTime = Number((new Date()).getTime()); - // offset by 15min so that we don't double fetch - if (!bugsLastChecked || nowTime > (Number(bugsLastChecked) + 900000)) { - log('autoUpdateBugDb called', new Date()); - checkLibraryVersion(); - } +function autoUpdateBugDb(isAutoUpdateEnabled, bugsLastCheckedMsec) { + const date = new Date(); + + log('autoUpdateBugDb called', date); + + if (!isAutoUpdateEnabled) return; + + if ( + !bugsLastCheckedMsec + || date.getTime() > (Number(bugsLastCheckedMsec) + ONE_HOUR_MSEC) // guard against double fetching + ) { + checkLibraryVersion(); } } From 5c624b3f3f945f6425a4759100f8ae048feff1ec Mon Sep 17 00:00:00 2001 From: wlycdgr Date: Mon, 21 Sep 2020 14:55:45 -0400 Subject: [PATCH 05/22] Minor comment in autoUpdateBugDb --- src/background.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/background.js b/src/background.js index ce18f12d2..9d7578747 100644 --- a/src/background.js +++ b/src/background.js @@ -161,7 +161,7 @@ function autoUpdateBugDb(isAutoUpdateEnabled, bugsLastCheckedMsec) { if (!isAutoUpdateEnabled) return; if ( - !bugsLastCheckedMsec + !bugsLastCheckedMsec // the value is 0, signifying that we have never checked yet || date.getTime() > (Number(bugsLastCheckedMsec) + ONE_HOUR_MSEC) // guard against double fetching ) { checkLibraryVersion(); From ef45c824cf98e785c9916fce7704fdaef525e7a1 Mon Sep 17 00:00:00 2001 From: wlycdgr Date: Mon, 21 Sep 2020 15:12:02 -0400 Subject: [PATCH 06/22] Renamed autoUpdateBugDb to clarify connection to checkLibraryVersion. Tweak docs. --- src/background.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/background.js b/src/background.js index 9d7578747..dd2cd1086 100644 --- a/src/background.js +++ b/src/background.js @@ -145,15 +145,15 @@ function checkLibraryVersion() { /** * Call checkLibraryVersion if auto updating is enabled and enough time has passed since the last check. - * Do nothing otherwise. + * Debug log that the function was called and when. * * @memberOf Background * - * @param {Boolean} isAutoUpdateEnabled True if bug db auto updating is enabled in conf. False otherwise. + * @param {Boolean} isAutoUpdateEnabled Whether bug db auto updating is enabled. * @param {Number} bugsLastCheckedMsec The Unix msec timestamp to compare against to see whether to call checkLibraryVersion again. * */ -function autoUpdateBugDb(isAutoUpdateEnabled, bugsLastCheckedMsec) { +function checkLibraryVersionIfNeeded(isAutoUpdateEnabled, bugsLastCheckedMsec) { const date = new Date(); log('autoUpdateBugDb called', date); @@ -1743,11 +1743,11 @@ function initializeGhosteryModules() { setInterval(scheduledTasks, ONE_DAY_MSEC); // Update db right away. - autoUpdateBugDb(conf.enable_autoupdate, conf.bugs_last_checked); + checkLibraryVersionIfNeeded(conf.enable_autoupdate, conf.bugs_last_checked); // Schedule it to run every hour. setInterval( - () => autoUpdateBugDb(conf.enable_autoupdate, conf.bugs_last_checked), + () => checkLibraryVersionIfNeeded(conf.enable_autoupdate, conf.bugs_last_checked), ONE_DAY_MSEC ); From ad2093110cb9e19241fe47959f104ab99d72c3a0 Mon Sep 17 00:00:00 2001 From: wlycdgr Date: Mon, 21 Sep 2020 15:22:35 -0400 Subject: [PATCH 07/22] Edit db update function names and docs to improve clarity --- src/background.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/background.js b/src/background.js index dd2cd1086..fb8333330 100644 --- a/src/background.js +++ b/src/background.js @@ -105,12 +105,12 @@ function setCliqzModuleEnabled(module, enabled) { /** * Pulls down latest version.json and triggers - * updates of all db files. + * updates of all db files. FKA checkLibraryVersion. * @memberOf Background * * @return {Promise} database updated data */ -function checkLibraryVersion() { +function updateDBs() { return new Promise(((resolve, reject) => { const failed = { success: false, updated: false }; utils.getJson(VERSION_CHECK_URL).then((data) => { @@ -137,26 +137,25 @@ function checkLibraryVersion() { }); }); }).catch((err) => { - log('Error in checkLibraryVersion', err); + log('Error in updateDBs', err); reject(failed); }); })); } /** - * Call checkLibraryVersion if auto updating is enabled and enough time has passed since the last check. - * Debug log that the function was called and when. + * Call updateDBs if auto updating is enabled and enough time has passed since the last check. + * Debug log that the function was called and when. Called at browser startup and at regular intervals thereafter. * * @memberOf Background * * @param {Boolean} isAutoUpdateEnabled Whether bug db auto updating is enabled. - * @param {Number} bugsLastCheckedMsec The Unix msec timestamp to compare against to see whether to call checkLibraryVersion again. - * + * @param {Number} bugsLastCheckedMsec The Unix msec timestamp to check against to make sure it is not too soon to call updateDBs again. */ -function checkLibraryVersionIfNeeded(isAutoUpdateEnabled, bugsLastCheckedMsec) { +function autoUpdateDBs(isAutoUpdateEnabled, bugsLastCheckedMsec) { const date = new Date(); - log('autoUpdateBugDb called', date); + log('autoUpdateDBs called', date); if (!isAutoUpdateEnabled) return; @@ -164,7 +163,7 @@ function checkLibraryVersionIfNeeded(isAutoUpdateEnabled, bugsLastCheckedMsec) { !bugsLastCheckedMsec // the value is 0, signifying that we have never checked yet || date.getTime() > (Number(bugsLastCheckedMsec) + ONE_HOUR_MSEC) // guard against double fetching ) { - checkLibraryVersion(); + updateDBs(); } } @@ -968,7 +967,7 @@ function onMessageHandler(request, sender, callback) { return true; } if (name === 'update_database') { - checkLibraryVersion().then((result) => { + updateDBs().then((result) => { callback(result); }); return true; @@ -1743,11 +1742,11 @@ function initializeGhosteryModules() { setInterval(scheduledTasks, ONE_DAY_MSEC); // Update db right away. - checkLibraryVersionIfNeeded(conf.enable_autoupdate, conf.bugs_last_checked); + autoUpdateDBs(conf.enable_autoupdate, conf.bugs_last_checked); // Schedule it to run every hour. setInterval( - () => checkLibraryVersionIfNeeded(conf.enable_autoupdate, conf.bugs_last_checked), + () => autoUpdateDBs(conf.enable_autoupdate, conf.bugs_last_checked), ONE_DAY_MSEC ); From c761b7cb02ad0da4c77fe237119fe4bfb1450be6 Mon Sep 17 00:00:00 2001 From: wlycdgr Date: Mon, 21 Sep 2020 17:52:19 -0400 Subject: [PATCH 08/22] Remove Cliqz anti-tracking A/B test config code from background. Tidy up setupAbTest --- src/background.js | 47 +++++++---------------------------------------- 1 file changed, 7 insertions(+), 40 deletions(-) diff --git a/src/background.js b/src/background.js index fb8333330..c2a6b31dc 100644 --- a/src/background.js +++ b/src/background.js @@ -1088,38 +1088,6 @@ function onMessageHandler(request, sender, callback) { return false; } -/** - * Determine Antitracking configuration parameters based - * on the results returned from the abtest endpoint. - * @memberOf Background - * - * @return {Object} Antitracking configuration parameters - */ -function getAntitrackingTestConfig() { - if (abtest.hasTest('antitracking_full')) { - return { - qsEnabled: true, - telemetryMode: 2, - }; - } - if (abtest.hasTest('antitracking_half')) { - return { - qsEnabled: true, - telemetryMode: 1, - }; - } - if (abtest.hasTest('antitracking_collect')) { - return { - qsEnabled: false, - telemetryMode: 1, - }; - } - return { - qsEnabled: true, - telemetryMode: 1, - }; -} - /** * Set option for Hub promo A/B/C test based * on the results returned from the abtest endpoint. @@ -1149,18 +1117,17 @@ function setupHubPromoABTest() { * of ABTest and availability of Human Web. */ function setupABTest() { - const antitrackingConfig = getAntitrackingTestConfig(); - if (antitrackingConfig && conf.enable_anti_tracking) { - if (!conf.enable_human_web) { - // force disable anti-tracking telemetry on humanweb opt-out - antitrackingConfig.telemetryMode = 0; - } - Object.keys(antitrackingConfig).forEach((opt) => { - const val = antitrackingConfig[opt]; + if (conf.enable_anti_tracking) { + const antitrackingConfig = { + qsEnabled: true, + telemetryMode: conf.enable_human_web ? 1 : 0, + }; + Object.entries(antitrackingConfig).forEach(([opt, val]) => { log('antitracking', 'set config option', opt, val); antitracking.action('setConfigOption', opt, val); }); } + if (abtest.hasTest('antitracking_whitelist2')) { cliqz.prefs.set('attrackBloomFilter', false); } From b0a54c5e813b26d8276e53e02a206619e8fa69b8 Mon Sep 17 00:00:00 2001 From: wlycdgr Date: Mon, 21 Sep 2020 19:05:55 -0400 Subject: [PATCH 09/22] Split up and reorganize setupABTest so outside code can only call those parts of the original it actually needs. --- src/background.js | 58 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/src/background.js b/src/background.js index c2a6b31dc..9fbf894e3 100644 --- a/src/background.js +++ b/src/background.js @@ -1113,28 +1113,48 @@ function setupHubPromoABTest() { } /** - * Adjust antitracking parameters based on the current state - * of ABTest and availability of Human Web. + * @since 8.5.3 + * + * Setup the Bloom Filter `antitracking_whitelist2` test. + * @memberOf Background */ -function setupABTest() { - if (conf.enable_anti_tracking) { - const antitrackingConfig = { - qsEnabled: true, - telemetryMode: conf.enable_human_web ? 1 : 0, - }; - Object.entries(antitrackingConfig).forEach(([opt, val]) => { - log('antitracking', 'set config option', opt, val); - antitracking.action('setConfigOption', opt, val); - }); - } - +function setupBloomFilterABTest() { if (abtest.hasTest('antitracking_whitelist2')) { cliqz.prefs.set('attrackBloomFilter', false); } +} +/** + * Configure A/B tests based on data fetched from the A/B servecr + * @memberOf Background + */ +function setupABTests() { + setupBloomFilterABTest(); setupHubPromoABTest(); } +/** + * @since 8.5.3 + * + * Update config options for the Cliqz antitracking module to match the current human web setting. + * Log out the updates. Returns without doing anything if antitracking is disabled. + * + * @param {Boolean} isAntitrackingEnabled Whether antitracking is currently enabled. + */ +function setCliqzAntitrackingConfig(isAntitrackingEnabled) { + if (!isAntitrackingEnabled) return; + + const antitrackingConfig = { + qsEnabled: true, + telemetryMode: conf.enable_human_web ? 1 : 0, + }; + + Object.entries(antitrackingConfig).forEach(([opt, val]) => { + log('antitracking', 'set config option', opt, val); + antitracking.action('setConfigOption', opt, val); + }); +} + /** * Initialize Dispatcher Events. * All Conf properties trigger a dispatcher pub event @@ -1161,7 +1181,7 @@ function initializeDispatcher() { dispatcher.on('conf.save.enable_human_web', (enableHumanWeb) => { if (!IS_CLIQZ) { setCliqzModuleEnabled(humanweb, enableHumanWeb).then(() => { - setupABTest(); + setCliqzAntitrackingConfig(conf.enable_anti_tracking); }); } else { setCliqzModuleEnabled(humanweb, false); @@ -1187,7 +1207,11 @@ function initializeDispatcher() { }); dispatcher.on('conf.save.enable_anti_tracking', (enableAntitracking) => { if (!IS_CLIQZ) { - setCliqzModuleEnabled(antitracking, enableAntitracking); + setCliqzModuleEnabled(antitracking, enableAntitracking).then(() => { + // enable_human_web could have been toggled while antitracking was off, + // so we want to make sure to update the antitracking telemetry option + setCliqzAntitrackingConfig(conf.enable_anti_tracking); + }); } else { setCliqzModuleEnabled(antitracking, false); } @@ -1693,7 +1717,7 @@ function initializeGhosteryModules() { // auto-fetch human web offer abtest.fetch() .then(() => { - setupABTest(); + setupABTests(); }) .catch(() => { log('Unable to reach abtest server'); From c563a1d49f2f9289bd32c7d6d4d0128c103945b9 Mon Sep 17 00:00:00 2001 From: wlycdgr Date: Tue, 22 Sep 2020 16:35:26 -0400 Subject: [PATCH 10/22] Clean up OptIn a bit in preparation for adding A/B test checkbox --- app/panel/components/Settings/OptIn.jsx | 98 ++++++++++++++----------- 1 file changed, 56 insertions(+), 42 deletions(-) diff --git a/app/panel/components/Settings/OptIn.jsx b/app/panel/components/Settings/OptIn.jsx index f74262c0b..3ff695f8d 100644 --- a/app/panel/components/Settings/OptIn.jsx +++ b/app/panel/components/Settings/OptIn.jsx @@ -18,62 +18,76 @@ import globals from '../../../../src/classes/Globals'; const { IS_CLIQZ, BROWSER_INFO } = globals; const IS_ANDROID = (BROWSER_INFO.os === 'android'); +const TOOLTIP_SVG_FILEPATH = '../../app/images/panel/icon-information-tooltip.svg'; + /** * @class Implement Opt In subview as a React component. * The view opens from the left-side menu of the main Settings view. * It invites user to opt in for telemetry options, human web and offers * @memberOf SettingsComponents */ -const OptIn = ({ settingsData, toggleCheckbox }) => ( -
-
-
-

{ t('settings_support_ghostery') }

-
- { t('settings_support_ghostery_by') } - : -
-
-
- - -
- -
-
-
- {!IS_CLIQZ && ( -
+const OptIn = ({ settingsData, toggleCheckbox }) => { + const checkbox = (id, name) => ( + + ); + + const labelFor = inputId => ( + + ); + + return ( +
+
+
+

{t('settings_support_ghostery')}

+
+ {t('settings_support_ghostery_by')} + : +
+
- - -
- + {checkbox('settings-share-usage', 'enable_metrics')} + {labelFor('settings-share-usage')} +
+
- )} - {!IS_CLIQZ && !IS_ANDROID && ( -
-
- - -
- + {!IS_CLIQZ && ( +
+
+ {checkbox('settings-share-usage', 'enable_human_web')} + {labelFor('settings-share-human-web')} +
+ +
-
- )} + )} + {!IS_CLIQZ && !IS_ANDROID && ( +
+
+ {checkbox('settings-allow-offers', 'enable_offers')} + {labelFor('settings-allow-offers')} +
+ +
+
+
+ )} +
-
-); + ); +}; OptIn.propTypes = { toggleCheckbox: PropTypes.func.isRequired, From 89d6e0f829254e438b9635d4bfac4cecf9106097 Mon Sep 17 00:00:00 2001 From: wlycdgr Date: Tue, 22 Sep 2020 17:17:58 -0400 Subject: [PATCH 11/22] Finish OptIn tidy-up --- app/panel/components/Settings/OptIn.jsx | 70 +++++++++++++------------ 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/app/panel/components/Settings/OptIn.jsx b/app/panel/components/Settings/OptIn.jsx index 3ff695f8d..47818dcc1 100644 --- a/app/panel/components/Settings/OptIn.jsx +++ b/app/panel/components/Settings/OptIn.jsx @@ -27,22 +27,38 @@ const TOOLTIP_SVG_FILEPATH = '../../app/images/panel/icon-information-tooltip.sv * @memberOf SettingsComponents */ const OptIn = ({ settingsData, toggleCheckbox }) => { - const checkbox = (id, name) => ( + const checkbox = (opt, name) => ( ); - const labelFor = inputId => ( -
From 2d42906fead2e142922c580ae5bb957401b2662b Mon Sep 17 00:00:00 2001 From: wlycdgr Date: Wed, 23 Sep 2020 09:59:02 -0400 Subject: [PATCH 13/22] Implement the enable_abtests conf setting and plug it into the checkbox stub in OptIn --- app/panel/components/Settings/OptIn.jsx | 5 +++-- src/classes/ConfData.js | 1 + src/classes/Globals.js | 1 + src/classes/Metrics.js | 1 + src/classes/PanelData.js | 3 ++- 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/panel/components/Settings/OptIn.jsx b/app/panel/components/Settings/OptIn.jsx index f833268d3..e84546329 100644 --- a/app/panel/components/Settings/OptIn.jsx +++ b/app/panel/components/Settings/OptIn.jsx @@ -85,8 +85,8 @@ const OptIn = ({ settingsData, toggleCheckbox }) => { tooltipSVG(t('settings_offers_tooltip'), 'up'), 'offers-section' )} - {!IS_CLIQZ && option( - checkbox('allow-abtests', true), + {option( + checkbox('allow-abtests', 'enable_abtests'), labelFor('allow-abtests', t('settings_allow_abtests')), tooltipSVG(t('settings_abtests_tooltip'), 'up'), 'abtests-section' @@ -103,6 +103,7 @@ OptIn.propTypes = { enable_metrics: PropTypes.bool.isRequired, enable_human_web: PropTypes.bool.isRequired, enable_offers: PropTypes.bool.isRequired, + enable_abtests: PropTypes.bool.isRequired, }).isRequired, }; diff --git a/src/classes/ConfData.js b/src/classes/ConfData.js index f50f64145..990db8cd4 100644 --- a/src/classes/ConfData.js +++ b/src/classes/ConfData.js @@ -113,6 +113,7 @@ class ConfData { _initProperty('enable_human_web', !IS_CLIQZ && !IS_FIREFOX); _initProperty('enable_metrics', false); _initProperty('enable_offers', !IS_CLIQZ && !IS_FIREFOX && !IS_ANDROID); + _initProperty('enable_abtests', true); _initProperty('enable_smart_block', true); _initProperty('expand_all_trackers', true); _initProperty('hide_alert_trusted', false); diff --git a/src/classes/Globals.js b/src/classes/Globals.js index bbbbe3477..93341a0f6 100644 --- a/src/classes/Globals.js +++ b/src/classes/Globals.js @@ -111,6 +111,7 @@ class Globals { 'enable_human_web', 'enable_metrics', 'enable_offers', + 'enable_abtests', 'enable_smart_block', 'expand_all_trackers', 'hide_alert_trusted', diff --git a/src/classes/Metrics.js b/src/classes/Metrics.js index 2efe7b1a8..67a6f0ece 100644 --- a/src/classes/Metrics.js +++ b/src/classes/Metrics.js @@ -279,6 +279,7 @@ class Metrics { 'enable_offers', 'account', 'enable_metrics', + 'enable_abtests', 'show_alert', 'alert_expanded', 'show_cmp' diff --git a/src/classes/PanelData.js b/src/classes/PanelData.js index ef103dca6..eb2734ff3 100644 --- a/src/classes/PanelData.js +++ b/src/classes/PanelData.js @@ -501,7 +501,7 @@ class PanelData { const { alert_bubble_pos, alert_bubble_timeout, block_by_default, cliqz_adb_mode, enable_autoupdate, enable_click2play, enable_click2play_social, enable_human_web, enable_offers, - enable_metrics, hide_alert_trusted, ignore_first_party, notify_library_updates, + enable_metrics, enable_abtests, hide_alert_trusted, ignore_first_party, notify_library_updates, notify_promotions, notify_upgrade_updates, selected_app_ids, show_alert, show_badge, show_cmp, show_tracker_urls, toggle_individual_trackers } = userSettingsSource; @@ -517,6 +517,7 @@ class PanelData { enable_human_web, enable_offers, enable_metrics, + enable_abtests, hide_alert_trusted, ignore_first_party, notify_library_updates, From 1f3a03f3635f62e826b64c7f2de7d3821ec1f2d5 Mon Sep 17 00:00:00 2001 From: wlycdgr Date: Wed, 23 Sep 2020 10:07:16 -0400 Subject: [PATCH 14/22] Do not call setupABTests if enable_abtests is false --- src/background.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/background.js b/src/background.js index 32281b8e8..ab92673c7 100644 --- a/src/background.js +++ b/src/background.js @@ -1711,7 +1711,7 @@ function initializeGhosteryModules() { // auto-fetch human web offer abtest.fetch() .then(() => { - setupABTests(); + if (conf.enable_abtests) setupABTests(); }) .catch(() => { log('Unable to reach abtest server'); From cba107f2ba1e4579ba6f4195b71bff6e0b3b994a Mon Sep 17 00:00:00 2001 From: wlycdgr Date: Wed, 23 Sep 2020 10:08:28 -0400 Subject: [PATCH 15/22] Skip the call to the AB server altogether if ab tests are disabled --- src/background.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/background.js b/src/background.js index ab92673c7..9d7c4b45c 100644 --- a/src/background.js +++ b/src/background.js @@ -1707,11 +1707,11 @@ function initializeGhosteryModules() { // auto-fetch from CMP cmp.fetchCMPData(); - if (!IS_CLIQZ) { + if (!IS_CLIQZ && conf.enable_abtests) { // auto-fetch human web offer abtest.fetch() .then(() => { - if (conf.enable_abtests) setupABTests(); + setupABTests(); }) .catch(() => { log('Unable to reach abtest server'); From f369ad2c19ec8f26fecda67882a09b45d77b7693 Mon Sep 17 00:00:00 2001 From: wlycdgr Date: Wed, 23 Sep 2020 10:57:56 -0400 Subject: [PATCH 16/22] Update AB test setting tooltip copy. remove enable_abtests from uninstall URL. Add ts metrics query string param for whether tests are enabled. Disabled sending other AB test query string params unless tests are enabled. --- _locales/en/messages.json | 2 +- src/classes/Metrics.js | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 8d9e1c39b..ceb9eafaf 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1041,7 +1041,7 @@ "message": "Ghostery Rewards is a private-by-design feature that delivers you discounts and special offers from our partner companies as you browse." }, "settings_abtests_tooltip": { - "message": "Participating in A/B tests helps Ghostery understand which version of a new layout or feature users like you prefer. The testing mechanism uses a random number generated on install to determine which version of a beta feature you see." + "message": "Participating in randomized A/B tests helps Ghostery understand which version of a new layout or feature users like you prefer." }, "settings_opt_in": { "message": "Opt In / Out" diff --git a/src/classes/Metrics.js b/src/classes/Metrics.js index 67a6f0ece..378cceaa5 100644 --- a/src/classes/Metrics.js +++ b/src/classes/Metrics.js @@ -15,6 +15,7 @@ import globals from './Globals'; import conf from './Conf'; import { log, prefsSet, prefsGet } from '../utils/common'; import { getActiveTab, processUrlQuery } from '../utils/utils'; +import { getPunycodeEncoded } from '@cliqz/url-parser'; // CONSTANTS const FREQUENCIES = { // in milliseconds @@ -279,7 +280,6 @@ class Metrics { 'enable_offers', 'account', 'enable_metrics', - 'enable_abtests', 'show_alert', 'alert_expanded', 'show_cmp' @@ -370,12 +370,19 @@ class Metrics { `&th=${encodeURIComponent(Metrics._getThemeValue().toString())}` + // New parameters for Ghostery 8.5.2 - // Hub Layout View - `&t2=${encodeURIComponent(Metrics._getHubLayoutView().toString())}` + // Subscription Interval `&si=${encodeURIComponent(Metrics._getSubscriptionInterval().toString())}` + // Product ID Parameter - `&pi=${encodeURIComponent('gbe')}`; + `&pi=${encodeURIComponent('gbe')}` + + + // New parameter for Ghostery 8.5.3 + // AB tests enabled? + `&ts=${encodeURIComponent(conf.enable_abtests ? '1' : '0')}`; + + if (conf.enable_abtests) { + // Hub Layout A/B test. Added in 8.5.3. GH-2097, GH-2100 + metrics_url += `&t2=${encodeURIComponent(Metrics._getHubLayoutView().toString())}`; + } if (CAMPAIGN_METRICS.includes(type)) { // only send campaign attribution when necessary From a0f0f0c786edf59f6657ecc8e9bb90dc851abfb1 Mon Sep 17 00:00:00 2001 From: wlycdgr Date: Wed, 23 Sep 2020 12:10:25 -0400 Subject: [PATCH 17/22] Remove unused import from Metrics --- src/classes/Metrics.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/classes/Metrics.js b/src/classes/Metrics.js index 378cceaa5..9907ad27c 100644 --- a/src/classes/Metrics.js +++ b/src/classes/Metrics.js @@ -15,7 +15,6 @@ import globals from './Globals'; import conf from './Conf'; import { log, prefsSet, prefsGet } from '../utils/common'; import { getActiveTab, processUrlQuery } from '../utils/utils'; -import { getPunycodeEncoded } from '@cliqz/url-parser'; // CONSTANTS const FREQUENCIES = { // in milliseconds From fa54859f6f9df80265d2f0c2c70346bdbae99d60 Mon Sep 17 00:00:00 2001 From: wlycdgr Date: Wed, 23 Sep 2020 12:12:56 -0400 Subject: [PATCH 18/22] Update test snapshot --- .../__tests__/__snapshots__/OptIn.jsx.snap | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/app/panel/components/Settings/__tests__/__snapshots__/OptIn.jsx.snap b/app/panel/components/Settings/__tests__/__snapshots__/OptIn.jsx.snap index 3953f909d..c30d04ec8 100644 --- a/app/panel/components/Settings/__tests__/__snapshots__/OptIn.jsx.snap +++ b/app/panel/components/Settings/__tests__/__snapshots__/OptIn.jsx.snap @@ -19,6 +19,7 @@ exports[`app/panel/Settings/OptIn.jsx Snapshot tests with react-test-renderer Op
+
+
+ + +
+ +
+
+
@@ -136,6 +168,7 @@ exports[`app/panel/Settings/OptIn.jsx Snapshot tests with react-test-renderer Op
+
+
+ + +
+ +
+
+
From 004506b90ec45706c6e0475235b15a8ce9dc81db Mon Sep 17 00:00:00 2001 From: wlycdgr Date: Wed, 23 Sep 2020 19:37:16 -0400 Subject: [PATCH 19/22] Fix typo --- src/background.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/background.js b/src/background.js index 9d7c4b45c..49fda2216 100644 --- a/src/background.js +++ b/src/background.js @@ -1119,7 +1119,7 @@ function setupBloomFilterABTest() { } /** - * Configure A/B tests based on data fetched from the A/B servecr + * Configure A/B tests based on data fetched from the A/B server * @memberOf Background */ function setupABTests() { From 98644ff27693391f28e830ce2be38610ef625ea9 Mon Sep 17 00:00:00 2001 From: wlycdgr Date: Wed, 23 Sep 2020 19:41:22 -0400 Subject: [PATCH 20/22] Fix comment errors --- src/background.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/background.js b/src/background.js index 49fda2216..dc5d2062e 100644 --- a/src/background.js +++ b/src/background.js @@ -1723,13 +1723,13 @@ function initializeGhosteryModules() { }); } - // Check CMP and ABTest every hour. + // Check CMP and ABTest every day. setInterval(scheduledTasks, ONE_DAY_MSEC); // Update db right away. autoUpdateDBs(conf.enable_autoupdate, conf.bugs_last_checked); - // Schedule it to run every hour. + // Schedule it to run every day. setInterval( () => autoUpdateDBs(conf.enable_autoupdate, conf.bugs_last_checked), ONE_DAY_MSEC From 9f6b99d383a08ac1f26ee9609a05429225f3d8b1 Mon Sep 17 00:00:00 2001 From: wlycdgr Date: Thu, 24 Sep 2020 12:47:02 -0400 Subject: [PATCH 21/22] Remove bloom filter Cliqz test --- src/background.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/background.js b/src/background.js index dc5d2062e..2e879416e 100644 --- a/src/background.js +++ b/src/background.js @@ -1106,24 +1106,11 @@ function setupHubLayoutABTest() { } } -/** - * @since 8.5.3 - * - * Setup the Bloom Filter `antitracking_whitelist2` test. - * @memberOf Background - */ -function setupBloomFilterABTest() { - if (abtest.hasTest('antitracking_whitelist2')) { - cliqz.prefs.set('attrackBloomFilter', false); - } -} - /** * Configure A/B tests based on data fetched from the A/B server * @memberOf Background */ function setupABTests() { - setupBloomFilterABTest(); setupHubLayoutABTest(); } From f1b4835a44b1adf809291f06f7214c79852a72bb Mon Sep 17 00:00:00 2001 From: Christopher Tino Date: Thu, 24 Sep 2020 16:38:04 -0400 Subject: [PATCH 22/22] remove comment --- src/background.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/background.js b/src/background.js index 2e879416e..f1a51a4de 100644 --- a/src/background.js +++ b/src/background.js @@ -1695,7 +1695,6 @@ function initializeGhosteryModules() { cmp.fetchCMPData(); if (!IS_CLIQZ && conf.enable_abtests) { - // auto-fetch human web offer abtest.fetch() .then(() => { setupABTests();