Commit 2ced80ec authored by Hector Carmona's avatar Hector Carmona Committed by Commit Bot

Navi: populate synthetic trials.

Once a local profile enters a synthetic trial for on-boarding, it will
remain in it forever. This is not a problem because local profiles
should not be running the on-boarding process more than once. If a user
creates a new profile, it will be assigned into a synthetic trial based
on the experiment at the time of onboarding.

Bug: 874153
Change-Id: I4f3b9aea39e75fd01ae7dabd7895ea8aa00e633a
Reviewed-on: https://chromium-review.googlesource.com/c/1344990
Commit-Queue: Hector Carmona <hcarmona@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Reviewed-by: default avatarAlexei Svitkine <asvitkine@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612364}
parent 70d4f95a
...@@ -66,6 +66,10 @@ namespace heap_profiling { ...@@ -66,6 +66,10 @@ namespace heap_profiling {
class BackgroundProfilingTriggers; class BackgroundProfilingTriggers;
} }
namespace nux {
bool IsNuxOnboardingEnabled(Profile* profile);
}
namespace safe_browsing { namespace safe_browsing {
class ChromeCleanerControllerDelegate; class ChromeCleanerControllerDelegate;
class DownloadUrlSBClient; class DownloadUrlSBClient;
...@@ -141,6 +145,7 @@ class ChromeMetricsServiceAccessor : public metrics::MetricsServiceAccessor { ...@@ -141,6 +145,7 @@ class ChromeMetricsServiceAccessor : public metrics::MetricsServiceAccessor {
friend class ChromePasswordManagerClient; friend class ChromePasswordManagerClient;
friend class NavigationMetricsRecorder; friend class NavigationMetricsRecorder;
friend class ChromeUnifiedConsentServiceClient; friend class ChromeUnifiedConsentServiceClient;
friend bool nux::IsNuxOnboardingEnabled(Profile* profile);
// Testing related friends. // Testing related friends.
friend class MetricsReportingStateTest; friend class MetricsReportingStateTest;
......
...@@ -384,6 +384,7 @@ const char kReverseAutologinEnabled[] = "reverse_autologin.enabled"; ...@@ -384,6 +384,7 @@ const char kReverseAutologinEnabled[] = "reverse_autologin.enabled";
const char kNetworkQualities[] = "net.network_qualities"; const char kNetworkQualities[] = "net.network_qualities";
const char kForceSessionSync[] = "settings.history_recorded"; const char kForceSessionSync[] = "settings.history_recorded";
const char kOnboardDuringNUX[] = "browser.onboard_during_nux"; const char kOnboardDuringNUX[] = "browser.onboard_during_nux";
const char kNuxOnboardGroup[] = "browser.onboard_group";
// This pref is particularly large, taking up 15+% of the prefs file, so should // This pref is particularly large, taking up 15+% of the prefs file, so should
// perhaps be kept around longer than the others. // perhaps be kept around longer than the others.
const char kHttpServerProperties[] = "net.http_server_properties"; const char kHttpServerProperties[] = "net.http_server_properties";
...@@ -417,6 +418,7 @@ void RegisterProfilePrefsForMigration( ...@@ -417,6 +418,7 @@ void RegisterProfilePrefsForMigration(
registry->RegisterDictionaryPref(kNetworkQualities, PrefRegistry::LOSSY_PREF); registry->RegisterDictionaryPref(kNetworkQualities, PrefRegistry::LOSSY_PREF);
registry->RegisterBooleanPref(kForceSessionSync, false); registry->RegisterBooleanPref(kForceSessionSync, false);
registry->RegisterBooleanPref(kOnboardDuringNUX, false); registry->RegisterBooleanPref(kOnboardDuringNUX, false);
registry->RegisterIntegerPref(kNuxOnboardGroup, 0);
registry->RegisterDictionaryPref(kHttpServerProperties, registry->RegisterDictionaryPref(kHttpServerProperties,
PrefRegistry::LOSSY_PREF); PrefRegistry::LOSSY_PREF);
} }
...@@ -886,5 +888,6 @@ void MigrateObsoleteProfilePrefs(Profile* profile) { ...@@ -886,5 +888,6 @@ void MigrateObsoleteProfilePrefs(Profile* profile) {
profile_prefs->ClearPref(kNetworkQualities); profile_prefs->ClearPref(kNetworkQualities);
profile_prefs->ClearPref(kForceSessionSync); profile_prefs->ClearPref(kForceSessionSync);
profile_prefs->ClearPref(kOnboardDuringNUX); profile_prefs->ClearPref(kOnboardDuringNUX);
profile_prefs->ClearPref(kNuxOnboardGroup);
profile_prefs->ClearPref(kHttpServerProperties); profile_prefs->ClearPref(kHttpServerProperties);
} }
...@@ -1081,8 +1081,8 @@ void ProfileManager::InitProfileUserPrefs(Profile* profile) { ...@@ -1081,8 +1081,8 @@ void ProfileManager::InitProfileUserPrefs(Profile* profile) {
#if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
// Enterprise users should not be included in any NUX/Navi flow. // Enterprise users should not be included in any NUX/Navi flow.
if (!base::win::IsEnterpriseManaged()) { if (!base::win::IsEnterpriseManaged()) {
int group = nux::GetOnboardingGroup(); profile->GetPrefs()->SetString(prefs::kNaviOnboardGroup,
profile->GetPrefs()->SetInteger(prefs::kNuxOnboardGroup, group); nux::GetOnboardingGroup());
} }
#endif // defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) #endif // defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
} }
......
...@@ -470,9 +470,9 @@ void StartupBrowserCreator::RegisterProfilePrefs(PrefRegistrySimple* registry) { ...@@ -470,9 +470,9 @@ void StartupBrowserCreator::RegisterProfilePrefs(PrefRegistrySimple* registry) {
// creation. // creation.
registry->RegisterBooleanPref(prefs::kHasSeenWelcomePage, true); registry->RegisterBooleanPref(prefs::kHasSeenWelcomePage, true);
#if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
// This will be set to a group number for newly created profiles, and is used // This will be set for newly created profiles, and is used to indicate which
// to indicate which users went through onboarding with the current group. // users went through onboarding with the current experiment group.
registry->RegisterIntegerPref(prefs::kNuxOnboardGroup, 0); registry->RegisterStringPref(prefs::kNaviOnboardGroup, "");
#endif // defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) #endif // defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
} }
......
...@@ -7,9 +7,11 @@ ...@@ -7,9 +7,11 @@
#include <string> #include <string>
#include "base/feature_list.h" #include "base/feature_list.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/field_trial_params.h" #include "base/metrics/field_trial_params.h"
#include "base/values.h" #include "base/values.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/welcome/nux/constants.h" #include "chrome/browser/ui/webui/welcome/nux/constants.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
...@@ -34,11 +36,15 @@ const base::FeatureParam<std::string> ...@@ -34,11 +36,15 @@ const base::FeatureParam<std::string>
const base::FeatureParam<bool> kNuxOnboardingForceEnabledShowEmailInterstitial = const base::FeatureParam<bool> kNuxOnboardingForceEnabledShowEmailInterstitial =
{&kNuxOnboardingForceEnabled, "show-email-interstitial", true}; {&kNuxOnboardingForceEnabled, "show-email-interstitial", true};
int GetOnboardingGroup() { // Must match study name in configs.
// Preppend a 0 to avoid issues with empty string. const char kNuxOnboardingStudyName[] = "NaviOnboarding";
return std::stoi("0" + base::GetFieldTrialParamValue(
/* Must match finch study name */ "NaviOnboarding", std::string GetOnboardingGroup() {
"onboarding-group")); // We need to use |base::GetFieldTrialParamValue| instead of
// |base::FeatureParam| because our control group needs a custom value for
// this param.
return base::GetFieldTrialParamValue(kNuxOnboardingStudyName,
"onboarding-group");
} }
bool IsNuxOnboardingEnabled(Profile* profile) { bool IsNuxOnboardingEnabled(Profile* profile) {
...@@ -47,23 +53,21 @@ bool IsNuxOnboardingEnabled(Profile* profile) { ...@@ -47,23 +53,21 @@ bool IsNuxOnboardingEnabled(Profile* profile) {
} else { } else {
#if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
// To avoid diluting data collection, existing users should not be assigned // To avoid diluting data collection, existing users should not be assigned
// an NUX group. So, the kNuxOnboardGroup integer is used to short-circuit // an onboarding group. So, |prefs::kNaviOnboardGroup| is used to
// the feature checks below. // short-circuit the feature checks below.
PrefService* prefs = profile->GetPrefs(); PrefService* prefs = profile->GetPrefs();
if (!prefs) if (!prefs)
return false; return false;
int onboard_group = prefs->GetInteger(prefs::kNuxOnboardGroup); std::string onboard_group = prefs->GetString(prefs::kNaviOnboardGroup);
if (onboard_group == 0) if (onboard_group.empty())
return false; return false;
int current_group = GetOnboardingGroup(); // User will be tied to their original onboarding group, even after
if (onboard_group != current_group) { // experiment ends.
// Remove user from group if they're not part of the current experiment. ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial(
prefs->SetInteger(prefs::kNuxOnboardGroup, 0); kNuxOnboardingStudyName, onboard_group);
return false;
}
return base::FeatureList::IsEnabled(nux::kNuxOnboardingFeature); return base::FeatureList::IsEnabled(nux::kNuxOnboardingFeature);
#else #else
...@@ -85,7 +89,7 @@ base::DictionaryValue GetNuxOnboardingModules(Profile* profile) { ...@@ -85,7 +89,7 @@ base::DictionaryValue GetNuxOnboardingModules(Profile* profile) {
kNuxOnboardingForceEnabledReturningUserModules.Get()); kNuxOnboardingForceEnabledReturningUserModules.Get());
modules.SetBoolean("show-email-interstitial", modules.SetBoolean("show-email-interstitial",
kNuxOnboardingForceEnabledShowEmailInterstitial.Get()); kNuxOnboardingForceEnabledShowEmailInterstitial.Get());
} else { // This means nux::kNuxOnboardingFeature is enabled. } else { // This means |nux::kNuxOnboardingFeature| is enabled.
modules.SetString("new-user", kNuxOnboardingNewUserModules.Get()); modules.SetString("new-user", kNuxOnboardingNewUserModules.Get());
modules.SetString("returning-user", modules.SetString("returning-user",
kNuxOnboardingReturningUserModules.Get()); kNuxOnboardingReturningUserModules.Get());
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#ifndef CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_HELPER_H_ #ifndef CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_HELPER_H_
#define CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_HELPER_H_ #define CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_HELPER_H_
#include <string>
#include "base/macros.h" #include "base/macros.h"
#include "base/metrics/field_trial_params.h" #include "base/metrics/field_trial_params.h"
...@@ -25,14 +27,14 @@ extern const base::FeatureParam<std::string> ...@@ -25,14 +27,14 @@ extern const base::FeatureParam<std::string>
extern const base::FeatureParam<bool> extern const base::FeatureParam<bool>
kNuxOnboardingForceEnabledShowEmailInterstitial; kNuxOnboardingForceEnabledShowEmailInterstitial;
// Get the group number for users who onboard in this experiment. // Get the group for users who onboard in this experiment.
// Groups are: // Groups are:
// - Specified by finch // - Specified by study
// - The same for all experiments in finch // - The same for all experiments in study
// - Incremented with each new version // - Incremented with each new version
// - Not reused // - Not reused
// - Cleared out when experiment ends // - Cleared out when experiment ends
int GetOnboardingGroup(); std::string GetOnboardingGroup();
bool IsNuxOnboardingEnabled(Profile* profile); bool IsNuxOnboardingEnabled(Profile* profile);
......
...@@ -1295,7 +1295,7 @@ const char kHasSeenWin10PromoPage[] = "browser.has_seen_win10_promo_page"; ...@@ -1295,7 +1295,7 @@ const char kHasSeenWin10PromoPage[] = "browser.has_seen_win10_promo_page";
// Put the user into an onboarding group that's decided when they go through // Put the user into an onboarding group that's decided when they go through
// the first run onboarding experience. Only users in a group will have their // the first run onboarding experience. Only users in a group will have their
// finch group pinged to keep track of them for the experiment. // finch group pinged to keep track of them for the experiment.
const char kNuxOnboardGroup[] = "browser.onboard_group"; const char kNaviOnboardGroup[] = "browser.navi_onboard_group";
#endif // defined(GOOGLE_CHROME_BUILD) #endif // defined(GOOGLE_CHROME_BUILD)
#endif // defined(OS_WIN) #endif // defined(OS_WIN)
......
...@@ -442,7 +442,7 @@ extern const char kHasSeenWelcomePage[]; ...@@ -442,7 +442,7 @@ extern const char kHasSeenWelcomePage[];
#if defined(OS_WIN) #if defined(OS_WIN)
extern const char kHasSeenWin10PromoPage[]; extern const char kHasSeenWin10PromoPage[];
#if defined(GOOGLE_CHROME_BUILD) #if defined(GOOGLE_CHROME_BUILD)
extern const char kNuxOnboardGroup[]; extern const char kNaviOnboardGroup[];
#endif // defined(GOOGLE_CHROME_BUILD) #endif // defined(GOOGLE_CHROME_BUILD)
#endif // defined(OS_WIN) #endif // defined(OS_WIN)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment