Skip to content

Commit

Permalink
[AF][Nickname] Clean up the Phase 1 histogram logging
Browse files Browse the repository at this point in the history
Remove server nickname metrics logging since the feature is fully
enabled and we don't need to maintain metrics for analysis post launch.

Bug: 1059087
Change-Id: I07a6b8a0fc277bcf7634a26842930ed0d5978316
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2495794
Commit-Queue: Sujie Zhu <sujiezhu@google.com>
Reviewed-by: Jared Saul <jsaul@google.com>
Reviewed-by: Brian White <bcwhite@chromium.org>
Reviewed-by: Siyu An <siyua@chromium.org>
Reviewed-by: Dominic Battré <battre@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821985}
  • Loading branch information
SujieZhu authored and Commit Bot committed Oct 29, 2020
1 parent 3f60315 commit 82ef7f0
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 398 deletions.
354 changes: 0 additions & 354 deletions components/autofill/core/browser/autofill_metrics_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,6 @@ class AutofillMetricsTest : public testing::Test {
bool include_masked_server_credit_card,
bool include_full_server_credit_card);

// Creates a masked server card with a nickname, and adds it to existing
// credit card list.
void AddMaskedServerCreditCardWithNickname();

void AddMaskedServerCreditCardWithOffer(std::string guid,
std::string offer_reward_amount,
GURL url,
Expand Down Expand Up @@ -565,13 +561,6 @@ void AutofillMetricsTest::RecreateCreditCards(
personal_data_->Refresh();
}

void AutofillMetricsTest::AddMaskedServerCreditCardWithNickname() {
CreditCard masked_server_credit_card =
test::GetMaskedServerCardWithNickname();
personal_data_->AddServerCreditCard(masked_server_credit_card);
personal_data_->Refresh();
}

void AutofillMetricsTest::AddMaskedServerCreditCardWithOffer(
std::string guid,
std::string offer_reward_amount,
Expand Down Expand Up @@ -6477,349 +6466,6 @@ TEST_P(AutofillMetricsIFrameTest, CreditCardWillSubmitFormEvents) {
}
}

// Test that we log form events for masked server card nickname.
// TODO(crbug.com/1059087): Remove histogram logging for server nickname.
TEST_F(AutofillMetricsTest, LogServerNicknameFormEvents) {
// Set up our form data.
FormData form;
form.name = ASCIIToUTF16("TestForm");
form.url = GURL("http://example.com/form.html");
form.action = GURL("http://example.com/submit.html");
form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin());

FormFieldData field;
std::vector<ServerFieldType> field_types;
test::CreateTestFormField("Month", "card_month", "", "text", &field);
form.fields.push_back(field);
field_types.push_back(CREDIT_CARD_EXP_MONTH);
test::CreateTestFormField("Year", "card_year", "", "text", &field);
form.fields.push_back(field);
field_types.push_back(CREDIT_CARD_EXP_2_DIGIT_YEAR);
test::CreateTestFormField("Credit card", "card", "", "text", &field);
form.fields.push_back(field);
field_types.push_back(CREDIT_CARD_NUMBER);

// Creating all kinds of cards. None of them has nicknames.
RecreateCreditCards(true /* include_local_credit_card */,
true /* include_masked_server_credit_card */,
true /* include_full_server_credit_card */);

// Simulate having seen this form on page load.
autofill_manager_->AddSeenForm(form, field_types, field_types);

{
// A masked server card with nickname.
// Simulating activating the autofill popup for the credit card field, new
// popup being shown and filling a local card suggestion.
base::HistogramTester histogram_tester;
autofill_manager_->OnQueryFormFieldAutofill(
0, form, field, gfx::RectF(), /*autoselect_first_suggestion=*/false);
autofill_manager_->DidShowSuggestions(true /* is_new_popup */, form, field);
std::string guid("10000000-0000-0000-0000-000000000001"); // local card
autofill_manager_->FillOrPreviewForm(
AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(),
autofill_manager_->MakeFrontendIDForTest(guid, std::string()));
histogram_tester.ExpectBucketCount("Autofill.FormEvents.CreditCard",
FORM_EVENT_SUGGESTIONS_SHOWN, 1);
histogram_tester.ExpectBucketCount("Autofill.FormEvents.CreditCard",
FORM_EVENT_SUGGESTIONS_SHOWN_ONCE, 1);
histogram_tester.ExpectBucketCount("Autofill.FormEvents.CreditCard",
FORM_EVENT_LOCAL_SUGGESTION_FILLED, 1);
// Check that the nickname sub-histogram was not recorded.
// ExpectBucketCount() can't be used here because it expects the histogram
// to exist.
EXPECT_EQ(0, histogram_tester.GetTotalCountsForPrefix(
"Autofill.FormEvents.CreditCard")
["Autofill.FormEvents.CreditCard.WithServerNickname"]);
}

// Add another masked server card with nickname.
AddMaskedServerCreditCardWithNickname();
// Reset the autofill manager state.
autofill_manager_->Reset();
autofill_manager_->AddSeenForm(form, field_types, field_types);

{
// A masked server card with nickname.
// Simulating activating the autofill popup for the credit card field, new
// popup being shown and filling a local card suggestion. Both general
// histogram and nickname sub-histogram are logged.
base::HistogramTester histogram_tester;
autofill_manager_->OnQueryFormFieldAutofill(
0, form, field, gfx::RectF(), /*autoselect_first_suggestion=*/false);
autofill_manager_->DidShowSuggestions(true /* is_new_popup */, form, field);
// Select the local card, still log to sub-histogram because user has
// another masked servr card with nickname.
std::string guid("10000000-0000-0000-0000-000000000001");
autofill_manager_->FillOrPreviewForm(
AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(),
autofill_manager_->MakeFrontendIDForTest(guid, std::string()));
// The general credit card form event historgram is still logged.
histogram_tester.ExpectBucketCount("Autofill.FormEvents.CreditCard",
FORM_EVENT_SUGGESTIONS_SHOWN, 1);
histogram_tester.ExpectBucketCount("Autofill.FormEvents.CreditCard",
FORM_EVENT_SUGGESTIONS_SHOWN_ONCE, 1);
histogram_tester.ExpectBucketCount("Autofill.FormEvents.CreditCard",
FORM_EVENT_LOCAL_SUGGESTION_FILLED, 1);
// Sub-histogratm CreditCard.WithServerNickname is also logged
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.CreditCard.WithServerNickname",
FORM_EVENT_SUGGESTIONS_SHOWN, 1);
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.CreditCard.WithServerNickname",
FORM_EVENT_SUGGESTIONS_SHOWN_ONCE, 1);
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.CreditCard.WithServerNickname",
FORM_EVENT_LOCAL_SUGGESTION_FILLED, 1);
}

