Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(838)

Unified Diff: components/autofill/core/browser/autofill_metrics.h

Issue 2800853004: UKM that threads together multiple form interaction events. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..c80e60158f4d1c39c37e12f384257f6734ecdb11 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 {
@@ -717,11 +724,42 @@ 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 URL keyed |AutofillFormSubmittedState|,
+ // |UserHappinessMetric|, |FormEvent| and |UnmaskPromptEvent|.
+ class UkmLogger {
+ public:
+ explicit UkmLogger(ukm::UkmService* ukm_service);
+ ~UkmLogger();
+
+ void set_url(const GURL& url) { url_ = url; }
+ void LogAutofillFormSubmittedState(const GURL& source_url,
+ 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_;
+ };
+
+ // 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 +809,8 @@ class AutofillMetrics {
// The last field that was polled for suggestions.
FormFieldData last_polled_field_;
+
+ UkmLogger* ukm_logger_; // Weak reference.
};
private:

Powered by Google App Engine
This is Rietveld 408576698