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 {
class BackgroundProfilingTriggers;
}
namespace nux {
bool IsNuxOnboardingEnabled(Profile* profile);
}
namespace safe_browsing {
class ChromeCleanerControllerDelegate;
class DownloadUrlSBClient;
......@@ -141,6 +145,7 @@ class ChromeMetricsServiceAccessor : public metrics::MetricsServiceAccessor {
friend class ChromePasswordManagerClient;
friend class NavigationMetricsRecorder;
friend class ChromeUnifiedConsentServiceClient;
friend bool nux::IsNuxOnboardingEnabled(Profile* profile);
// Testing related friends.
friend class MetricsReportingStateTest;
......
......@@ -384,6 +384,7 @@ const char kReverseAutologinEnabled[] = "reverse_autologin.enabled";
const char kNetworkQualities[] = "net.network_qualities";
const char kForceSessionSync[] = "settings.history_recorded";
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
// perhaps be kept around longer than the others.
const char kHttpServerProperties[] = "net.http_server_properties";
......@@ -417,6 +418,7 @@ void RegisterProfilePrefsForMigration(
registry->RegisterDictionaryPref(kNetworkQualities, PrefRegistry::LOSSY_PREF);
registry->RegisterBooleanPref(kForceSessionSync, false);
registry->RegisterBooleanPref(kOnboardDuringNUX, false);
registry->RegisterIntegerPref(kNuxOnboardGroup, 0);
registry->RegisterDictionaryPref(kHttpServerProperties,
PrefRegistry::LOSSY_PREF);
}
......@@ -886,5 +888,6 @@ void MigrateObsoleteProfilePrefs(Profile* profile) {
profile_prefs->ClearPref(kNetworkQualities);
profile_prefs->ClearPref(kForceSessionSync);
profile_prefs->ClearPref(kOnboardDuringNUX);
profile_prefs->ClearPref(kNuxOnboardGroup);
profile_prefs->ClearPref(kHttpServerProperties);
}
......@@ -1081,8 +1081,8 @@ void ProfileManager::InitProfileUserPrefs(Profile* profile) {
#if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
// Enterprise users should not be included in any NUX/Navi flow.
if (!base::win::IsEnterpriseManaged()) {
int group = nux::GetOnboardingGroup();
profile->GetPrefs()->SetInteger(prefs::kNuxOnboardGroup, group);
profile->GetPrefs()->SetString(prefs::kNaviOnboardGroup,
nux::GetOnboardingGroup());
}
#endif // defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
}
......
......@@ -470,9 +470,9 @@ void StartupBrowserCreator::RegisterProfilePrefs(PrefRegistrySimple* registry) {
// creation.
registry->RegisterBooleanPref(prefs::kHasSeenWelcomePage, true);
#if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
// This will be set to a group number for newly created profiles, and is used
// to indicate which users went through onboarding with the current group.
registry->RegisterIntegerPref(prefs::kNuxOnboardGroup, 0);
// This will be set for newly created profiles, and is used to indicate which
// users went through onboarding with the current experiment group.
registry->RegisterStringPref(prefs::kNaviOnboardGroup, "");
#endif // defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
}
......
......@@ -7,9 +7,11 @@
#include <string>
#include "base/feature_list.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/field_trial_params.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/welcome/nux/constants.h"
#include "chrome/common/pref_names.h"
......@@ -34,11 +36,15 @@ const base::FeatureParam<std::string>
const base::FeatureParam<bool> kNuxOnboardingForceEnabledShowEmailInterstitial =
{&kNuxOnboardingForceEnabled, "show-email-interstitial", true};
int GetOnboardingGroup() {
// Preppend a 0 to avoid issues with empty string.
return std::stoi("0" + base::GetFieldTrialParamValue(
/* Must match finch study name */ "NaviOnboarding",
"onboarding-group"));
// Must match study name in configs.
const char kNuxOnboardingStudyName[] = "NaviOnboarding";
std::string GetOnboardingGroup() {
// 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) {
......@@ -47,23 +53,21 @@ bool IsNuxOnboardingEnabled(Profile* profile) {
} else {
#if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
// To avoid diluting data collection, existing users should not be assigned
// an NUX group. So, the kNuxOnboardGroup integer is used to short-circuit
// the feature checks below.
// an onboarding group. So, |prefs::kNaviOnboardGroup| is used to
// short-circuit the feature checks below.
PrefService* prefs = profile->GetPrefs();
if (!prefs)
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;
int current_group = GetOnboardingGroup();
if (onboard_group != current_group) {
// Remove user from group if they're not part of the current experiment.
prefs->SetInteger(prefs::kNuxOnboardGroup, 0);
return false;
}
// User will be tied to their original onboarding group, even after
// experiment ends.
ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial(
kNuxOnboardingStudyName, onboard_group);
return base::FeatureList::IsEnabled(nux::kNuxOnboardingFeature);
#else
......@@ -85,7 +89,7 @@ base::DictionaryValue GetNuxOnboardingModules(Profile* profile) {
kNuxOnboardingForceEnabledReturningUserModules.Get());
modules.SetBoolean("show-email-interstitial",
kNuxOnboardingForceEnabledShowEmailInterstitial.Get());
} else { // This means nux::kNuxOnboardingFeature is enabled.
} else { // This means |nux::kNuxOnboardingFeature| is enabled.
modules.SetString("new-user", kNuxOnboardingNewUserModules.Get());
modules.SetString("returning-user",
kNuxOnboardingReturningUserModules.Get());
......
......@@ -5,6 +5,8 @@
#ifndef 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/metrics/field_trial_params.h"
......@@ -25,14 +27,14 @@ extern const base::FeatureParam<std::string>
extern const base::FeatureParam<bool>
kNuxOnboardingForceEnabledShowEmailInterstitial;
// Get the group number for users who onboard in this experiment.
// Get the group for users who onboard in this experiment.
// Groups are:
// - Specified by finch
// - The same for all experiments in finch
// - Specified by study
// - The same for all experiments in study
// - Incremented with each new version
// - Not reused
// - Cleared out when experiment ends
int GetOnboardingGroup();
std::string GetOnboardingGroup();
bool IsNuxOnboardingEnabled(Profile* profile);
......
......@@ -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
// the first run onboarding experience. Only users in a group will have their
// 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(OS_WIN)
......
......@@ -442,7 +442,7 @@ extern const char kHasSeenWelcomePage[];
#if defined(OS_WIN)
extern const char kHasSeenWin10PromoPage[];
#if defined(GOOGLE_CHROME_BUILD)
extern const char kNuxOnboardGroup[];
extern const char kNaviOnboardGroup[];
#endif // defined(GOOGLE_CHROME_BUILD)
#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