Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-2071/Hub-promo-abc-test #583

Merged
merged 9 commits into from Jul 20, 2020
@@ -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 (
<div className="full-height">
@@ -1,5 +1,7 @@
{
"manifest_version": 2,
"debug": true,
"log": true,
"author": "Ghostery",
"name": "__MSG_name__",
"short_name": "Ghostery",
@@ -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
});
}
});
});
}

@@ -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);
@@ -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
*
ProTip! Use n and p to navigate between commits in a pull request.