Commit 00b70ebf authored by Siyu An's avatar Siyu An Committed by Commit Bot

[Sticky Bubbles] Add logging for unknown bubble closing reason

We found in the metrics the number of (bubble shown) and number of
(bubble closed with reason) are not matched. I am suspecting in some cases
it will be logged before the close_reason is returned, and in this case
the reason will be unknown[1].

[1]https://source.chromium.org/chromium/chromium/src/+/master:chrome/browser/ui/views/autofill/payments/save_card_bubble_views.cc;l=123-134;drc=d9daac114a9f5c8a7bc99042d92f40dcd62c3d08

Added a logging to verify

Bug: 1070799
Change-Id: I8a0cb2eb4c4158d11fcd6593777ad568947812d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2441014
Commit-Queue: Siyu An <siyua@chromium.org>
Reviewed-by: default avatarJared Saul <jsaul@google.com>
Reviewed-by: default avatarEvan Stade <estade@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812574}
parent bc802c69
......@@ -112,30 +112,29 @@ void LocalCardMigrationBubbleControllerImpl::OnBubbleClosed(
// Log local card migration bubble result according to the closed reason.
if (base::FeatureList::IsEnabled(
features::kAutofillEnableFixedPaymentsBubbleLogging)) {
AutofillMetrics::LocalCardMigrationBubbleResultMetric metric;
switch (closed_reason) {
case PaymentsBubbleClosedReason::kAccepted:
AutofillMetrics::LogLocalCardMigrationBubbleResultMetric(
AutofillMetrics::LOCAL_CARD_MIGRATION_BUBBLE_ACCEPTED, is_reshow_);
return;
metric = AutofillMetrics::LOCAL_CARD_MIGRATION_BUBBLE_ACCEPTED;
break;
case PaymentsBubbleClosedReason::kClosed:
AutofillMetrics::LogLocalCardMigrationBubbleResultMetric(
AutofillMetrics::LOCAL_CARD_MIGRATION_BUBBLE_CLOSED, is_reshow_);
return;
metric = AutofillMetrics::LOCAL_CARD_MIGRATION_BUBBLE_CLOSED;
break;
case PaymentsBubbleClosedReason::kNotInteracted:
AutofillMetrics::LogLocalCardMigrationBubbleResultMetric(
AutofillMetrics::LOCAL_CARD_MIGRATION_BUBBLE_NOT_INTERACTED,
is_reshow_);
return;
metric = AutofillMetrics::LOCAL_CARD_MIGRATION_BUBBLE_NOT_INTERACTED;
break;
case PaymentsBubbleClosedReason::kLostFocus:
AutofillMetrics::LogLocalCardMigrationBubbleResultMetric(
AutofillMetrics::LOCAL_CARD_MIGRATION_BUBBLE_LOST_FOCUS,
is_reshow_);
return;
metric = AutofillMetrics::LOCAL_CARD_MIGRATION_BUBBLE_LOST_FOCUS;
break;
case PaymentsBubbleClosedReason::kUnknown:
metric = AutofillMetrics::LOCAL_CARD_MIGRATION_BUBBLE_RESULT_UNKNOWN;
break;
case PaymentsBubbleClosedReason::kCancelled:
NOTREACHED();
return;
}
AutofillMetrics::LogLocalCardMigrationBubbleResultMetric(metric,
is_reshow_);
}
}
......
......@@ -387,6 +387,21 @@ TEST_P(LocalCardMigrationBubbleLoggingTest, FirstShow_BubbleLostFocus) {
}
}
TEST_P(LocalCardMigrationBubbleLoggingTest, FirstShow_Unknown) {
base::HistogramTester histogram_tester;
ShowBubble();
CloseBubble(PaymentsBubbleClosedReason::kUnknown);
if (GetParam()) {
histogram_tester.ExpectUniqueSample(
"Autofill.LocalCardMigrationBubbleResult.FirstShow",
AutofillMetrics::LOCAL_CARD_MIGRATION_BUBBLE_RESULT_UNKNOWN, 1);
} else {
histogram_tester.ExpectTotalCount(
"Autofill.LocalCardMigrationBubbleResult.FirstShow", 0);
}
}
TEST_P(LocalCardMigrationBubbleLoggingTest, Reshows_BubbleAccepted) {
base::HistogramTester histogram_tester;
ShowBubble();
......@@ -471,6 +486,27 @@ TEST_P(LocalCardMigrationBubbleLoggingTest, Reshows_BubbleLostFocus) {
}
}
TEST_P(LocalCardMigrationBubbleLoggingTest, Reshows_Unknown) {
base::HistogramTester histogram_tester;
ShowBubble();
CloseAndReshowBubble();
CloseBubble(PaymentsBubbleClosedReason::kUnknown);
if (GetParam()) {
histogram_tester.ExpectUniqueSample(
"Autofill.LocalCardMigrationBubbleResult.FirstShow",
AutofillMetrics::LOCAL_CARD_MIGRATION_BUBBLE_NOT_INTERACTED, 1);
histogram_tester.ExpectUniqueSample(
"Autofill.LocalCardMigrationBubbleResult.Reshows",
AutofillMetrics::LOCAL_CARD_MIGRATION_BUBBLE_RESULT_UNKNOWN, 1);
} else {
histogram_tester.ExpectTotalCount(
"Autofill.LocalCardMigrationBubbleResult.FirstShow", 0);
histogram_tester.ExpectTotalCount(
"Autofill.LocalCardMigrationBubbleResult.Reshows", 0);
}
}
INSTANTIATE_TEST_SUITE_P(LocalCardMigrationBubbleControllerImplTest,
LocalCardMigrationBubbleLoggingTest,
::testing::Bool());
......
......@@ -515,8 +515,8 @@ void SaveCardBubbleControllerImpl::OnBubbleClosed(
metric = AutofillMetrics::SAVE_CARD_PROMPT_LOST_FOCUS;
break;
case PaymentsBubbleClosedReason::kUnknown:
NOTREACHED();
return;
metric = AutofillMetrics::SAVE_CARD_PROMPT_RESULT_UNKNOWN;
break;
}
AutofillMetrics::LogSaveCardPromptResultMetric(
metric, is_upload_save_, is_reshow_, options_,
......
......@@ -1140,6 +1140,19 @@ TEST_P(SaveCardBubbleLoggingTest, Metrics_LostFocus) {
AutofillMetrics::SAVE_CARD_PROMPT_LOST_FOCUS, 1);
}
TEST_P(SaveCardBubbleLoggingTest, Metrics_Unknown) {
if (!metrics_revamp_experiment_enabled_)
return;
base::HistogramTester histogram_tester;
TriggerFlow();
CloseBubble(PaymentsBubbleClosedReason::kUnknown);
histogram_tester.ExpectUniqueSample(
"Autofill.SaveCreditCardPromptResult" + GetHistogramNameSuffix(),
AutofillMetrics::SAVE_CARD_PROMPT_RESULT_UNKNOWN, 1);
}
TEST_P(SaveCardBubbleLoggingTest, Metrics_SecurityLevel) {
base::HistogramTester histogram_tester;
controller()->set_security_level(security_state::SecurityLevel::SECURE);
......
......@@ -255,6 +255,9 @@ class AutofillMetrics {
SAVE_CARD_PROMPT_NOT_INTERACTED,
// The prompt lost focus and was deactivated.
SAVE_CARD_PROMPT_LOST_FOCUS,
// The reason why the prompt is closed is not clear. Possible reason is the
// logging function is invoked before the closed reason is correctly set.
SAVE_CARD_PROMPT_RESULT_UNKNOWN,
NUM_SAVE_CARD_PROMPT_RESULT_METRICS,
};
......@@ -568,6 +571,9 @@ class AutofillMetrics {
LOCAL_CARD_MIGRATION_BUBBLE_NOT_INTERACTED = 2,
// The bubble lost its focus and was deactivated.
LOCAL_CARD_MIGRATION_BUBBLE_LOST_FOCUS = 3,
// The reason why the prompt is closed is not clear. Possible reason is the
// logging function is invoked before the closed reason is correctly set.
LOCAL_CARD_MIGRATION_BUBBLE_RESULT_UNKNOWN = 4,
NUM_LOCAL_CARD_MIGRATION_BUBBLE_RESULT_METRICS,
};
......
......@@ -5217,6 +5217,7 @@ Unknown properties are collapsed to zero. -->
<int value="1" label="User explicitly closed the the bubble"/>
<int value="2" label="User did not interact with the bubble"/>
<int value="3" label="Bubble lost focus and was deactivated"/>
<int value="4" label="Bubble result unknown"/>
</enum>
<enum name="AutofillLocalCardMigrationBubbleUserInteraction">
......@@ -5397,6 +5398,7 @@ Unknown properties are collapsed to zero. -->
<int value="2" label="Closed"/>
<int value="3" label="Not interacted"/>
<int value="4" label="Lost focus"/>
<int value="5" label="Unknown"/>
</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