Commit 3c69a5ee authored by Yi Gu's avatar Yi Gu Committed by Chromium LUCI CQ

[WebOTP] Record metrics when the verification backend is not available

Similar to other outcomes, we'd like to record when the new backend is
not available to help with debugging the browser code API.

Bug: 1127397
Change-Id: I9354a9a637bff19968f3cc53638950f5cfc6e335
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2566349
Commit-Queue: Yi Gu <yigu@chromium.org>
Reviewed-by: default avatarKen Buchanan <kenrb@chromium.org>
Reviewed-by: default avatarMajid Valipour <majidvp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833393}
parent 63e592f5
......@@ -871,6 +871,37 @@ IN_PROC_BROWSER_TEST_F(SmsBrowserTest, RecordTimeoutAsOutcome) {
ExpectOutcomeUKM(url, blink::WebOTPServiceOutcome::kTimeout);
}
IN_PROC_BROWSER_TEST_F(SmsBrowserTest, RecordBackendNotAvailableAsOutcome) {
GURL url = GetTestUrl(nullptr, "simple_page.html");
EXPECT_TRUE(NavigateToURL(shell(), url));
auto provider = std::make_unique<MockSmsProvider>();
MockSmsProvider* mock_provider_ptr = provider.get();
BrowserMainLoop::GetInstance()->SetSmsProviderForTesting(std::move(provider));
shell()->web_contents()->SetDelegate(&delegate_);
EXPECT_CALL(*mock_provider_ptr, Retrieve(_))
.WillOnce(Invoke([&mock_provider_ptr]() {
mock_provider_ptr->NotifyFailure(FailureType::kBackendNotAvailable);
}));
base::RunLoop ukm_loop;
// Wait for UKM to be recorded to avoid race condition between outcome
// capture and evaluation.
ukm_recorder()->SetOnAddEntryCallback(Entry::kEntryName,
ukm_loop.QuitClosure());
EXPECT_TRUE(ExecJs(shell(), R"(
navigator.credentials.get({otp: {transport: ["sms"]}});
)"));
ukm_loop.Run();
ExpectOutcomeUKM(url, blink::WebOTPServiceOutcome::kBackendNotAvailable);
}
IN_PROC_BROWSER_TEST_F(SmsBrowserTest,
NotRecordFailureForMultiplePendingOrigins) {
auto provider = std::make_unique<MockSmsProvider>();
......
......@@ -18,7 +18,8 @@ enum class WebOTPServiceOutcome {
kAborted = 4,
kTimeout = 5,
kUserCancelled = 6,
kMaxValue = kUserCancelled
kBackendNotAvailable = 7,
kMaxValue = kBackendNotAvailable
};
} // namespace blink
......
......@@ -684,10 +684,15 @@ void OnSmsReceive(ScriptPromiseResolver* resolver,
// Similar to kTimeout, the promise is not rejected here.
return;
} else if (status == mojom::blink::SmsStatus::kBackendNotAvailable) {
// Records when the backend is not available AND the request gets cancelled.
// i.e. client specifies GmsBackend.VERIFICATION but it's unavailable. If
// client specifies GmsBackend.AUTO and the verification backend is not
// available, we fall back to the user consent backend and the request will
// be handled accordingly. e.g. if the user declined the prompt, we record
// it as |kUserCancelled|.
RecordSmsOutcome(WebOTPServiceOutcome::kBackendNotAvailable, source_id,
recorder);
// Similar to kTimeout, the promise is not rejected here.
// TODO(yigu): Add UMA to better understand this.
// http://crbug.com/1141024
return;
}
RecordSmsSuccessTime(base::TimeTicks::Now() - start_time, source_id,
......
......@@ -76958,6 +76958,7 @@ others/histograms.xml -->
<int value="4" label="Aborted"/>
<int value="5" label="Timeout"/>
<int value="6" label="UserCancelled"/>
<int value="7" label="BackendNotAvailable"/>
</enum>
<enum name="WebpDecodedFormat">
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