// Reset the autofill manager state.
autofill_manager_->Reset();
autofill_manager_->AddSeenForm(form, field_types, field_types);

{
// A masked server card with nickname.
// Simulating activating the autofill popup for the credit card field, new
// popup being shown, selecting a masked card server suggestion and
// submitting the form. Verify that all related form events are correctly
// logged to nickname sub-histogram.
base::HistogramTester histogram_tester;
autofill_manager_->OnQueryFormFieldAutofill(
0, form, field, gfx::RectF(), /*autoselect_first_suggestion=*/false);
autofill_manager_->DidShowSuggestions(true /* is_new_popup */, form, field);
// Select the masked server card without nickname, still log to nickname
// sub-histogram because user has another masked server card with nickname.
std::string guid("10000000-0000-0000-0000-000000000002");
autofill_manager_->FillOrPreviewForm(
AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.back(),
autofill_manager_->MakeFrontendIDForTest(guid, std::string()));
OnDidGetRealPan(AutofillClient::SUCCESS, "6011000990139424");
autofill_manager_->OnFormSubmitted(form, false,
SubmissionSource::FORM_SUBMISSION);
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.CreditCard.WithServerNickname",
FORM_EVENT_INTERACTED_ONCE, 1);
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.CreditCard.WithServerNickname",
FORM_EVENT_SUGGESTIONS_SHOWN, 1);
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.CreditCard.WithServerNickname",
FORM_EVENT_SUGGESTIONS_SHOWN_ONCE, 1);
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.CreditCard.WithServerNickname",
FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED, 1);
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.CreditCard.WithServerNickname",
FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED_ONCE, 1);
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.CreditCard.WithServerNickname",
FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED, 1);
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.CreditCard.WithServerNickname",
FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED_ONCE, 1);
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.CreditCard.WithServerNickname",
FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SUBMITTED_ONCE, 1);
}
}

// Test that we log suggestion selection duration for masked server card
// nickname.
// TODO(crbug.com/1059087): Remove histogram logging for server nickname.
TEST_F(AutofillMetricsTest, LogServerNicknameSelectionDuration) {
base::TimeTicks now = AutofillTickClock::NowTicks();
TestAutofillTickClock test_clock;
test_clock.SetNowTicks(now);

// Set up our form data.
FormData form;
form.name = ASCIIToUTF16("TestForm");
form.url = GURL("http://example.com/form.html");
form.action = GURL("http://example.com/submit.html");
form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin());

