Skip to content

Commit

Permalink
Exclude users from the cohort if they have at least one Aztec enabled…
Browse files Browse the repository at this point in the history
… site
  • Loading branch information
maxme committed Nov 13, 2019
1 parent a837ae6 commit 2ff8e8d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -609,11 +609,11 @@ public static boolean isDefaultAppWideEditorPreferenceSet() {
}

public static boolean isUserInGutenbergRolloutGroup() {
return getBoolean(DeletablePrefKey.GUTENBERG_DEFAULT_FOR_NEW_POSTS, false);
return getBoolean(DeletablePrefKey.USER_IN_GUTENBERG_ROLLOUT_GROUP, false);
}

public static void setUserInGutenbergRolloutGroup() {
setBoolean(DeletablePrefKey.GUTENBERG_DEFAULT_FOR_NEW_POSTS, true);
setBoolean(DeletablePrefKey.USER_IN_GUTENBERG_ROLLOUT_GROUP, true);
}

public static void removeAppWideEditorPreference() {
Expand Down
31 changes: 25 additions & 6 deletions WordPress/src/main/java/org/wordpress/android/util/SiteUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ public class SiteUtils {
public static void migrateAppWideMobileEditorPreferenceToRemote(final AccountStore accountStore,
final SiteStore siteStore,
final Dispatcher dispatcher) {
// Skip if the user is not signed in
if (!FluxCUtils.isSignedInWPComOrHasWPOrgSite(accountStore, siteStore)) {
return;
}

// In a later version we might override mobile_editor setting if it's set to `aztec` and show a specific notice
// for these users ("We made a lot of progress on the block editor and we think it's now better than
// the classic editor, we switched it on, but you can change the configuration in your Site Settings").
Expand All @@ -58,18 +63,22 @@ public static void migrateAppWideMobileEditorPreferenceToRemote(final AccountSto
// To exclude ids 0 and 1, to rollout for 10% users,
// we'll use a test like `id % 100 >= 90` instead of `id % 100 < 10`.
if (accountStore.getAccount().getUserId() % 100 >= (100 - GB_ROLLOUT_PERCENTAGE)) {
// We want to make sure to enable Gutenberg only on the sites they didn't opt-out.
if (atLeastOneSiteHasAztecEnabled(siteStore)) {
// If the user has opt-ed out from at least one of their site, then exclude them from the cohort
return;
}

// Force the dialog to be shown on updated sites
for (SiteModel site : siteStore.getSites()) {
if (TextUtils.isEmpty(site.getMobileEditor())) {
// Enable Gutenberg
enableBlockEditor(dispatcher, site);
AnalyticsUtils.trackWithSiteDetails(Stat.EDITOR_GUTENBERG_ENABLED, site,
BlockEditorEnabledSource.ON_PROGRESSIVE_ROLLOUT.asPropertyMap());
// Show the info popup when the user creates a new post for the first time on this site
AppPrefs.setShowGutenbergInfoPopupForTheNewPosts(site.getUrl(), true);
}
}

// Enable Gutenberg for all sites using a single network call
dispatcher.dispatch(SiteActionBuilder.newDesignateMobileEditorForAllSitesAction(
new DesignateMobileEditorForAllSitesPayload(SiteUtils.GB_EDITOR_NAME)));

// After enabling Gutenberg on these sites, we consider the user entered the rollout group
AppPrefs.setUserInGutenbergRolloutGroup();
}
Expand All @@ -88,6 +97,16 @@ public static void migrateAppWideMobileEditorPreferenceToRemote(final AccountSto
}
}

private static boolean atLeastOneSiteHasAztecEnabled(final SiteStore siteStore) {
// We want to make sure to enable Gutenberg only on the sites they didn't opt-out.
for (SiteModel site : siteStore.getSites()) {
if (TextUtils.equals(site.getMobileEditor(), AZTEC_EDITOR_NAME)) {
return true;
}
}
return false;
}

public static boolean enableBlockEditorOnSiteCreation(Dispatcher dispatcher, SiteStore siteStore,
int siteLocalSiteID) {
SiteModel newSiteModel = siteStore.getSiteByLocalId(siteLocalSiteID);
Expand Down

0 comments on commit 2ff8e8d

Please sign in to comment.