Commit 6072951d authored by mathp's avatar mathp Committed by Commit bot

[Autofill] Add FormEvent logging for "will submit form".

A previous CL split the AutofillManager::OnFormSubmitted logic into OnWillSubmit and OnFormSubmitted to support AJAX forms. This change splits the logged events similarly and introduces AutofillMetrics::FormEventLogger::OnWillSubmitForm, which is logged anytime a form is about to be submitted. We move FormEventLogger::OnDidSubmitForm back into AutofillManager::OnFormSubmitted, since it more closely matches what happened before.

We will use the extra "will submit" logged events to determine the proportion of submitted forms that are AJAX (don't end up calling OnFormSubmitted).

BUG=460488
TEST=AutofillMetricsTest

Review URL: https://codereview.chromium.org/1010263002

Cr-Commit-Position: refs/heads/master@{#322169}
parent 19c185c6
...@@ -328,8 +328,8 @@ bool AutofillManager::OnWillSubmitForm(const FormData& form, ...@@ -328,8 +328,8 @@ bool AutofillManager::OnWillSubmitForm(const FormData& form,
if (!submitted_form) if (!submitted_form)
return false; return false;
address_form_event_logger_->OnDidSubmitForm(); address_form_event_logger_->OnWillSubmitForm();
credit_card_form_event_logger_->OnDidSubmitForm(); credit_card_form_event_logger_->OnWillSubmitForm();
// Only upload server statistics and UMA metrics if at least some local data // Only upload server statistics and UMA metrics if at least some local data
// is available to use as a baseline. // is available to use as a baseline.
...@@ -389,6 +389,9 @@ bool AutofillManager::OnFormSubmitted(const FormData& form) { ...@@ -389,6 +389,9 @@ bool AutofillManager::OnFormSubmitted(const FormData& form) {
if (!submitted_form) if (!submitted_form)
return false; return false;
address_form_event_logger_->OnFormSubmitted();
credit_card_form_event_logger_->OnFormSubmitted();
// Update Personal Data with the form's submitted data. // Update Personal Data with the form's submitted data.
if (submitted_form->IsAutofillable()) if (submitted_form->IsAutofillable())
ImportFormData(*submitted_form); ImportFormData(*submitted_form);
......
...@@ -437,10 +437,12 @@ class AutofillManager : public AutofillDownloadManager::Observer, ...@@ -437,10 +437,12 @@ class AutofillManager : public AutofillDownloadManager::Observer,
DisabledAutofillDispatchesError); DisabledAutofillDispatchesError);
FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AddressFilledFormEvents); FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AddressFilledFormEvents);
FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AddressSubmittedFormEvents); FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AddressSubmittedFormEvents);
FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AddressWillSubmitFormEvents);
FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AddressSuggestionsCount); FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AddressSuggestionsCount);
FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AutofillIsEnabledAtPageLoad); FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AutofillIsEnabledAtPageLoad);
FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, CreditCardSelectedFormEvents); FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, CreditCardSelectedFormEvents);
FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, CreditCardFilledFormEvents); FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, CreditCardFilledFormEvents);
FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, CreditCardWillSubmitFormEvents);
FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, CreditCardSubmittedFormEvents); FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, CreditCardSubmittedFormEvents);
FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, DeveloperEngagement); FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, DeveloperEngagement);
FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FormFillDuration); FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FormFillDuration);
......
...@@ -522,9 +522,11 @@ AutofillMetrics::FormEventLogger::FormEventLogger(bool is_for_credit_card) ...@@ -522,9 +522,11 @@ AutofillMetrics::FormEventLogger::FormEventLogger(bool is_for_credit_card)
has_logged_suggestions_shown_(false), has_logged_suggestions_shown_(false),
has_logged_masked_server_card_suggestion_selected_(false), has_logged_masked_server_card_suggestion_selected_(false),
has_logged_suggestion_filled_(false), has_logged_suggestion_filled_(false),
has_logged_will_submit_(false),
has_logged_submitted_(false), has_logged_submitted_(false),
logged_suggestion_filled_was_server_data_(false), logged_suggestion_filled_was_server_data_(false),
logged_suggestion_filled_was_masked_server_card_(false) {}; logged_suggestion_filled_was_masked_server_card_(false) {
}
void AutofillMetrics::FormEventLogger::OnDidInteractWithAutofillableForm() { void AutofillMetrics::FormEventLogger::OnDidInteractWithAutofillableForm() {
if (!has_logged_interacted_) { if (!has_logged_interacted_) {
...@@ -597,7 +599,29 @@ void AutofillMetrics::FormEventLogger::OnDidFillSuggestion( ...@@ -597,7 +599,29 @@ void AutofillMetrics::FormEventLogger::OnDidFillSuggestion(
} }
} }
void AutofillMetrics::FormEventLogger::OnDidSubmitForm() { void AutofillMetrics::FormEventLogger::OnWillSubmitForm() {
// Not logging this kind of form if we haven't logged a user interaction.
if (!has_logged_interacted_)
return;
// Not logging twice.
if (has_logged_will_submit_)
return;
has_logged_will_submit_ = true;
if (!has_logged_suggestion_filled_) {
Log(AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE);
} else if (logged_suggestion_filled_was_masked_server_card_) {
Log(AutofillMetrics::
FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_WILL_SUBMIT_ONCE);
} else if (logged_suggestion_filled_was_server_data_) {
Log(AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE);
} else {
Log(AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_WILL_SUBMIT_ONCE);
}
}
void AutofillMetrics::FormEventLogger::OnFormSubmitted() {
// Not logging this kind of form if we haven't logged a user interaction. // Not logging this kind of form if we haven't logged a user interaction.
if (!has_logged_interacted_) if (!has_logged_interacted_)
return; return;
......
...@@ -281,6 +281,16 @@ class AutofillMetrics { ...@@ -281,6 +281,16 @@ class AutofillMetrics {
FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED, FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED,
// Same as above but only triggered once per page load. // Same as above but only triggered once per page load.
FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED_ONCE, FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED_ONCE,
// An autofillable form is about to be submitted. If the submission is not
// interrupted by JavaScript, the "form submitted" events above will also be
// logged. Depending on the user filling a local, server, masked server card
// or no suggestion one of the following will be triggered, at most once per
// page load.
FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE,
FORM_EVENT_LOCAL_SUGGESTION_WILL_SUBMIT_ONCE,
FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE,
FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_WILL_SUBMIT_ONCE,
NUM_FORM_EVENTS, NUM_FORM_EVENTS,
}; };
...@@ -546,7 +556,9 @@ class AutofillMetrics { ...@@ -546,7 +556,9 @@ class AutofillMetrics {
void OnDidFillSuggestion(const AutofillProfile& profile); void OnDidFillSuggestion(const AutofillProfile& profile);
void OnDidSubmitForm(); void OnWillSubmitForm();
void OnFormSubmitted();
private: private:
void Log(FormEvent event) const; void Log(FormEvent event) const;
...@@ -558,6 +570,7 @@ class AutofillMetrics { ...@@ -558,6 +570,7 @@ class AutofillMetrics {
bool has_logged_suggestions_shown_; bool has_logged_suggestions_shown_;
bool has_logged_masked_server_card_suggestion_selected_; bool has_logged_masked_server_card_suggestion_selected_;
bool has_logged_suggestion_filled_; bool has_logged_suggestion_filled_;
bool has_logged_will_submit_;
bool has_logged_submitted_; bool has_logged_submitted_;
bool logged_suggestion_filled_was_server_data_; bool logged_suggestion_filled_was_server_data_;
bool logged_suggestion_filled_was_masked_server_card_; bool logged_suggestion_filled_was_masked_server_card_;
......
...@@ -45118,6 +45118,15 @@ Therefore, the affected-histogram name has to have at least one dot in it. ...@@ -45118,6 +45118,15 @@ Therefore, the affected-histogram name has to have at least one dot in it.
label="Submitted with masked server card suggestion filled (once)"/> label="Submitted with masked server card suggestion filled (once)"/>
<int value="13" label="Masked server card suggestion selected"/> <int value="13" label="Masked server card suggestion selected"/>
<int value="14" label="Masked server card suggestion selected (once)"/> <int value="14" label="Masked server card suggestion selected (once)"/>
<int value="15"
label="About to be submitted with no suggestion filled (once)"/>
<int value="16"
label="About to be submitted with local suggestion filled (once)"/>
<int value="17"
label="About to be submitted with server suggestion filled (once)"/>
<int value="18"
label="About to be submitted with masked server card suggestion filled
(once)"/>
</enum> </enum>
<enum name="AutofillGetRealPanResult" type="int"> <enum name="AutofillGetRealPanResult" type="int">
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