From 3b6983541394f19570dfcce045e73a87b7ca29e2 Mon Sep 17 00:00:00 2001 From: vasilii Date: Tue, 21 Jun 2016 02:43:53 -0700 Subject: [PATCH] Add a histogram to count empty and/or duplicate usernames in the account chooser. BUG=400674 Review-Url: https://codereview.chromium.org/2077933002 Cr-Commit-Position: refs/heads/master@{#400935} --- ...credential_manager_pending_request_task.cc | 30 +++++++++++++++++++ .../browser/password_manager_metrics_util.cc | 5 ++++ .../browser/password_manager_metrics_util.h | 11 +++++++ tools/metrics/histograms/histograms.xml | 15 ++++++++++ 4 files changed, 61 insertions(+) diff --git a/components/password_manager/core/browser/credential_manager_pending_request_task.cc b/components/password_manager/core/browser/credential_manager_pending_request_task.cc index a852003e954153..26fb40ecd68e11 100644 --- a/components/password_manager/core/browser/credential_manager_pending_request_task.cc +++ b/components/password_manager/core/browser/credential_manager_pending_request_task.cc @@ -4,18 +4,46 @@ #include "components/password_manager/core/browser/credential_manager_pending_request_task.h" +#include #include #include "components/autofill/core/common/password_form.h" #include "components/password_manager/core/browser/affiliated_match_helper.h" #include "components/password_manager/core/browser/password_bubble_experiment.h" #include "components/password_manager/core/browser/password_manager_client.h" +#include "components/password_manager/core/browser/password_manager_metrics_util.h" #include "components/password_manager/core/browser/password_manager_util.h" #include "components/password_manager/core/common/credential_manager_types.h" #include "url/gurl.h" #include "url/origin.h" namespace password_manager { +namespace { + +// Send a UMA histogram about if |local_results| has empty or duplicate +// usernames. +void ReportAccountChooserMetrics( + const ScopedVector& local_results) { + std::vector usernames; + for (const auto& form : local_results) + usernames.push_back(form->username_value); + std::sort(usernames.begin(), usernames.end()); + bool has_empty_username = !usernames.empty() && usernames[0].empty(); + bool has_duplicates = + std::adjacent_find(usernames.begin(), usernames.end()) != usernames.end(); + metrics_util::AccountChooserUsabilityMetric metric; + if (has_empty_username && has_duplicates) + metric = metrics_util::ACCOUNT_CHOOSER_EMPTY_USERNAME_AND_DUPLICATES; + else if (has_empty_username) + metric = metrics_util::ACCOUNT_CHOOSER_EMPTY_USERNAME; + else if (has_duplicates) + metric = metrics_util::ACCOUNT_CHOOSER_DUPLICATES; + else + metric = metrics_util::ACCOUNT_CHOOSER_LOOKS_OK; + metrics_util::LogAccountChooserUsability(metric); +} + +} // namespace CredentialManagerPendingRequestTask::CredentialManagerPendingRequestTask( CredentialManagerPendingRequestTaskDelegate* delegate, @@ -118,6 +146,8 @@ void CredentialManagerPendingRequestTask::OnGetPasswordStoreResults( // user chooses if they pick one. std::unique_ptr potential_autosignin_form( new autofill::PasswordForm(*local_results[0])); + if (!zero_click_only_) + ReportAccountChooserMetrics(local_results); if (zero_click_only_ || !delegate_->client()->PromptUserToChooseCredentials( std::move(local_results), std::move(federated_results), origin_, diff --git a/components/password_manager/core/browser/password_manager_metrics_util.cc b/components/password_manager/core/browser/password_manager_metrics_util.cc index 48d1c820f5a943..e20c5dad1e9c37 100644 --- a/components/password_manager/core/browser/password_manager_metrics_util.cc +++ b/components/password_manager/core/browser/password_manager_metrics_util.cc @@ -110,6 +110,11 @@ void LogAutoSigninPromoUserAction(SyncSignInUserAction action) { CHROME_SIGNIN_ACTION_COUNT); } +void LogAccountChooserUsability(AccountChooserUsabilityMetric usability) { + UMA_HISTOGRAM_ENUMERATION("PasswordManager.AccountChooserDialogUsability", + usability, ACCOUNT_CHOOSER_USABILITY_COUNT); +} + } // namespace metrics_util } // namespace password_manager diff --git a/components/password_manager/core/browser/password_manager_metrics_util.h b/components/password_manager/core/browser/password_manager_metrics_util.h index 5e5e01a6f030ce..98ef56256859ea 100644 --- a/components/password_manager/core/browser/password_manager_metrics_util.h +++ b/components/password_manager/core/browser/password_manager_metrics_util.h @@ -137,6 +137,14 @@ enum SyncSignInUserAction { CHROME_SIGNIN_ACTION_COUNT }; +enum AccountChooserUsabilityMetric { + ACCOUNT_CHOOSER_LOOKS_OK, + ACCOUNT_CHOOSER_EMPTY_USERNAME, + ACCOUNT_CHOOSER_DUPLICATES, + ACCOUNT_CHOOSER_EMPTY_USERNAME_AND_DUPLICATES, + ACCOUNT_CHOOSER_USABILITY_COUNT, +}; + // A version of the UMA_HISTOGRAM_BOOLEAN macro that allows the |name| // to vary over the program's runtime. void LogUMAHistogramBoolean(const std::string& name, bool sample); @@ -181,6 +189,9 @@ void LogAccountChooserUserActionManyAccounts(AccountChooserUserAction action); // Log a user action on showing the Chrome sign in promo. void LogAutoSigninPromoUserAction(SyncSignInUserAction action); +// Log if the account chooser has empty username or duplicate usernames. +void LogAccountChooserUsability(AccountChooserUsabilityMetric usability); + } // namespace metrics_util } // namespace password_manager diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index 68928e41b0bd17..e69a8506518fd1 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml @@ -37297,6 +37297,14 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries. + + vasilii@chromium.org + + Whether the account chooser includes an empty username or any duplicates + + + gcasto@chromium.org vabr@chromium.org @@ -64309,6 +64317,13 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries. + + + + + + +