FormFieldData field;
std::vector<ServerFieldType> field_types;
test::CreateTestFormField("Month", "card_month", "", "text", &field);
form.fields.push_back(field);
field_types.push_back(CREDIT_CARD_EXP_MONTH);
test::CreateTestFormField("Year", "card_year", "", "text", &field);
form.fields.push_back(field);
field_types.push_back(CREDIT_CARD_EXP_2_DIGIT_YEAR);
test::CreateTestFormField("Credit card", "card", "", "text", &field);
form.fields.push_back(field);
field_types.push_back(CREDIT_CARD_NUMBER);

// Creating all kinds of cards. None of them have nicknames.
RecreateCreditCards(true /* include_local_credit_card */,
true /* include_masked_server_credit_card */,
true /* include_full_server_credit_card */);

// Simulate having seen this form on page load.
autofill_manager_->AddSeenForm(form, field_types, field_types);

{
// No masked server card has nickname.
// Simulating activating the autofill popup for the credit card field, new
// popup being shown and filling a local card suggestion.
base::HistogramTester histogram_tester;
autofill_manager_->OnQueryFormFieldAutofill(
0, form, field, gfx::RectF(), /*autoselect_first_suggestion=*/false);
autofill_manager_->DidShowSuggestions(true /* is_new_popup */, form, field);
// Simulate choosing a suggestion after 1 second.
base::TimeDelta selection_delta = base::TimeDelta::FromSeconds(1);
test_clock.SetNowTicks(now + selection_delta);
std::string guid("10000000-0000-0000-0000-000000000001"); // local card
autofill_manager_->FillOrPreviewForm(
AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(),
autofill_manager_->MakeFrontendIDForTest(guid, std::string()));
// Check that the nickname sub-histogram was not recorded.
histogram_tester.ExpectTotalCount(
"Autofill.FormEvents.CreditCard.WithServerNickname.SelectionDuration",
0);
}

// Add another masked server card with nickname.
AddMaskedServerCreditCardWithNickname();
// Reset the autofill manager state.
autofill_manager_->Reset();
autofill_manager_->AddSeenForm(form, field_types, field_types);

{
// A masked server card with nickname.
// Simulating activating the autofill popup for the credit card field, new
// popup being shown and filling a local card suggestion.
base::HistogramTester histogram_tester;
test_clock.SetNowTicks(now);
autofill_manager_->OnQueryFormFieldAutofill(
0, form, field, gfx::RectF(), /*autoselect_first_suggestion=*/false);
autofill_manager_->DidShowSuggestions(true /* is_new_popup */, form, field);
// Simulate choosing a suggestion after 1 second.
base::TimeDelta selection_delta = base::TimeDelta::FromSeconds(1);
test_clock.SetNowTicks(now + selection_delta);
// Select the local card, log nickname selection duration because user has
// another masked servr card with nickname.
std::string guid("10000000-0000-0000-0000-000000000001");
autofill_manager_->FillOrPreviewForm(
AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(),
autofill_manager_->MakeFrontendIDForTest(guid, std::string()));
histogram_tester.ExpectTotalCount(
"Autofill.FormEvents.CreditCard.WithServerNickname.SelectionDuration",
1);
histogram_tester.ExpectTimeBucketCount(
"Autofill.FormEvents.CreditCard.WithServerNickname.SelectionDuration",
selection_delta, 1);
}

// Reset the autofill manager state.
autofill_manager_->Reset();
autofill_manager_->AddSeenForm(form, field_types, field_types);

{
// A masked server card with nickname.
// Simulating activating the autofill popup for the credit card field, new
// popup being shown and selecting a masked card server suggestion.
base::HistogramTester histogram_tester;
test_clock.SetNowTicks(now);
autofill_manager_->OnQueryFormFieldAutofill(
0, form, field, gfx::RectF(), /*autoselect_first_suggestion=*/false);
autofill_manager_->DidShowSuggestions(true /* is_new_popup */, form, field);
// Simulate choosing a suggestion after 1 second.
base::TimeDelta selection_delta = base::TimeDelta::FromSeconds(1);
test_clock.SetNowTicks(now + selection_delta);
// Select the masked server card without nickname, still log select
// duration, even though GetRealPan fails afterwards, because user has
// another masked server card with nickname.
std::string guid("10000000-0000-0000-0000-000000000002");
autofill_manager_->FillOrPreviewForm(
AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.back(),
autofill_manager_->MakeFrontendIDForTest(guid, std::string()));
OnDidGetRealPan(AutofillClient::PERMANENT_FAILURE, std::string());
histogram_tester.ExpectTotalCount(
"Autofill.FormEvents.CreditCard.WithServerNickname.SelectionDuration",
1);
histogram_tester.ExpectTimeBucketCount(
"Autofill.FormEvents.CreditCard.WithServerNickname.SelectionDuration",
selection_delta, 1);
}

