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

[WebOTP] Record timing related UKMs (2/2)

crrev.com/c/2429236 records SMS receive time and success time. This
patch adds metrics to record the time from the API is called to the time
a user clicks "Deny" to terminate the verification flow.

There's an existing metric called "TimeCancel" which is from the origin
trial. After the trial we changed the backend. Since then it no longer
record "user" cancellation time.

crrev.com/c/2428825 introduced a new catergory "user cancel" and this
patch records the timing of such behavior.

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

Bug: 1127402
Change-Id: I1314bf8e3efb4f2817132bc0ef629124b4b10d69
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2502950Reviewed-by: default avatarAlexei Svitkine <asvitkine@chromium.org>
Reviewed-by: default avatarKen Buchanan <kenrb@chromium.org>
Reviewed-by: default avatarMajid Valipour <majidvp@chromium.org>
Commit-Queue: Yi Gu <yigu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822786}
parent 3fdbbad5
...@@ -885,6 +885,7 @@ IN_PROC_BROWSER_TEST_F(SmsBrowserTest, ...@@ -885,6 +885,7 @@ IN_PROC_BROWSER_TEST_F(SmsBrowserTest,
} }
IN_PROC_BROWSER_TEST_F(SmsBrowserTest, RecordUserCancelledAsOutcome) { IN_PROC_BROWSER_TEST_F(SmsBrowserTest, RecordUserCancelledAsOutcome) {
base::HistogramTester histogram_tester;
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kWebOtpBackend, switches::kWebOtpBackendUserConsent); switches::kWebOtpBackend, switches::kWebOtpBackendUserConsent);
GURL url = GetTestUrl(nullptr, "simple_page.html"); GURL url = GetTestUrl(nullptr, "simple_page.html");
...@@ -914,7 +915,10 @@ IN_PROC_BROWSER_TEST_F(SmsBrowserTest, RecordUserCancelledAsOutcome) { ...@@ -914,7 +915,10 @@ IN_PROC_BROWSER_TEST_F(SmsBrowserTest, RecordUserCancelledAsOutcome) {
ukm_loop.Run(); ukm_loop.Run();
content::FetchHistogramsFromChildProcesses();
ExpectOutcomeUKM(url, blink::WebOTPServiceOutcome::kUserCancelled); ExpectOutcomeUKM(url, blink::WebOTPServiceOutcome::kUserCancelled);
ExpectTimingUKM("TimeUserCancelMs");
histogram_tester.ExpectTotalCount("Blink.Sms.Receive.TimeUserCancel", 1);
} }
// Disabled test: https://crbug.com/1134455 // Disabled test: https://crbug.com/1134455
......
...@@ -38,6 +38,21 @@ void RecordSmsSuccessTime(base::TimeDelta duration, ...@@ -38,6 +38,21 @@ void RecordSmsSuccessTime(base::TimeDelta duration,
UMA_HISTOGRAM_MEDIUM_TIMES("Blink.Sms.Receive.TimeSuccess", duration); UMA_HISTOGRAM_MEDIUM_TIMES("Blink.Sms.Receive.TimeSuccess", duration);
} }
void RecordSmsUserCancelTime(base::TimeDelta duration,
ukm::SourceId source_id,
ukm::UkmRecorder* ukm_recorder) {
DCHECK_NE(source_id, ukm::kInvalidSourceId);
DCHECK(ukm_recorder);
ukm::builders::SMSReceiver builder(source_id);
// Uses exponential bucketing for datapoints reflecting user activity.
builder.SetTimeUserCancelMs(
ukm::GetExponentialBucketMinForUserTiming(duration.InMilliseconds()));
builder.Record(ukm_recorder);
UMA_HISTOGRAM_MEDIUM_TIMES("Blink.Sms.Receive.TimeUserCancel", duration);
}
void RecordSmsCancelTime(base::TimeDelta duration) { void RecordSmsCancelTime(base::TimeDelta duration) {
UMA_HISTOGRAM_MEDIUM_TIMES("Blink.Sms.Receive.TimeCancel", duration); UMA_HISTOGRAM_MEDIUM_TIMES("Blink.Sms.Receive.TimeCancel", duration);
} }
......
...@@ -35,6 +35,11 @@ void RecordSmsSuccessTime(base::TimeDelta duration, ...@@ -35,6 +35,11 @@ void RecordSmsSuccessTime(base::TimeDelta duration,
// Records the time from when the API is called to when the user dismisses the // Records the time from when the API is called to when the user dismisses the
// infobar to abort SMS retrieval. This uses the same histogram as WebOTPService // infobar to abort SMS retrieval. This uses the same histogram as WebOTPService
// API to provide continuity with previous iterations of the API. // API to provide continuity with previous iterations of the API.
void RecordSmsUserCancelTime(base::TimeDelta duration,
ukm::SourceId source_id,
ukm::UkmRecorder* ukm_recorder);
// Records the time from when the API is called to when the request is cancelled
// by the service due to duplicated requests or lack of delegate.
void RecordSmsCancelTime(base::TimeDelta duration); void RecordSmsCancelTime(base::TimeDelta duration);
} // namespace blink } // namespace blink
......
...@@ -593,6 +593,8 @@ void OnSmsReceive(ScriptPromiseResolver* resolver, ...@@ -593,6 +593,8 @@ void OnSmsReceive(ScriptPromiseResolver* resolver,
return; return;
} else if (status == mojom::blink::SmsStatus::kUserCancelled) { } else if (status == mojom::blink::SmsStatus::kUserCancelled) {
RecordSmsOutcome(WebOTPServiceOutcome::kUserCancelled, source_id, recorder); RecordSmsOutcome(WebOTPServiceOutcome::kUserCancelled, source_id, recorder);
RecordSmsUserCancelTime(base::TimeTicks::Now() - start_time, source_id,
recorder);
// Similar to kTimeout, the promise is not rejected here. // Similar to kTimeout, the promise is not rejected here.
return; return;
} }
......
...@@ -1719,8 +1719,8 @@ reviews. Googlers can read more about this at go/gwsq-gerrit. ...@@ -1719,8 +1719,8 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
<owner>yigu@chromium.org</owner> <owner>yigu@chromium.org</owner>
<owner>web-identity@google.com</owner> <owner>web-identity@google.com</owner>
<summary> <summary>
Records the duration from when the API is called to when the user presses Records the duration from when the API is called to when the request is
the cancel button to abort SMS retrieval. cancelled by the service due to duplicated requests or lack of delegate.
</summary> </summary>
</histogram> </histogram>
...@@ -1785,6 +1785,18 @@ reviews. Googlers can read more about this at go/gwsq-gerrit. ...@@ -1785,6 +1785,18 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary> </summary>
</histogram> </histogram>
<histogram name="Blink.Sms.Receive.TimeUserCancel" units="ms"
expires_after="M92">
<owner>goto@chromium.org</owner>
<owner>yigu@chromium.org</owner>
<owner>web-identity@google.com</owner>
<summary>
Records the duration from when the API is called to when the user
successfully receives the SMS and presses &quot;Deny&quot; to terminate the
SMS verification flow.
</summary>
</histogram>
<histogram name="Blink.SpatialNavigation.Advance" units="microseconds" <histogram name="Blink.SpatialNavigation.Advance" units="microseconds"
expires_after="M85"> expires_after="M85">
<obsolete> <obsolete>
......
...@@ -11734,6 +11734,12 @@ be describing additional metrics about the same event. ...@@ -11734,6 +11734,12 @@ be describing additional metrics about the same event.
the SMS verification flow. the SMS verification flow.
</summary> </summary>
</metric> </metric>
<metric name="TimeUserCancelMs">
<summary>
Records the duration from when the API is called to when the user presses
&quot;Deny&quot; to terminate the SMS verification flow.
</summary>
</metric>
</event> </event>
<event name="SSL.MixedContentShown"> <event name="SSL.MixedContentShown">
......
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