Commit 1447fae2 authored by Jared Saul's avatar Jared Saul Committed by Commit Bot

[Autofill] Log metric for whether card upload cardholder name was edited

Bug: 848955
Change-Id: I8febd9c3471b58b962d3706eede4be506b092044
Reviewed-on: https://chromium-review.googlesource.com/1134089Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarSebastien Seguin-Gagnon <sebsg@chromium.org>
Reviewed-by: default avatarRobert Kaplow <rkaplow@chromium.org>
Commit-Queue: Jared Saul <jsaul@google.com>
Cr-Commit-Position: refs/heads/master@{#574709}
parent dcd80426
......@@ -6,6 +6,7 @@
#include <stddef.h>
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
......@@ -181,6 +182,10 @@ void SaveCardBubbleControllerImpl::OnSaveButton(
if (!upload_save_card_callback_.is_null()) {
base::string16 name_provided_by_user;
if (!cardholder_name.empty()) {
// Log whether the name was changed by the user or simply accepted without
// edits.
AutofillMetrics::LogSaveCardCardholderNameWasEdited(
cardholder_name != base::UTF8ToUTF16(account_info_.full_name));
// Trim the cardholder name provided by the user and send it in the
// callback so it can be included in the final request.
DCHECK(ShouldRequestNameFromUser());
......
......@@ -559,6 +559,80 @@ IN_PROC_BROWSER_TEST_F(
EXPECT_FALSE(FindViewInBubbleById(DialogViewId::CARDHOLDER_NAME_TOOLTIP));
}
// Tests the upload save bubble. Ensures that if cardholder name is explicitly
// requested and the user accepts the dialog without changing it, the correct
// metric is logged.
IN_PROC_BROWSER_TEST_F(
SaveCardBubbleViewsFullFormBrowserTest,
Upload_CardholderNameRequested_SubmittingPrefilledValueLogsUneditedMetric) {
// Enable the EditableCardholderName experiment.
scoped_feature_list_.InitAndEnableFeature(
kAutofillUpstreamEditableCardholderName);
// Set up the Payments RPC.
SetUploadDetailsRpcPaymentsAccepts();
// Sign the user in.
SignInWithFullName("John Smith");
// Submitting the form should show the upload save bubble, along with a
// textfield specifically requesting the cardholder name.
// (Must wait for response from Payments before accessing the controller.)
ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE});
FillAndSubmitFormWithoutName();
WaitForObservedEvent();
EXPECT_TRUE(FindViewInBubbleById(DialogViewId::CARDHOLDER_NAME_TEXTFIELD));
// Clicking [Save] should accept and close the bubble, logging that the name
// was not edited.
ResetEventWaiterForSequence({DialogEvent::SENT_UPLOAD_CARD_REQUEST});
base::HistogramTester histogram_tester;
ClickOnDialogViewWithIdAndWait(DialogViewId::OK_BUTTON);
histogram_tester.ExpectUniqueSample(
"Autofill.SaveCardCardholderNameWasEdited", false, 1);
}
// Tests the upload save bubble. Ensures that if cardholder name is explicitly
// requested and the user accepts the dialog after changing it, the correct
// metric is logged.
IN_PROC_BROWSER_TEST_F(
SaveCardBubbleViewsFullFormBrowserTest,
Upload_CardholderNameRequested_SubmittingChangedValueLogsEditedMetric) {
// Enable the EditableCardholderName experiment.
scoped_feature_list_.InitAndEnableFeature(
kAutofillUpstreamEditableCardholderName);
// Set up the Payments RPC.
SetUploadDetailsRpcPaymentsAccepts();
// Sign the user in.
SignInWithFullName("John Smith");
// Submitting the form should show the upload save bubble, along with a
// textfield specifically requesting the cardholder name.
// (Must wait for response from Payments before accessing the controller.)
ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE});
FillAndSubmitFormWithoutName();
WaitForObservedEvent();
EXPECT_TRUE(FindViewInBubbleById(DialogViewId::CARDHOLDER_NAME_TEXTFIELD));
// Changing the name then clicking [Save] should accept and close the bubble,
// logging that the name was edited.
ResetEventWaiterForSequence({DialogEvent::SENT_UPLOAD_CARD_REQUEST});
views::Textfield* cardholder_name_textfield = static_cast<views::Textfield*>(
FindViewInBubbleById(DialogViewId::CARDHOLDER_NAME_TEXTFIELD));
cardholder_name_textfield->InsertOrReplaceText(
base::ASCIIToUTF16("Jane Doe"));
base::HistogramTester histogram_tester;
ClickOnDialogViewWithIdAndWait(DialogViewId::OK_BUTTON);
histogram_tester.ExpectUniqueSample(
"Autofill.SaveCardCardholderNameWasEdited", true, 1);
}
// TODO(jsaul): Only *part* of the legal message StyledLabel is clickable, and
// the NOTREACHED() in SaveCardBubbleViews::StyledLabelLinkClicked
// prevents us from being able to click it unless we know the exact
......
......@@ -680,6 +680,11 @@ void AutofillMetrics::LogSaveCardCardholderNamePrefilled(bool prefilled) {
UMA_HISTOGRAM_BOOLEAN("Autofill.SaveCardCardholderNamePrefilled", prefilled);
}
// static
void AutofillMetrics::LogSaveCardCardholderNameWasEdited(bool edited) {
UMA_HISTOGRAM_BOOLEAN("Autofill.SaveCardCardholderNameWasEdited", edited);
}
// static
void AutofillMetrics::LogCardUploadDecisionMetrics(
int upload_decision_metrics) {
......
......@@ -770,6 +770,11 @@ class AutofillMetrics {
// whether the cardholder name was prefilled or not.
static void LogSaveCardCardholderNamePrefilled(bool prefilled);
// When a cardholder name fix flow is shown during credit card upload and the
// user accepts upload, logs whether the final cardholder name was changed
// from its prefilled value or not.
static void LogSaveCardCardholderNameWasEdited(bool edited);
// |upload_decision_metrics| is a bitmask of |CardUploadDecisionMetric|.
static void LogCardUploadDecisionMetrics(int upload_decision_metrics);
static void LogCreditCardInfoBarMetric(
......
......@@ -6705,6 +6705,15 @@ uploading your change for review.
</summary>
</histogram>
<histogram name="Autofill.SaveCardCardholderNameWasEdited" enum="Boolean">
<owner>jsaul@google.com</owner>
<summary>
If the cardholder name fix flow is shown during credit card upload and the
user accepts upload, logs whether the final cardholder name was changed from
its prefilled value or not.
</summary>
</histogram>
<histogram name="Autofill.SaveCardWithFirstAndLastNameComplete" enum="Boolean">
<owner>sebsg@chromium.org</owner>
<!-- Name completed by histogram_suffixes name="AutofillCreditCardType" -->
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