Skip to content

Commit

Permalink
[AF] Use FillingProduct in LogAutofillSelectedManageEntry.
Browse files Browse the repository at this point in the history
This CL touches the following metric:
* Autofill.SuggestionsListManageClicked

No effect on the metric is expected because:
* "Manage ..." suggestion is added only when first layer autofill
(address or credit card) suggestions are shown.
This CL also adds a CHECK to verify that the main filling product of
the popup is either kAddress or kCreditCard when the "Manage ..." is
accepted.

Bug: b:316859406
Change-Id: I95890573ffacb8225084d8b07f93c3938b2378f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5147308
Commit-Queue: Timofey Chudakov <tchudakov@google.com>
Reviewed-by: Jan Keitel <jkeitel@google.com>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#1243871}
  • Loading branch information
Timofey Chudakov authored and Chromium LUCI CQ committed Jan 7, 2024
1 parent fdee5cc commit 7b1d9f2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -509,11 +509,16 @@ void AutofillExternalDelegate::DidAcceptSuggestion(
return;
}
switch (suggestion.popup_item_id) {
case PopupItemId::kAutofillOptions:
case PopupItemId::kAutofillOptions: {
// User selected 'Autofill Options'.
autofill_metrics::LogAutofillSelectedManageEntry(popup_type_);
const FillingProduct main_filling_product = GetMainFillingProduct();
CHECK(main_filling_product == FillingProduct::kAddress ||
main_filling_product == FillingProduct::kCreditCard ||
main_filling_product == FillingProduct::kIban);
autofill_metrics::LogAutofillSelectedManageEntry(main_filling_product);
manager_->client().ShowAutofillSettings(popup_type_);
break;
}
case PopupItemId::kEditAddressProfile: {
ShowEditAddressProfileDialog(
suggestion.GetBackendId<Suggestion::Guid>().value());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,24 @@
#include "base/metrics/user_metrics.h"
#include "components/autofill/core/browser/filling_product.h"
#include "components/autofill/core/browser/metrics/autofill_metrics.h"
#include "components/autofill/core/browser/ui/popup_types.h"

namespace autofill::autofill_metrics {
namespace {

ManageSuggestionType ToManageSuggestionType(PopupType popup_type) {
ManageSuggestionType ToManageSuggestionType(FillingProduct popup_type) {
switch (popup_type) {
case PopupType::kAddresses:
case FillingProduct::kAddress:
return ManageSuggestionType::kAddresses;
case PopupType::kCreditCards:
case FillingProduct::kCreditCard:
return ManageSuggestionType::kPaymentMethodsCreditCards;
case PopupType::kIbans:
case FillingProduct::kIban:
return ManageSuggestionType::kPaymentMethodsIbans;
case PopupType::kPasswords:
ABSL_FALLTHROUGH_INTENDED;
case PopupType::kAutocomplete:
case PopupType::kUnspecified:
case FillingProduct::kAutocomplete:
case FillingProduct::kCompose:
case FillingProduct::kMerchantPromoCode:
case FillingProduct::kPassword:
case FillingProduct::kPlusAddresses:
case FillingProduct::kNone:
return ManageSuggestionType::kOther;
}
}
Expand Down Expand Up @@ -66,8 +67,8 @@ void LogAutofillSuggestionAcceptedIndex(int index,
off_the_record);
}

void LogAutofillSelectedManageEntry(PopupType popup_type) {
const ManageSuggestionType uma_type = ToManageSuggestionType(popup_type);
void LogAutofillSelectedManageEntry(FillingProduct filling_product) {
const ManageSuggestionType uma_type = ToManageSuggestionType(filling_product);
base::UmaHistogramEnumeration("Autofill.SuggestionsListManageClicked",
uma_type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#define COMPONENTS_AUTOFILL_CORE_BROWSER_METRICS_SUGGESTIONS_LIST_METRICS_H_

namespace autofill {
enum class PopupType;
enum class FillingProduct;

namespace autofill_metrics {
Expand Down Expand Up @@ -45,7 +44,7 @@ void LogAutofillSuggestionAcceptedIndex(int index,
bool off_the_record);

// Logs that the user selected 'Manage...' settings entry in the popup.
void LogAutofillSelectedManageEntry(autofill::PopupType popup_type);
void LogAutofillSelectedManageEntry(FillingProduct filling_product);

// Logs the 'Show cards from your Google Account" button events.
void LogAutofillShowCardsFromGoogleAccountButtonEventMetric(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ TEST(SuggestionsListMetricsTest, LogSuggestionAcceptedIndex_Other) {

TEST(SuggestionsListMetricsTest, LogAutofillSelectedManageEntry_Addresses) {
base::HistogramTester histogram_tester;
LogAutofillSelectedManageEntry(PopupType::kAddresses);
LogAutofillSelectedManageEntry(FillingProduct::kAddress);
EXPECT_THAT(
histogram_tester.GetAllSamples("Autofill.SuggestionsListManageClicked"),
BucketsAre(base::Bucket(ManageSuggestionType::kAddresses, 1)));
Expand All @@ -81,7 +81,7 @@ TEST(SuggestionsListMetricsTest, LogAutofillSelectedManageEntry_Addresses) {
TEST(SuggestionsListMetricsTest,
LogAutofillSelectedManageEntry_PaymentMethodsCreditCards) {
base::HistogramTester histogram_tester;
LogAutofillSelectedManageEntry(PopupType::kCreditCards);
LogAutofillSelectedManageEntry(FillingProduct::kCreditCard);
EXPECT_THAT(
histogram_tester.GetAllSamples("Autofill.SuggestionsListManageClicked"),
BucketsAre(
Expand All @@ -91,16 +91,16 @@ TEST(SuggestionsListMetricsTest,
TEST(SuggestionsListMetricsTest,
LogAutofillSelectedManageEntry_PaymentMethodsIbans) {
base::HistogramTester histogram_tester;
LogAutofillSelectedManageEntry(PopupType::kIbans);
LogAutofillSelectedManageEntry(FillingProduct::kIban);
EXPECT_THAT(
histogram_tester.GetAllSamples("Autofill.SuggestionsListManageClicked"),
BucketsAre(base::Bucket(ManageSuggestionType::kPaymentMethodsIbans, 1)));
}

TEST(SuggestionsListMetricsTest, LogAutofillSelectedManageEntry_Other) {
base::HistogramTester histogram_tester;
LogAutofillSelectedManageEntry(PopupType::kUnspecified);
LogAutofillSelectedManageEntry(PopupType::kPasswords);
LogAutofillSelectedManageEntry(FillingProduct::kNone);
LogAutofillSelectedManageEntry(FillingProduct::kPassword);
EXPECT_THAT(
histogram_tester.GetAllSamples("Autofill.SuggestionsListManageClicked"),
BucketsAre(base::Bucket(ManageSuggestionType::kOther, 2)));
Expand Down

0 comments on commit 7b1d9f2

Please sign in to comment.