diff --git a/app/hub/Views/HomeView/HomeViewContainer.jsx b/app/hub/Views/HomeView/HomeViewContainer.jsx
index 380d9e3cd..b1d43fced 100644
--- a/app/hub/Views/HomeView/HomeViewContainer.jsx
+++ b/app/hub/Views/HomeView/HomeViewContainer.jsx
@@ -119,9 +119,9 @@ class HomeViewContainer extends Component {
} = home;
// Flag to display promo modal (used in A/B testing)
- const shouldShowPromoModal = false;
+ const { pm } = QueryString.parse(window.location.search);
// Logic to display premium modal if it is the case that it is being shown once per hub refresh to non-premium users
- const showPromoModal = shouldShowPromoModal && !premium_promo_modal_shown && !isPremium;
+ const showPromoModal = pm && pm === 'true' && !premium_promo_modal_shown && !isPremium;
return (
diff --git a/manifest.json b/manifest.json
index 592a97f63..1883c2363 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,5 +1,7 @@
{
"manifest_version": 2,
+ "debug": true,
+ "log": true,
"author": "Ghostery",
"name": "__MSG_name__",
"short_name": "Ghostery",
diff --git a/src/background.js b/src/background.js
index d12c5ee59..3acd6b4c0 100644
--- a/src/background.js
+++ b/src/background.js
@@ -1082,6 +1082,25 @@ function getAntitrackingTestConfig() {
};
}
+/**
+ * Set option for Hub promo A/B/C test based
+ * on the results returned from the abtest endpoint.
+ * @memberOf Background
+ *
+ * @return {Object} Hub promotion configuration parameters
+ */
+function setupHubPromoABTest() {
+ if (conf.hub_promo_variant !== 'not_yet_set') return;
+
+ if (abtest.hasTest('hub_plain')) {
+ conf.hub_promo_variant = 'plain';
+ } else if (abtest.hasTest('hub_midnight')) {
+ conf.hub_promo_variant = 'midnight';
+ } else {
+ conf.hub_promo_variant = 'upgrade';
+ }
+}
+
/**
* Adjust antitracking parameters based on the current state
* of ABTest and availability of Human Web.
@@ -1110,6 +1129,8 @@ function setupABTest() {
// cliqz.disableModule('search');
// cliqz.disableModule('overlay');
// }
+
+ setupHubPromoABTest();
}
/**
@@ -1598,12 +1619,6 @@ function initializeGhosteryModules() {
setTimeout(() => {
metrics.ping('install_complete');
}, 300000);
-
- // open the Ghostery Hub on install with justInstalled query parameter set to true
- chrome.tabs.create({
- url: chrome.runtime.getURL('./app/templates/hub.html?justInstalled=true'),
- active: true
- });
} else {
// Record install if the user previously closed the browser before the install ping fired
metrics.ping('install');
@@ -1668,17 +1683,24 @@ function initializeGhosteryModules() {
// Set these tasks to run every hour
function scheduledTasks() {
- // auto-fetch from CMP
- cmp.fetchCMPData();
+ return new Promise((resolve) => {
+ // auto-fetch from CMP
+ cmp.fetchCMPData();
- if (!IS_CLIQZ) {
- // auto-fetch human web offer
- abtest.fetch().then(() => {
- setupABTest();
- }).catch(() => {
- log('Unable to reach abtest server');
- });
- }
+ if (!IS_CLIQZ) {
+ // auto-fetch human web offer
+ abtest.fetch()
+ .then(() => {
+ setupABTest();
+ })
+ .catch(() => {
+ log('Unable to reach abtest server');
+ })
+ .finally(() => resolve());
+ } else {
+ resolve();
+ }
+ });
}
// Check CMP and ABTest every hour.
@@ -1712,7 +1734,19 @@ function initializeGhosteryModules() {
cliqzStartup,
]).then(() => {
// run scheduledTasks on init
- scheduledTasks();
+ scheduledTasks().then(() => {
+ // open the Ghostery Hub on install with justInstalled query parameter set to true
+ // we need to do this after running scheduledTasks for the first time
+ // because of an A/B test that determines which promo variant is shown in the Hub on install
+ if (globals.JUST_INSTALLED) {
+ const route = (conf.hub_promo_variant === 'upgrade' || conf.hub_promo_variant === 'not_yet_set') ? '' : '#home';
+ const showPremiumPromoModal = conf.hub_promo_variant === 'midnight';
+ chrome.tabs.create({
+ url: chrome.runtime.getURL(`./app/templates/hub.html?$justInstalled=true&pm=${showPremiumPromoModal}${route}`),
+ active: true
+ });
+ }
+ });
});
}
diff --git a/src/classes/ConfData.js b/src/classes/ConfData.js
index ffdc87225..7c49a60b8 100644
--- a/src/classes/ConfData.js
+++ b/src/classes/ConfData.js
@@ -115,6 +115,7 @@ class ConfData {
_initProperty('enable_smart_block', true);
_initProperty('expand_all_trackers', true);
_initProperty('hide_alert_trusted', false);
+ _initProperty('hub_promo_variant', 'not_yet_set');
_initProperty('ignore_first_party', true);
_initProperty('import_callout_dismissed', true);
_initProperty('insights_promo_modal_last_seen', 0);
diff --git a/src/classes/Metrics.js b/src/classes/Metrics.js
index fb34f64f0..13a1efa62 100644
--- a/src/classes/Metrics.js
+++ b/src/classes/Metrics.js
@@ -366,7 +366,11 @@ class Metrics {
// Engaged Velocity
`&ve=${encodeURIComponent(Metrics._getVelocityEngaged(type).toString())}` +
// Theme
- `&th=${encodeURIComponent(Metrics._getThemeValue().toString())}`;
+ `&th=${encodeURIComponent(Metrics._getThemeValue().toString())}` +
+
+ // New parameter for Ghostery 8.5.2
+ // Hub Promo variant
+ `&hp=${encodeURIComponent(Metrics._getHubPromoVariant().toString())}`;
if (CAMPAIGN_METRICS.includes(type)) {
// only send campaign attribution when necessary
@@ -525,6 +529,27 @@ class Metrics {
}
}
+ /**
+ * Get the Int associated with the Hub promo variant shown on install
+ * @private
+ * @return {number} Int associated with the Hub promo variant
+ */
+ static _getHubPromoVariant() {
+ const { hub_promo_variant } = conf;
+
+ switch (hub_promo_variant) {
+ case 'upgrade':
+ return 1;
+ case 'plain':
+ return 2;
+ case 'midnight':
+ return 3;
+ case 'not_yet_set':
+ default:
+ return 0;
+ }
+ }
+
/**
* Calculate remaining scheduled time for a ping
*