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..13b5a0a1bca303833998b8d12acaabc20a631911 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,11 @@ 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 kUKMFormInteractionsFormEventMetricName[]; |
+extern const char kUKMFormInteractionsUnmaskPromptEventMetricName[]; |
} // namespace internal |
namespace autofill { |
@@ -543,6 +550,38 @@ class AutofillMetrics { |
NUM_CONVERTED_ADDRESS_CONVERSION_TYPES |
}; |
+ // Utility to log URL keyed |AutofillFormSubmittedState|, |
+ // |UserHappinessMetric|, |FormEvent| and |UnmaskPromptEvent|. |
+ class UkmLogger { |
+ public: |
+ explicit UkmLogger(ukm::UkmService* ukm_service); |
+ ~UkmLogger(); |
+ |
+ const GURL& url() const { return url_; } |
+ void set_url(const GURL& url) { url_ = url; } |
+ |
+ void LogAutofillFormSubmittedState(AutofillFormSubmittedState state); |
+ void LogUserHappinessMetric(UserHappinessMetric metric); |
+ void LogAddressFormEvent(FormEvent event); |
+ void LogCreditCardFormEvent(FormEvent event); |
+ void LogUnmaskPromptEvent(UnmaskPromptEvent event); |
+ void LogUkm(); |
+ |
+ 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 +708,8 @@ 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, |
+ UkmLogger* ukm_logger); |
// This should be called when determining the heuristic types for a form's |
// fields. |
@@ -717,11 +757,11 @@ class AutofillMetrics { |
const std::string& ukm_entry_name, |
const std::map<std::string, 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, UkmLogger* ukm_logger); |
inline void set_is_server_data_available(bool is_server_data_available) { |
is_server_data_available_ = is_server_data_available; |
@@ -771,6 +811,8 @@ class AutofillMetrics { |
// The last field that was polled for suggestions. |
FormFieldData last_polled_field_; |
+ |
+ UkmLogger* ukm_logger_; // Weak reference. |
}; |
private: |