// Reset the autofill manager state.
autofill_manager_->Reset();
autofill_manager_->AddSeenForm(form, field_types, field_types);

{
// A masked server card with nickname.
// Simulating suggestions are shown twice, then choosing a local card.
base::HistogramTester histogram_tester;
test_clock.SetNowTicks(now);
autofill_manager_->OnQueryFormFieldAutofill(
0, form, field, gfx::RectF(), /*autoselect_first_suggestion=*/false);
autofill_manager_->DidShowSuggestions(true /* is_new_popup */, form, field);
// Simulate the first popup was dismissed and the second popup is shown
// after 1 second.
base::TimeDelta suggestion_delta = base::TimeDelta::FromSeconds(1);
test_clock.SetNowTicks(now + suggestion_delta);
autofill_manager_->DidShowSuggestions(true /* is_new_popup */, form, field);
// Simulate choosing a suggestion on the second popup after 2 seconds.
// The overall selection duration will be 3 seconds, between the first time
// suggestion was shown and the first card is chosen.
base::TimeDelta total_selection_delta =
suggestion_delta + base::TimeDelta::FromSeconds(2);
test_clock.SetNowTicks(now + total_selection_delta);
std::string guid("10000000-0000-0000-0000-000000000001"); // local card
autofill_manager_->FillOrPreviewForm(
AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.back(),
autofill_manager_->MakeFrontendIDForTest(guid, std::string()));
histogram_tester.ExpectTotalCount(
"Autofill.FormEvents.CreditCard.WithServerNickname.SelectionDuration",
1);
histogram_tester.ExpectTimeBucketCount(
"Autofill.FormEvents.CreditCard.WithServerNickname.SelectionDuration",
total_selection_delta, 1);
}

// Reset the autofill manager state.
autofill_manager_->Reset();
autofill_manager_->AddSeenForm(form, field_types, field_types);

{
// A masked server card with nickname.
// Simulating suggestions being shown and selecting masked server card
// multiple times.
base::HistogramTester histogram_tester;
test_clock.SetNowTicks(now);
autofill_manager_->OnQueryFormFieldAutofill(
0, form, field, gfx::RectF(), /*autoselect_first_suggestion=*/false);
autofill_manager_->DidShowSuggestions(true /* is_new_popup */, form, field);
// Simulate the first selection happens 1 second after suggestion is shown.
base::TimeDelta first_suggestion_delta = base::TimeDelta::FromSeconds(1);
test_clock.SetNowTicks(now + first_suggestion_delta);
std::string guid1(
"10000000-0000-0000-0000-000000000002"); // masked server card
autofill_manager_->FillOrPreviewForm(
AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.back(),
autofill_manager_->MakeFrontendIDForTest(guid1, std::string()));
// Simulate choosing another local card 2 seconds after user chooses the
// server card.
base::TimeDelta second_selection_delta =
first_suggestion_delta + base::TimeDelta::FromSeconds(2);
test_clock.SetNowTicks(now + second_selection_delta);
std::string guid2("10000000-0000-0000-0000-000000000001"); // local card
autofill_manager_->FillOrPreviewForm(
AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.back(),
autofill_manager_->MakeFrontendIDForTest(guid2, std::string()));
// The selection duration should be only logged once.
histogram_tester.ExpectTotalCount(
"Autofill.FormEvents.CreditCard.WithServerNickname.SelectionDuration",
1);
// The logged selection duration should be 1 second, between the suggestion
// was shown and the first card is chosen.
histogram_tester.ExpectTimeBucketCount(
"Autofill.FormEvents.CreditCard.WithServerNickname.SelectionDuration",
first_suggestion_delta, 1);
}
}

// Test that we log form events for masked server card with offers.
TEST_F(AutofillMetricsTest, LogServerOfferFormEvents) {
scoped_feature_list_.InitAndEnableFeature(
Expand Down
Loading

0 comments on commit 82ef7f0

Please sign in to comment.