Commit 5ba4cd16 authored by Jared Saul's avatar Jared Saul Committed by Commit Bot

[Autofill] Log metric when CC omnibox icon is shown but not prompt

When a card has max strikes on desktop, instead of showing the
offer-to-save bubble, only the omnibox icon is shown. This metric tracks
these occurrences.

Bug: 884817
Change-Id: I43f5cf0b1c9d6a3431790e8a2788bbf489fcdbe6
Reviewed-on: https://chromium-review.googlesource.com/c/1330898Reviewed-by: default avatarFabio Tirelo <ftirelo@chromium.org>
Commit-Queue: Jared Saul <jsaul@google.com>
Cr-Commit-Position: refs/heads/master@{#607414}
parent f2f1286b
......@@ -635,7 +635,13 @@ void SaveCardBubbleControllerImpl::ShowIconOnly() {
switch (current_bubble_type_) {
case BubbleType::UPLOAD_SAVE:
case BubbleType::LOCAL_SAVE:
// TODO(crbug/884817): Log metrics for "bubble not shown".
AutofillMetrics::LogSaveCardPromptMetric(
AutofillMetrics::SAVE_CARD_ICON_SHOWN_WITHOUT_PROMPT, is_upload_save_,
is_reshow_, should_request_name_from_user_,
should_request_expiration_date_from_user_,
pref_service_->GetInteger(
prefs::kAutofillAcceptSaveCreditCardPromptState),
GetSecurityLevel());
break;
case BubbleType::MANAGE_CARDS:
case BubbleType::SIGN_IN_PROMO:
......
......@@ -94,7 +94,8 @@ class SaveCardBubbleControllerImplTest : public BrowserWithTestWindowTest {
void SetLegalMessage(const std::string& message_json,
bool should_request_name_from_user = false,
bool should_request_expiration_date_from_user = false) {
bool should_request_expiration_date_from_user = false,
bool show_bubble = true) {
std::unique_ptr<base::Value> value(base::JSONReader::Read(message_json));
ASSERT_TRUE(value);
base::DictionaryValue* dictionary;
......@@ -103,28 +104,29 @@ class SaveCardBubbleControllerImplTest : public BrowserWithTestWindowTest {
dictionary->CreateDeepCopy();
controller()->OfferUploadSave(
CreditCard(), std::move(legal_message), should_request_name_from_user,
should_request_expiration_date_from_user,
/*show_bubble=*/true, base::BindOnce(&UploadSaveCardCallback));
should_request_expiration_date_from_user, show_bubble,
base::BindOnce(&UploadSaveCardCallback));
}
void ShowLocalBubble(CreditCard* card = nullptr) {
void ShowLocalBubble(CreditCard* card = nullptr, bool show_bubble = true) {
// TODO(crbug.com/852562): Migrate this to BindOnce/OnceClosure.
controller()->OfferLocalSave(
card ? CreditCard(*card)
: autofill::test::GetCreditCard(), // Visa by default
/*show_bubble=*/true, base::BindOnce(&LocalSaveCardCallback));
show_bubble, base::BindOnce(&LocalSaveCardCallback));
}
void ShowUploadBubble(bool should_request_name_from_user = false,
bool should_request_expiration_date_from_user = false) {
bool should_request_expiration_date_from_user = false,
bool show_bubble = true) {
SetLegalMessage(
"{"
" \"line\" : [ {"
" \"template\": \"This is the entire message.\""
" } ]"
"}",
should_request_name_from_user,
should_request_expiration_date_from_user);
should_request_name_from_user, should_request_expiration_date_from_user,
show_bubble);
}
void CloseAndReshowBubble() {
......@@ -298,6 +300,26 @@ TEST_F(SaveCardBubbleControllerImplTest,
Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOWN, 1)));
}
TEST_F(SaveCardBubbleControllerImplTest, Metrics_Local_ShowBubbleFalse) {
base::HistogramTester histogram_tester;
ShowLocalBubble(/*card=*/nullptr, /*show_bubble=*/false);
histogram_tester.ExpectUniqueSample(
"Autofill.SaveCreditCardPrompt.Local.FirstShow",
AutofillMetrics::SAVE_CARD_ICON_SHOWN_WITHOUT_PROMPT, 1);
}
TEST_F(SaveCardBubbleControllerImplTest, Metrics_Upload_ShowBubbleFalse) {
base::HistogramTester histogram_tester;
ShowUploadBubble(/*should_request_name_from_user=*/false,
/*should_request_expiration_date_from_user=*/false,
/*show_bubble=*/false);
histogram_tester.ExpectUniqueSample(
"Autofill.SaveCreditCardPrompt.Upload.FirstShow",
AutofillMetrics::SAVE_CARD_ICON_SHOWN_WITHOUT_PROMPT, 1);
}
TEST_F(SaveCardBubbleControllerImplTest, Metrics_Local_FirstShow_SaveButton) {
ShowLocalBubble();
......
......@@ -261,6 +261,10 @@ class AutofillMetrics {
// The prompt was dismissed because the user clicked a legal message link.
SAVE_CARD_PROMPT_CVC_FIX_FLOW_DISMISS_CLICK_LEGAL_MESSAGE,
// The save card bubble was not shown due to the card having too many
// offer-to-save strikes, but the omnibox icon was still displayed.
SAVE_CARD_ICON_SHOWN_WITHOUT_PROMPT,
NUM_SAVE_CARD_PROMPT_METRICS,
};
......
......@@ -3051,6 +3051,7 @@ uploading your change for review. These are checked by presubmit scripts.
label="CVC fix flow ended, navigated away from page while prompt hidden"/>
<int value="13"
label="CVC fix flow dismissed, user clicked a legal message link"/>
<int value="14" label="Omnibox icon shown, but not bubble (max strikes)"/>
</enum>
<enum name="AutofillSaveType">
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