Commit c14c1467 authored by Robert Kaplow's avatar Robert Kaplow Committed by Commit Bot

Enable initial_url collection in UKM.

Simplify the logic by just enabling and removing the variations param (which was never enabled).


Bug: 869123
Change-Id: Ic98b681e53ca3a4179d4f5a6f2948520f3c9ff6c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1600451Reviewed-by: default avatarBryan McQuade <bmcquade@chromium.org>
Commit-Queue: Robert Kaplow <rkaplow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#658561}
parent 363b7a34
......@@ -88,12 +88,6 @@ bool HasSupportedScheme(const GURL& url) {
url.SchemeIs(kExtensionScheme) || url.SchemeIs(kAppScheme);
}
// True if we should record the initial_url field of the UKM Source proto.
bool ShouldRecordInitialUrl() {
return base::GetFieldTrialParamByFeatureAsBool(kUkmFeature,
"RecordInitialUrl", false);
}
enum class DroppedDataReason {
NOT_DROPPED = 0,
RECORDING_DISABLED = 1,
......@@ -325,8 +319,6 @@ void UkmRecorderImpl::StoreRecordingsInReport(Report* report) {
}
Source* proto_source = report->add_sources();
kv.second->PopulateProto(proto_source);
if (!ShouldRecordInitialUrl())
proto_source->clear_initial_url();
serialized_source_type_counts[GetSourceIdType(kv.first)]++;
}
......
......@@ -285,7 +285,7 @@ TEST_F(UkmServiceTest, SourceSerialization) {
EXPECT_EQ(id, proto_source.id());
EXPECT_EQ(GURL("https://google.com/final").spec(), proto_source.url());
EXPECT_FALSE(proto_source.has_initial_url());
EXPECT_TRUE(proto_source.has_initial_url());
}
TEST_F(UkmServiceTest, AddEntryWithEmptyMetrics) {
......@@ -442,43 +442,34 @@ TEST_F(UkmServiceTest, GetNewSourceID) {
}
TEST_F(UkmServiceTest, RecordInitialUrl) {
for (bool should_record_initial_url : {true, false}) {
base::FieldTrialList field_trial_list(nullptr /* entropy_provider */);
ScopedUkmFeatureParams params(
base::FeatureList::OVERRIDE_ENABLE_FEATURE,
{{"RecordInitialUrl", should_record_initial_url ? "true" : "false"}});
ClearPrefs();
UkmService service(&prefs_, &client_,
true /* restrict_to_whitelisted_entries */);
TestRecordingHelper recorder(&service);
EXPECT_EQ(GetPersistedLogCount(), 0);
service.Initialize();
task_runner_->RunUntilIdle();
service.EnableRecording(/*extensions=*/false);
service.EnableReporting();
ClearPrefs();
UkmService service(&prefs_, &client_,
true /* restrict_to_whitelisted_entries */);
TestRecordingHelper recorder(&service);
EXPECT_EQ(GetPersistedLogCount(), 0);
service.Initialize();
task_runner_->RunUntilIdle();
service.EnableRecording(/*extensions=*/false);
service.EnableReporting();
ukm::SourceId id = GetWhitelistedSourceId(0);
UkmSource::NavigationData navigation_data;
navigation_data.urls = {GURL("https://google.com/initial"),
GURL("https://google.com/final")};
recorder.RecordNavigation(id, navigation_data);
ukm::SourceId id = GetWhitelistedSourceId(0);
UkmSource::NavigationData navigation_data;
navigation_data.urls = {GURL("https://google.com/initial"),
GURL("https://google.com/final")};
recorder.RecordNavigation(id, navigation_data);
service.Flush();
EXPECT_EQ(GetPersistedLogCount(), 1);
service.Flush();
EXPECT_EQ(GetPersistedLogCount(), 1);
Report proto_report = GetPersistedReport();
EXPECT_EQ(1, proto_report.sources_size());
const Source& proto_source = proto_report.sources(0);
Report proto_report = GetPersistedReport();
EXPECT_EQ(1, proto_report.sources_size());
const Source& proto_source = proto_report.sources(0);
EXPECT_EQ(id, proto_source.id());
EXPECT_EQ(GURL("https://google.com/final").spec(), proto_source.url());
EXPECT_EQ(should_record_initial_url, proto_source.has_initial_url());
if (should_record_initial_url) {
EXPECT_EQ(GURL("https://google.com/initial").spec(),
proto_source.initial_url());
}
}
EXPECT_EQ(id, proto_source.id());
EXPECT_EQ(GURL("https://google.com/final").spec(), proto_source.url());
EXPECT_TRUE(proto_source.has_initial_url());
EXPECT_EQ(GURL("https://google.com/initial").spec(),
proto_source.initial_url());
}
TEST_F(UkmServiceTest, RestrictToWhitelistedSourceIds) {
......
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