Commit 46358146 authored by Yi Gu's avatar Yi Gu Committed by Commit Bot

[WebOTP] UKM: add metric to measure WebOTP's impact on phone collection

This UKM helps us to understand whether WebOTP increases phone number
collection. We will first use UMA to analyze the portion of each bucket
in the metric. If certain buckets have high volume, we need to turn to
UKM for better understanding. See detailed design doc [1].

UKM collection review:
https://docs.google.com/document/d/1xlV8thqJ3Vt_uYr0Dbi8PR_cctRzUXcDS2y1BiPGCm8/edit?usp=sharing

[1] https://docs.google.com/document/d/1OPqPNY9l76kvaBPBCS5wbBQv2HNhmNlsDAcUvmYgyNI/edit#heading=h.xlif2jhriq2t

Bug: 1107590
Change-Id: Ia6f87d35861879cfd586a20b2eb0e2baf31b9190
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2359403Reviewed-by: default avatarChristos Froussios <cfroussios@chromium.org>
Reviewed-by: default avatarBrian White <bcwhite@chromium.org>
Reviewed-by: default avatarAlexei Svitkine <asvitkine@chromium.org>
Commit-Queue: Yi Gu <yigu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799229}
parent c167a965
...@@ -393,6 +393,11 @@ void ContentAutofillDriver::ReportAutofillWebOTPMetrics( ...@@ -393,6 +393,11 @@ void ContentAutofillDriver::ReportAutofillWebOTPMetrics(
if (document_used_webotp) if (document_used_webotp)
phone_collection_metric_state_ |= phone_collection_metric::kWebOTPUsed; phone_collection_metric_state_ |= phone_collection_metric::kWebOTPUsed;
ukm::UkmRecorder* recorder = autofill_manager_->client()->GetUkmRecorder();
ukm::SourceId source_id = autofill_manager_->client()->GetUkmSourceId();
AutofillMetrics::LogWebOTPPhoneCollectionMetricStateUkm(
recorder, source_id, phone_collection_metric_state_);
UMA_HISTOGRAM_ENUMERATION( UMA_HISTOGRAM_ENUMERATION(
"Autofill.WebOTP.PhonePlusWebOTPPlusOTC", "Autofill.WebOTP.PhonePlusWebOTPPlusOTC",
static_cast<PhoneCollectionMetricState>(phone_collection_metric_state_)); static_cast<PhoneCollectionMetricState>(phone_collection_metric_state_));
......
...@@ -2428,4 +2428,17 @@ void AutofillMetrics::LogAddressFormImportStatustMetric( ...@@ -2428,4 +2428,17 @@ void AutofillMetrics::LogAddressFormImportStatustMetric(
base::UmaHistogramEnumeration("Autofill.AddressProfileImportStatus", metric); base::UmaHistogramEnumeration("Autofill.AddressProfileImportStatus", metric);
} }
// static
void AutofillMetrics::LogWebOTPPhoneCollectionMetricStateUkm(
ukm::UkmRecorder* recorder,
ukm::SourceId source_id,
uint32_t phone_collection_metric_state) {
DCHECK(recorder);
DCHECK_NE(source_id, ukm::kInvalidSourceId);
ukm::builders::WebOTPImpact builder(source_id);
builder.SetPhoneCollection(phone_collection_metric_state);
builder.Record(recorder);
}
} // namespace autofill } // namespace autofill
...@@ -1604,6 +1604,13 @@ class AutofillMetrics { ...@@ -1604,6 +1604,13 @@ class AutofillMetrics {
static const char* GetMetricsSyncStateSuffix( static const char* GetMetricsSyncStateSuffix(
AutofillSyncSigninState sync_state); AutofillSyncSigninState sync_state);
// Records whether a document collected phone number, and/or used WebOTP,
// and/or used OneTimeCode (OTC) during its lifecycle.
static void LogWebOTPPhoneCollectionMetricStateUkm(
ukm::UkmRecorder* ukm_recorder,
ukm::SourceId source_id,
uint32_t phone_collection_metric_state);
private: private:
static void Log(AutocompleteEvent event); static void Log(AutocompleteEvent event);
......
...@@ -10745,6 +10745,37 @@ TEST_F(AutofillMetricsTest, ...@@ -10745,6 +10745,37 @@ TEST_F(AutofillMetricsTest,
histogram_tester.ExpectTotalCount("Autofill.WebOTP.PhonePlusWebOTPPlusOTC", histogram_tester.ExpectTotalCount("Autofill.WebOTP.PhonePlusWebOTPPlusOTC",
1); 1);
} }
// Verify that proper PhoneCollectionMetricsState is logged to UKM.
TEST_F(AutofillMetricsTest, WebOTPPhoneCollectionMetricsStateLoggedToUKM) {
auto entries = test_ukm_recorder_->GetEntriesByName(
ukm::builders::WebOTPImpact::kEntryName);
ASSERT_TRUE(entries.empty());
FormData form;
CreateSimpleForm(autofill_client_.form_origin(), form);
// Document collects phone number
AddAutoCompleteFieldToForm("tel", form);
// Document uses OntTimeCode
AddAutoCompleteFieldToForm("one-time-code", form);
std::vector<FormData> forms(1, form);
base::HistogramTester histogram_tester;
autofill_manager_->OnFormsSeen(forms, TimeTicks());
autofill_driver_->SetAutofillManager(std::move(autofill_manager_));
static_cast<ContentAutofillDriver*>(autofill_driver_.get())
->ReportAutofillWebOTPMetrics(/* Document uses WebOTP */ true);
entries = test_ukm_recorder_->GetEntriesByName(
ukm::builders::WebOTPImpact::kEntryName);
ASSERT_EQ(1u, entries.size());
const int64_t* metric =
test_ukm_recorder_->GetEntryMetric(entries[0], "PhoneCollection");
EXPECT_EQ(*metric, static_cast<int>(
PhoneCollectionMetricState::kPhonePlusWebOTPPlusOTC));
}
#endif // !defined(OS_IOS) #endif // !defined(OS_IOS)
TEST_F(AutofillMetricsTest, LogAutocompleteSuggestionAcceptedIndex_WithIndex) { TEST_F(AutofillMetricsTest, LogAutocompleteSuggestionAcceptedIndex_WithIndex) {
......
...@@ -13250,6 +13250,21 @@ be describing additional metrics about the same event. ...@@ -13250,6 +13250,21 @@ be describing additional metrics about the same event.
</metric> </metric>
</event> </event>
<event name="WebOTPImpact">
<owner>yigu@chromium.org</owner>
<owner>goto@chromium.org</owner>
<owner>web-identity@google.com</owner>
<summary>
Records in the browser process when a document is destroyed.
</summary>
<metric name="PhoneCollection" enum="PhoneCollectionState">
<summary>
Records whether a document collected phone number, and/or used WebOTP,
and/or used OneTimeCode (OTC) during its lifecycle.
</summary>
</metric>
</event>
<event name="WebRTC.AddressHarvesting"> <event name="WebRTC.AddressHarvesting">
<owner>hta@chromium.org</owner> <owner>hta@chromium.org</owner>
<summary> <summary>
......
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