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-1983: Handle opt-in settings for legacy users on FF #518

Merged
merged 2 commits into from Mar 30, 2020
Merged
Changes from all commits
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

@@ -1,6 +1,7 @@
### GHOSTERY 8.4.8 ()
### GHOSTERY 8.4.8 (March 30, 2019)

+ Fixes issue that could intermittently cause some cookies to be reset (Fixes #514)
+ Handle legacy opt-in settings for Firefox (#518)

### GHOSTERY 8.4.7 (March 16, 2020)

@@ -1471,6 +1471,8 @@ function initializeVersioning() {
if (globals.JUST_UPGRADED) {
log('THIS IS AN UPGRADE');
conf.previous_version = globals.EXTENSION_VERSION;
const { version_history } = conf;
const earliestVersion = version_history[0].split('.');
const prevVersion = PREVIOUS_EXTENSION_VERSION.split('.');
const currentVersion = globals.EXTENSION_VERSION.split('.');

@@ -1487,13 +1489,12 @@ function initializeVersioning() {
conf.enable_smart_block = false;
}

// Are we upgrading from Ghostery 8 prior to 8.2?
if ((+prevVersion[0] === 8) && (prevVersion[1] < 2)) {
globals.JUST_UPGRADED_FROM_8_1 = true;
// Check if the earliest version is < 8.4.2
if (earliestVersion[0] <= 8 && earliestVersion[1] <= 4 && earliestVersion[2] < 2) {
This conversation was marked as resolved by christophertino

This comment has been minimized.

@jsignanini

jsignanini Mar 26, 2020
Member

@christophertino to be extra safe we should add a length check on the earliestVersion array so it doesn't crash if it's < 3.

globals.REQUIRE_LEGACY_OPT_IN = true;
}

// Establish version history
const { version_history } = conf;
version_history.push(globals.EXTENSION_VERSION);
conf.version_history = version_history;
} else {
@@ -1512,14 +1513,6 @@ function initializeVersioning() {
function initializeGhosteryModules() {
if (globals.JUST_UPGRADED) {
log('JUST UPGRADED');

const { version_history } = conf;
const size = version_history.length;
if (!size || version_history[size - 1] !== globals.EXTENSION_VERSION) {
version_history.push(globals.EXTENSION_VERSION);
}
conf.version_history = version_history;

metrics.ping('upgrade');
// We don't want install_complete pings for upgrade
conf.metrics.install_complete_all = Number(new Date().getTime());
@@ -1563,35 +1556,28 @@ function initializeGhosteryModules() {
initialiseWebRequestPipeline(),
]).then(() => {
if (!IS_CLIQZ) {
if (globals.JUST_UPGRADED_FROM_7) {
// These users had human web already, so we respect their choice
conf.enable_human_web = !humanweb.isDisabled;
// These users did not have adblocking and antitracking.
// We introduce these new features initially disabled.
conf.enable_ad_block = false;
conf.enable_anti_tracking = false;
// Enable Offers except or Cliqz
conf.enable_offers = true;
} else if (globals.JUST_UPGRADED_FROM_8_1) {
// These users already had human web, adblocker and antitracking, so we respect their choice
conf.enable_ad_block = !adblocker.isDisabled;
conf.enable_anti_tracking = !antitracking.isDisabled;
conf.enable_human_web = !humanweb.isDisabled;
// These users did not have Offers, so we enable them on upgrade.
conf.enable_offers = true;
} else {
// Otherwise we respect browser-core default settings
conf.enable_ad_block = !adblocker.isDisabled;
conf.enable_anti_tracking = !antitracking.isDisabled;
conf.enable_human_web = !humanweb.isDisabled && !(IS_FIREFOX && globals.JUST_INSTALLED);
conf.enable_offers = !offers.isDisabled && !(IS_FIREFOX && globals.JUST_INSTALLED);
conf.enable_ad_block = !adblocker.isDisabled;
conf.enable_anti_tracking = !antitracking.isDisabled;
conf.enable_human_web = !humanweb.isDisabled;
conf.enable_offers = !offers.isDisabled;

if (IS_FIREFOX) {
if (globals.JUST_INSTALLED) {
conf.enable_human_web = false;
conf.enable_offers = false;
} else if (globals.REQUIRE_LEGACY_OPT_IN && !conf.cliqz_legacy_opt_in) {
conf.enable_human_web = false;
conf.enable_offers = cliqz.prefs.get('myoffrz.opted_in') || false;
conf.cliqz_legacy_opt_in = true;
}
}

const myoffrzShouldMigrate = conf.rewards_opted_in !== undefined && cliqz.prefs.get('myoffrz.opted_in', undefined) === undefined;
if (myoffrzShouldMigrate) {
cliqz.prefs.set('myoffrz.opted_in', conf.rewards_opted_in);
conf.rewards_opted_in = undefined;
}

cliqz.events.subscribe('myoffrz:turnoff', () => {
panelData.set({ enable_offers: false });
rewards.sendSignal({
@@ -100,6 +100,7 @@ class ConfData {
_initProperty('block_by_default', false);
_initProperty('bugs_last_checked', 0);
_initProperty('bugs_last_updated', nowTime);
_initProperty('cliqz_legacy_opt_in', false);
_initProperty('cliqz_import_state', 0);
_initProperty('cmp_version', 0);
_initProperty('current_theme', 'default');
@@ -129,7 +130,7 @@ class ConfData {
_initProperty('plus_promo_modal_last_seen', 0);
_initProperty('premium_promo_modal_last_seen', 0);
_initProperty('rewards_accepted', false);
_initProperty('rewards_opted_in', false);
_initProperty('rewards_opted_in', false); // Migrated to Cliqz pref myoffrz.opted_in
_initProperty('settings_last_imported', 0);
_initProperty('settings_last_exported', 0);
_initProperty('show_alert', BROWSER_INFO.os !== 'android' && !IS_FIREFOX);
@@ -38,7 +38,7 @@ class Globals {
this.JUST_INSTALLED = false;
this.JUST_UPGRADED = false;
this.JUST_UPGRADED_FROM_7 = false;
this.JUST_UPGRADED_FROM_8_1 = false;
this.REQUIRE_LEGACY_OPT_IN = false;
this.HOTFIX = false;
this.LET_REDIRECTS_THROUGH = false;
this.C2P_LOADED = false;
ProTip! Use n and p to navigate between commits in a pull request.