Send variations seed version to UMA.
Update variations_seed proto and metrics protos, and send seed versions
to UMA, so it's available for analysis.
Change-Id: Id2954646c6c000af8accde3e43f1eedc9e5c1c1f
Reviewed-on: https://chromium-review.googlesource.com/c/1339242
Reviewed-by: Alexei Svitkine <[email protected]>
Commit-Queue: Steven Holte <[email protected]>
Cr-Commit-Position: refs/heads/master@{#610188}
diff --git a/components/variations/active_field_trials.cc b/components/variations/active_field_trials.cc
index f18dfe1..ae0fb9fd 100644
--- a/components/variations/active_field_trials.cc
+++ b/components/variations/active_field_trials.cc
@@ -8,6 +8,7 @@
#include <vector>
+#include "base/lazy_instance.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "components/variations/hashing.h"
@@ -17,6 +18,8 @@
namespace {
+base::LazyInstance<std::string>::Leaky g_seed_version;
+
// Populates |name_group_ids| based on |active_groups|. Field trial names are
// suffixed with |suffix| before hashing is executed.
void GetFieldTrialActiveGroupIdsForActiveGroups(
@@ -77,6 +80,14 @@
AppendActiveGroupIdsAsStrings(name_group_ids, output);
}
+void SetSeedVersion(const std::string& seed_version) {
+ g_seed_version.Get() = seed_version;
+}
+
+const std::string& GetSeedVersion() {
+ return g_seed_version.Get();
+}
+
namespace testing {
void TestGetFieldTrialActiveGroupIds(
diff --git a/components/variations/active_field_trials.h b/components/variations/active_field_trials.h
index ecadf08..d9f10a0 100644
--- a/components/variations/active_field_trials.h
+++ b/components/variations/active_field_trials.h
@@ -63,6 +63,18 @@
// which hasn't been chosen yet are NOT returned in this list.
void GetSyntheticTrialGroupIdsAsString(std::vector<std::string>* output);
+// Sets the version of the seed that the current set of FieldTrials was
+// generated from.
+// TODO(crbug/507665): Move this to field_trials_provider once it moves
+// into components/variations
+void SetSeedVersion(const std::string& seed_version);
+
+// Gets the version of the seed that the current set of FieldTrials was
+// generated from.
+// TODO(crbug/507665): Move this to field_trials_provider once it moves
+// into components/variations
+const std::string& GetSeedVersion();
+
// Expose some functions for testing. These functions just wrap functionality
// that is implemented above.
namespace testing {
diff --git a/components/variations/proto/variations_seed.proto b/components/variations/proto/variations_seed.proto
index 8824b7e..0659414e 100644
--- a/components/variations/proto/variations_seed.proto
+++ b/components/variations/proto/variations_seed.proto
@@ -23,4 +23,8 @@
// Lowercase ISO 3166-1 alpha-2 country code of the client, according to IP
// address. Deprecated.
optional string country_code = 3 [deprecated = true];
+
+ // A version string which identifies the version of the configuration files
+ // that this seed was generated from.
+ optional string version = 4;
}
diff --git a/components/variations/variations_seed_processor.cc b/components/variations/variations_seed_processor.cc
index 7fff151..3bc232fd 100644
--- a/components/variations/variations_seed_processor.cc
+++ b/components/variations/variations_seed_processor.cc
@@ -172,6 +172,7 @@
base::FeatureList* feature_list) {
std::vector<ProcessedStudy> filtered_studies;
FilterAndValidateStudies(seed, client_state, &filtered_studies);
+ SetSeedVersion(seed.version());
for (const ProcessedStudy& study : filtered_studies) {
CreateTrialFromStudy(study, override_callback, low_entropy_provider,