| Index: components/autofill/core/browser/autofill_metrics.h
|
| diff --git a/components/autofill/core/browser/autofill_metrics.h b/components/autofill/core/browser/autofill_metrics.h
|
| index 15ee9a173c9debb9119f586cc6c5ce5773b62a2e..7e0a72f4d8a6cc411ddb8c5b10a6bfb2f883f755 100644
|
| --- a/components/autofill/core/browser/autofill_metrics.h
|
| +++ b/components/autofill/core/browser/autofill_metrics.h
|
| @@ -7,6 +7,8 @@
|
|
|
| #include <stddef.h>
|
| #include <string>
|
| +#include <utility>
|
| +#include <vector>
|
|
|
| #include "base/macros.h"
|
| #include "components/autofill/core/browser/autofill_client.h"
|
| @@ -29,6 +31,12 @@ extern const char kUKMCardUploadDecisionEntryName[];
|
| extern const char kUKMCardUploadDecisionMetricName[];
|
| extern const char kUKMDeveloperEngagementEntryName[];
|
| extern const char kUKMDeveloperEngagementMetricName[];
|
| +extern const char kUKMFormInteractionsEntryName[];
|
| +extern const char kUKMFormInteractionsAutofillFormSubmittedStateMetricName[];
|
| +extern const char kUKMFormInteractionsUserHappinessMetricMetricName[];
|
| +extern const char kUKMFormInteractionsAddressFormEventMetricName[];
|
| +extern const char kUKMFormInteractionsCreditCardFormEventMetricName[];
|
| +extern const char kUKMFormInteractionsUnmaskPromptEventMetricName[];
|
| } // namespace internal
|
|
|
| namespace autofill {
|
| @@ -543,6 +551,42 @@ class AutofillMetrics {
|
| NUM_CONVERTED_ADDRESS_CONVERSION_TYPES
|
| };
|
|
|
| + // Utility to log URL keyed |AutofillFormSubmittedState|,
|
| + // |UserHappinessMetric|, |FormEvent| and |UnmaskPromptEvent|.
|
| + class FormInteractionsUkmLogger {
|
| + public:
|
| + explicit FormInteractionsUkmLogger(ukm::UkmService* ukm_service);
|
| + ~FormInteractionsUkmLogger();
|
| +
|
| + const GURL& url() const { return url_; }
|
| + void set_url(const GURL& url) { url_ = url; }
|
| +
|
| + // The following Log functions only log the form interactions to private
|
| + // class variables. |SubmitUkm| is the only method that calls the
|
| + // |UkmService|.
|
| + void LogAutofillFormSubmittedState(AutofillFormSubmittedState state);
|
| + void LogUserHappinessMetric(UserHappinessMetric metric);
|
| + void LogAddressFormEvent(FormEvent event);
|
| + void LogCreditCardFormEvent(FormEvent event);
|
| + void LogUnmaskPromptEvent(UnmaskPromptEvent event);
|
| +
|
| + void SubmitUkm();
|
| +
|
| + private:
|
| + enum MetricType {
|
| + AUTOFILL_FORM_SUBMITTED_STATE, // |AutofillFormSubmittedState|
|
| + USER_HAPPINESS_METRIC, // |UserHappinessMetric|
|
| + ADDRESS_FORM_EVENT, // |FormEvent| for address
|
| + CREDIT_CARD_FORM_EVENT, // |FormEvent| for credit_card
|
| + UNMASK_PROMPT_EVENT, // |UnmaskPromptEvent|
|
| +
|
| + NUM_METRIC_TYPES,
|
| + };
|
| + ukm::UkmService* ukm_service_; // Weak reference.
|
| + GURL url_;
|
| + std::vector<std::pair<MetricType, int>> metrics_;
|
| + };
|
| +
|
| static void LogCardUploadDecisionMetric(CardUploadDecisionMetric metric);
|
| static void LogCreditCardInfoBarMetric(InfoBarMetric metric,
|
| bool is_uploading);
|
| @@ -669,7 +713,9 @@ class AutofillMetrics {
|
|
|
| // This should be called at each form submission to indicate the autofilled
|
| // state of the form.
|
| - static void LogAutofillFormSubmittedState(AutofillFormSubmittedState state);
|
| + static void LogAutofillFormSubmittedState(
|
| + AutofillFormSubmittedState state,
|
| + FormInteractionsUkmLogger* form_interactions_ukm_logger);
|
|
|
| // This should be called when determining the heuristic types for a form's
|
| // fields.
|
| @@ -715,13 +761,14 @@ class AutofillMetrics {
|
| static bool LogUkm(ukm::UkmService* ukm_service,
|
| const GURL& url,
|
| const std::string& ukm_entry_name,
|
| - const std::map<std::string, int>& metrics);
|
| + const std::vector<std::pair<const char*, int>>& metrics);
|
|
|
| - // Utility to autofill form events in the relevant histograms depending on
|
| + // Utility to log autofill form events in the relevant histograms depending on
|
| // the presence of server and/or local data.
|
| class FormEventLogger {
|
| public:
|
| - FormEventLogger(bool is_for_credit_card);
|
| + FormEventLogger(bool is_for_credit_card,
|
| + FormInteractionsUkmLogger* form_interactions_ukm_logger);
|
|
|
| inline void set_is_server_data_available(bool is_server_data_available) {
|
| is_server_data_available_ = is_server_data_available;
|
| @@ -754,7 +801,7 @@ class AutofillMetrics {
|
| void OnFormSubmitted();
|
|
|
| private:
|
| - void Log(FormEvent event) const;
|
| + void Log(FormEvent event, bool log_ukm) const;
|
|
|
| bool is_for_credit_card_;
|
| bool is_server_data_available_;
|
| @@ -771,6 +818,9 @@ class AutofillMetrics {
|
|
|
| // The last field that was polled for suggestions.
|
| FormFieldData last_polled_field_;
|
| +
|
| + FormInteractionsUkmLogger*
|
| + form_interactions_ukm_logger_; // Weak reference.
|
| };
|
|
|
| private:
|
|
|