Skip to content

Commit

Permalink
Add separate UMA histograms for the account chooser with 1/many accou…
Browse files Browse the repository at this point in the history
…nts.

BUG=612501

Review-Url: https://codereview.chromium.org/2002643002
Cr-Commit-Position: refs/heads/master@{#395556}
  • Loading branch information
vasilii authored and Commit bot committed May 24, 2016
1 parent 6fc84fa commit d7185e0
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 10 deletions.
20 changes: 15 additions & 5 deletions chrome/browser/ui/passwords/password_dialog_controller_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,20 @@ void PasswordDialogControllerImpl::OnSmartLockLinkClicked() {
void PasswordDialogControllerImpl::OnChooseCredentials(
const autofill::PasswordForm& password_form,
password_manager::CredentialType credential_type) {
password_manager::metrics_util::LogAccountChooserUserAction(
password_manager::metrics_util::ACCOUNT_CHOOSER_CREDENTIAL_CHOSEN);
if (local_credentials_.size() == 1) {
password_manager::metrics_util::LogAccountChooserUserActionOneAccount(
password_manager::metrics_util::ACCOUNT_CHOOSER_CREDENTIAL_CHOSEN);
} else {
password_manager::metrics_util::LogAccountChooserUserActionManyAccounts(
password_manager::metrics_util::ACCOUNT_CHOOSER_CREDENTIAL_CHOSEN);
}
ResetDialog();
delegate_->ChooseCredential(password_form, credential_type);
}

void PasswordDialogControllerImpl::OnSignInClicked() {
DCHECK_EQ(1u, local_credentials_.size());
password_manager::metrics_util::LogAccountChooserUserAction(
password_manager::metrics_util::LogAccountChooserUserActionOneAccount(
password_manager::metrics_util::ACCOUNT_CHOOSER_SIGN_IN);
ResetDialog();
delegate_->ChooseCredential(
Expand Down Expand Up @@ -150,8 +155,13 @@ void PasswordDialogControllerImpl::OnAutoSigninTurnOff() {

void PasswordDialogControllerImpl::OnCloseDialog() {
if (account_chooser_dialog_) {
password_manager::metrics_util::LogAccountChooserUserAction(
password_manager::metrics_util::ACCOUNT_CHOOSER_DISMISSED);
if (local_credentials_.size() == 1) {
password_manager::metrics_util::LogAccountChooserUserActionOneAccount(
password_manager::metrics_util::ACCOUNT_CHOOSER_DISMISSED);
} else {
password_manager::metrics_util::LogAccountChooserUserActionManyAccounts(
password_manager::metrics_util::ACCOUNT_CHOOSER_DISMISSED);
}
account_chooser_dialog_ = nullptr;
}
if (autosignin_dialog_) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ TEST_F(PasswordDialogControllerTest, ShowAccountChooser) {
histogram_tester.ExpectUniqueSample(
"PasswordManager.AccountChooserDialog",
password_manager::metrics_util::ACCOUNT_CHOOSER_CREDENTIAL_CHOSEN, 1);
histogram_tester.ExpectUniqueSample(
"PasswordManager.AccountChooserDialogMultipleAccounts",
password_manager::metrics_util::ACCOUNT_CHOOSER_CREDENTIAL_CHOSEN, 1);
histogram_tester.ExpectTotalCount(
"PasswordManager.AccountChooserDialogOneAccount", 0);
}

TEST_F(PasswordDialogControllerTest, ShowAccountChooserAndSignIn) {
Expand All @@ -147,21 +152,33 @@ TEST_F(PasswordDialogControllerTest, ShowAccountChooserAndSignIn) {
histogram_tester.ExpectUniqueSample(
"PasswordManager.AccountChooserDialog",
password_manager::metrics_util::ACCOUNT_CHOOSER_SIGN_IN, 1);
histogram_tester.ExpectUniqueSample(
"PasswordManager.AccountChooserDialogOneAccount",
password_manager::metrics_util::ACCOUNT_CHOOSER_SIGN_IN, 1);
histogram_tester.ExpectTotalCount(
"PasswordManager.AccountChooserDialogMultipleAccounts", 0);
}

TEST_F(PasswordDialogControllerTest, AccountChooserClosed) {
base::HistogramTester histogram_tester;
StrictMock<MockPasswordPrompt> prompt;
std::vector<std::unique_ptr<autofill::PasswordForm>> locals;
locals.push_back(
base::WrapUnique(new autofill::PasswordForm(GetLocalForm())));
EXPECT_CALL(prompt, ShowAccountChooser());
controller().ShowAccountChooser(&prompt,
PasswordDialogController::FormsVector(),
controller().ShowAccountChooser(&prompt, std::move(locals),
PasswordDialogController::FormsVector());

EXPECT_CALL(ui_controller_mock(), OnDialogHidden());
controller().OnCloseDialog();
histogram_tester.ExpectUniqueSample(
"PasswordManager.AccountChooserDialog",
password_manager::metrics_util::ACCOUNT_CHOOSER_DISMISSED, 1);
histogram_tester.ExpectUniqueSample(
"PasswordManager.AccountChooserDialogOneAccount",
password_manager::metrics_util::ACCOUNT_CHOOSER_DISMISSED, 1);
histogram_tester.ExpectTotalCount(
"PasswordManager.AccountChooserDialogMultipleAccounts", 0);
}

TEST_F(PasswordDialogControllerTest, AutoSigninPromo) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,19 @@ void LogAutoSigninPromoUserAction(AutoSigninPromoUserAction action) {
AUTO_SIGNIN_PROMO_ACTION_COUNT);
}

void LogAccountChooserUserAction(AccountChooserUserAction action) {
void LogAccountChooserUserActionOneAccount(AccountChooserUserAction action) {
UMA_HISTOGRAM_ENUMERATION("PasswordManager.AccountChooserDialogOneAccount",
action, ACCOUNT_CHOOSER_ACTION_COUNT);
// TODO(vasilii): deprecate the histogram when the new ones hit the Stable.
UMA_HISTOGRAM_ENUMERATION("PasswordManager.AccountChooserDialog", action,
ACCOUNT_CHOOSER_ACTION_COUNT);
}

void LogAccountChooserUserActionManyAccounts(AccountChooserUserAction action) {
UMA_HISTOGRAM_ENUMERATION(
"PasswordManager.AccountChooserDialogMultipleAccounts", action,
ACCOUNT_CHOOSER_ACTION_COUNT);
// TODO(vasilii): deprecate the histogram when the new ones hit the Stable.
UMA_HISTOGRAM_ENUMERATION("PasswordManager.AccountChooserDialog", action,
ACCOUNT_CHOOSER_ACTION_COUNT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,9 @@ void LogMultiAccountUpdateBubbleUserAction(
// Log a user action on showing the autosignin first run experience.
void LogAutoSigninPromoUserAction(AutoSigninPromoUserAction action);

// Log a user action on showing the account chooser.
void LogAccountChooserUserAction(AccountChooserUserAction action);
// Log a user action on showing the account chooser for one or many accounts.
void LogAccountChooserUserActionOneAccount(AccountChooserUserAction action);
void LogAccountChooserUserActionManyAccounts(AccountChooserUserAction action);

} // namespace metrics_util

Expand Down
16 changes: 16 additions & 0 deletions tools/metrics/histograms/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36376,6 +36376,22 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<summary>The dismissal reason of the account chooser.</summary>
</histogram>

<histogram name="PasswordManager.AccountChooserDialogMultipleAccounts"
enum="AccountChooserDismissalReason">
<owner>[email protected]</owner>
<summary>
The dismissal reason of the account chooser with multiple accounts.
</summary>
</histogram>

<histogram name="PasswordManager.AccountChooserDialogOneAccount"
enum="AccountChooserDismissalReason">
<owner>[email protected]</owner>
<summary>
The dismissal reason of the account chooser with one account.
</summary>
</histogram>

<histogram name="PasswordManager.AccountsPerSite">
<owner>[email protected]</owner>
<owner>[email protected]</owner>
Expand Down

0 comments on commit d7185e0

Please sign in to comment.