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

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

Issue 2940983003: [autofill] Add UKM for field type prediction quality and autofill outcome. (Closed)
Patch Set: Created 3 years, 6 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 d849ce143f8bce195815706ee4ac48778b4ad44e..9ef0927c27dfe72d391d715943f2979abb0672fa 100644
--- a/components/autofill/core/browser/autofill_metrics.h
+++ b/components/autofill/core/browser/autofill_metrics.h
@@ -11,7 +11,6 @@
#include <vector>
#include "base/macros.h"
-#include "base/strings/string_piece_forward.h"
#include "base/time/time.h"
#include "components/autofill/core/browser/autofill_client.h"
#include "components/autofill/core/browser/autofill_profile.h"
@@ -19,6 +18,7 @@
#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/common/autofill_pref_names.h"
#include "components/autofill/core/common/form_field_data.h"
+#include "components/autofill/core/common/signatures_util.h"
#include "components/ukm/public/ukm_recorder.h"
namespace internal {
@@ -69,6 +69,19 @@ extern const char kUKMIsEmptyMetricName[];
// |UkmEntry| for |AutofillFormSubmittedState|.
extern const char kUKMFormSubmittedEntryName[];
extern const char kUKMAutofillFormSubmittedStateMetricName[];
+
+// |UkmEntry| for capturing field fill status and type prediction quality.
+extern const char kUKMFieldTypeEntryName[];
+extern const char kUKMFieldFillStatusEntryName[];
+extern const char kUKMFormSignatureMetricName[];
+extern const char kUKMFieldSignatureMetricName[];
+extern const char kUKMValidationEventMetricName[];
+extern const char kUKMPredictionSourceMetricName[];
+extern const char kUKMPredictedTypeMetricName[];
+extern const char kUKMActualTypeMetricName[];
+extern const char kUKMWasSuggestionShownMetricName[];
+extern const char kUKMWasPreviouslyAutofilledMetricName[];
+
} // namespace internal
namespace autofill {
@@ -408,6 +421,14 @@ class AutofillMetrics {
NUM_FIELD_TYPE_QUALITY_METRICS
};
+ enum QualityMetricPredictionSource {
+ PREDICTION_SOURCE_UNKNOWN, // Not used. The prediction source is unknown.
+ PREDICTION_SOURCE_HEURISTIC, // Local heuristic field-type prediction.
+ PREDICTION_SOURCE_SERVER, // Crowd-sourced server field type prediction.
+ PREDICTION_SOURCE_OVERALL, // Overall field-type prediction seen by user.
+ NUM_QUALITY_METRIC_SOURCES
+ };
+
enum QualityMetricType {
TYPE_SUBMISSION = 0, // Logged based on user's submitted data.
TYPE_NO_SUBMISSION, // Logged based on user's entered data.
@@ -679,11 +700,16 @@ class AutofillMetrics {
NUM_CONVERTED_ADDRESS_CONVERSION_TYPES
};
+ class UkmTimestampPin;
sebsg 2017/06/19 14:48:09 As discussed, please remove or add comment.
Roger McFarlane (Chromium) 2017/06/21 21:01:54 Done.
+
// Utility to log URL keyed form interaction events.
class FormInteractionsUkmLogger {
public:
explicit FormInteractionsUkmLogger(ukm::UkmRecorder* ukm_recorder);
+ bool has_pinned_timestamp() const { return !pinned_timestamp_.is_null(); }
+ void set_pinned_timestamp(base::TimeTicks t) { pinned_timestamp_ = t; }
+
const GURL& url() const { return url_; }
void OnFormsParsed(const GURL& url);
@@ -694,6 +720,15 @@ class AutofillMetrics {
void LogSelectedMaskedServerCard();
void LogDidFillSuggestion(int record_type);
void LogTextFieldDidChange(const AutofillField& field);
+ void LogFieldFillStatus(const FormStructure& form,
+ const AutofillField& field,
+ QualityMetricType metric_type);
+ void LogFieldType(FormSignature form_signature,
+ FieldSignature field_signature,
+ QualityMetricPredictionSource prediction_source,
+ QualityMetricType metric_type,
+ ServerFieldType predicted_type,
+ ServerFieldType actual_type);
void LogFormSubmitted(AutofillFormSubmittedState state);
// We initialize |url_| with the form's URL when we log the first form
@@ -710,6 +745,26 @@ class AutofillMetrics {
ukm::SourceId source_id_ = -1;
GURL url_;
base::TimeTicks form_parsed_timestamp_;
+ base::TimeTicks pinned_timestamp_;
+ };
+
+ // Utility class to pin the timestamp used by the FormInteractionsUkmLogger
+ // while an instance of this class is in scope. Pinned timestamps cannot be
+ // nested.
+ class UkmTimestampPin {
+ public:
+ UkmTimestampPin(FormInteractionsUkmLogger* logger) : logger_(logger) {
+ DCHECK(!logger->has_pinned_timestamp());
+ logger->set_pinned_timestamp(base::TimeTicks::Now());
+ }
+ ~UkmTimestampPin() {
+ DCHECK(logger_->has_pinned_timestamp());
+ logger_->set_pinned_timestamp(base::TimeTicks());
+ }
+
+ private:
+ FormInteractionsUkmLogger* const logger_;
+ DISALLOW_IMPLICIT_CONSTRUCTORS(UkmTimestampPin);
};
// |upload_decision_metrics| is a bitmask of |CardUploadDecisionMetric|.
@@ -736,16 +791,19 @@ class AutofillMetrics {
static void LogDeveloperEngagementMetric(DeveloperEngagementMetric metric);
static void LogHeuristicPredictionQualityMetrics(
- const ServerFieldTypeSet& possible_types,
- ServerFieldType predicted_type,
+ FormInteractionsUkmLogger* form_interactions_ukm_logger,
+ const FormStructure& form,
+ const AutofillField& field,
QualityMetricType metric_type);
static void LogServerPredictionQualityMetrics(
- const ServerFieldTypeSet& possible_types,
- ServerFieldType predicted_type,
+ FormInteractionsUkmLogger* form_interactions_ukm_logger,
+ const FormStructure& form,
+ const AutofillField& field,
QualityMetricType metric_type);
static void LogOverallPredictionQualityMetrics(
- const ServerFieldTypeSet& possible_types,
- ServerFieldType predicted_type,
+ FormInteractionsUkmLogger* form_interactions_ukm_logger,
+ const FormStructure& form,
+ const AutofillField& field,
QualityMetricType metric_type);
static void LogServerQueryMetric(ServerQueryMetric metric);

Powered by Google App Engine
This is Rietveld 408576698