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

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

Issue 2800853004: UKM that threads together multiple form interaction events. (Closed)
Patch Set: Updates unit tests. 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..e45042a481dddcbeb9e3526fb2f16173b938fb1b 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,38 @@ class AutofillMetrics {
NUM_CONVERTED_ADDRESS_CONVERSION_TYPES
};
+ // Utility to log URL keyed |AutofillFormSubmittedState|,
+ // |UserHappinessMetric|, |FormEvent| and |UnmaskPromptEvent|.
+ class UkmLogger {
sebsg 2017/04/10 19:20:19 Do you think we could rename to something like For
csashi 2017/04/10 20:15:58 Done.
+ 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 +709,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.
@@ -715,13 +756,13 @@ 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, UkmLogger* ukm_logger);
inline void set_is_server_data_available(bool is_server_data_available) {
is_server_data_available_ = is_server_data_available;
@@ -754,7 +795,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 +812,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