| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_METRICS_H_ | |
| 6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_METRICS_H_ | |
| 7 | |
| 8 #include <stddef.h> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/basictypes.h" | |
| 12 #include "chrome/browser/autofill/autofill_manager_delegate.h" | |
| 13 #include "chrome/browser/autofill/field_types.h" | |
| 14 | |
| 15 namespace base { | |
| 16 class TimeDelta; | |
| 17 } | |
| 18 | |
| 19 class AutofillMetrics { | |
| 20 public: | |
| 21 // The success or failure of Autocheckout. | |
| 22 enum AutocheckoutCompletionStatus { | |
| 23 AUTOCHECKOUT_FAILED, // The user canceled out of the dialog after | |
| 24 // an Autocheckout failure. | |
| 25 AUTOCHECKOUT_SUCCEEDED, // The dialog was closed after Autocheckout | |
| 26 // succeeded. | |
| 27 }; | |
| 28 | |
| 29 // The action a user took to dismiss a bubble. | |
| 30 enum BubbleMetric { | |
| 31 BUBBLE_CREATED = 0, // The bubble was created. | |
| 32 BUBBLE_ACCEPTED, // The user accepted, i.e. confirmed, the bubble. | |
| 33 BUBBLE_DISMISSED, // The user dismissed the bubble. | |
| 34 BUBBLE_IGNORED, // The user did not interact with the bubble. | |
| 35 NUM_BUBBLE_METRICS, | |
| 36 }; | |
| 37 | |
| 38 enum DeveloperEngagementMetric { | |
| 39 // Parsed a form that is potentially autofillable. | |
| 40 FILLABLE_FORM_PARSED = 0, | |
| 41 // Parsed a form that is potentially autofillable and contains at least one | |
| 42 // web developer-specified field type hint, a la | |
| 43 // http://is.gd/whatwg_autocomplete | |
| 44 FILLABLE_FORM_CONTAINS_TYPE_HINTS, | |
| 45 NUM_DEVELOPER_ENGAGEMENT_METRICS, | |
| 46 }; | |
| 47 | |
| 48 // The action the user took to dismiss a dialog. | |
| 49 enum DialogDismissalAction { | |
| 50 DIALOG_ACCEPTED = 0, // The user accepted, i.e. confirmed, the dialog. | |
| 51 DIALOG_CANCELED, // The user canceled out of the dialog. | |
| 52 }; | |
| 53 | |
| 54 enum InfoBarMetric { | |
| 55 INFOBAR_SHOWN = 0, // We showed an infobar, e.g. prompting to save credit | |
| 56 // card info. | |
| 57 INFOBAR_ACCEPTED, // The user explicitly accepted the infobar. | |
| 58 INFOBAR_DENIED, // The user explicitly denied the infobar. | |
| 59 INFOBAR_IGNORED, // The user completely ignored the infobar (logged on | |
| 60 // tab close). | |
| 61 NUM_INFO_BAR_METRICS, | |
| 62 }; | |
| 63 | |
| 64 // Metrics measuring how well we predict field types. Exactly three such | |
| 65 // metrics are logged for each fillable field in a submitted form: for | |
| 66 // the heuristic prediction, for the crowd-sourced prediction, and for the | |
| 67 // overall prediction. | |
| 68 enum FieldTypeQualityMetric { | |
| 69 TYPE_UNKNOWN = 0, // Offered no prediction. | |
| 70 TYPE_MATCH, // Predicted correctly. | |
| 71 TYPE_MISMATCH, // Predicted incorrectly. | |
| 72 NUM_FIELD_TYPE_QUALITY_METRICS, | |
| 73 }; | |
| 74 | |
| 75 enum QualityMetric { | |
| 76 // Logged for each potentially fillable field in a submitted form. | |
| 77 FIELD_SUBMITTED = 0, | |
| 78 | |
| 79 // A simple successs metric, logged for each field that returns true for | |
| 80 // |is_autofilled()|. | |
| 81 FIELD_AUTOFILLED, | |
| 82 | |
| 83 // A simple failure metric, logged for each field that returns false for | |
| 84 // |is_autofilled()| but has a value that is present in the personal data | |
| 85 // manager. | |
| 86 FIELD_NOT_AUTOFILLED, | |
| 87 | |
| 88 // The below are only logged when |FIELD_AUTOFILL_FAILED| is also logged. | |
| 89 NOT_AUTOFILLED_HEURISTIC_TYPE_UNKNOWN, | |
| 90 NOT_AUTOFILLED_HEURISTIC_TYPE_MATCH, | |
| 91 NOT_AUTOFILLED_HEURISTIC_TYPE_MISMATCH, | |
| 92 NOT_AUTOFILLED_SERVER_TYPE_UNKNOWN, | |
| 93 NOT_AUTOFILLED_SERVER_TYPE_MATCH, | |
| 94 NOT_AUTOFILLED_SERVER_TYPE_MISMATCH, | |
| 95 NUM_QUALITY_METRICS, | |
| 96 }; | |
| 97 | |
| 98 // Each of these is logged at most once per query to the server, which in turn | |
| 99 // occurs at most once per page load. | |
| 100 enum ServerQueryMetric { | |
| 101 QUERY_SENT = 0, // Sent a query to the server. | |
| 102 QUERY_RESPONSE_RECEIVED, // Received a response. | |
| 103 QUERY_RESPONSE_PARSED, // Successfully parsed the server response. | |
| 104 | |
| 105 // The response was parseable, but provided no improvements relative to our | |
| 106 // heuristics. | |
| 107 QUERY_RESPONSE_MATCHED_LOCAL_HEURISTICS, | |
| 108 | |
| 109 // Our heuristics detected at least one auto-fillable field, and the server | |
| 110 // response overrode the type of at least one field. | |
| 111 QUERY_RESPONSE_OVERRODE_LOCAL_HEURISTICS, | |
| 112 | |
| 113 // Our heuristics did not detect any auto-fillable fields, but the server | |
| 114 // response did detect at least one. | |
| 115 QUERY_RESPONSE_WITH_NO_LOCAL_HEURISTICS, | |
| 116 NUM_SERVER_QUERY_METRICS, | |
| 117 }; | |
| 118 | |
| 119 // Each of these metrics is logged only for potentially autofillable forms, | |
| 120 // i.e. forms with at least three fields, etc. | |
| 121 // These are used to derive certain "user happiness" metrics. For example, we | |
| 122 // can compute the ratio (USER_DID_EDIT_AUTOFILLED_FIELD / USER_DID_AUTOFILL) | |
| 123 // to see how often users have to correct autofilled data. | |
| 124 enum UserHappinessMetric { | |
| 125 // Loaded a page containing forms. | |
| 126 FORMS_LOADED, | |
| 127 // Submitted a fillable form -- i.e. one with at least three field values | |
| 128 // that match the user's stored Autofill data -- and all matching fields | |
| 129 // were autofilled. | |
| 130 SUBMITTED_FILLABLE_FORM_AUTOFILLED_ALL, | |
| 131 // Submitted a fillable form and some (but not all) matching fields were | |
| 132 // autofilled. | |
| 133 SUBMITTED_FILLABLE_FORM_AUTOFILLED_SOME, | |
| 134 // Submitted a fillable form and no fields were autofilled. | |
| 135 SUBMITTED_FILLABLE_FORM_AUTOFILLED_NONE, | |
| 136 // Submitted a non-fillable form. | |
| 137 SUBMITTED_NON_FILLABLE_FORM, | |
| 138 | |
| 139 // User manually filled one of the form fields. | |
| 140 USER_DID_TYPE, | |
| 141 // We showed a popup containing Autofill suggestions. | |
| 142 SUGGESTIONS_SHOWN, | |
| 143 // Same as above, but only logged once per page load. | |
| 144 SUGGESTIONS_SHOWN_ONCE, | |
| 145 // User autofilled at least part of the form. | |
| 146 USER_DID_AUTOFILL, | |
| 147 // Same as above, but only logged once per page load. | |
| 148 USER_DID_AUTOFILL_ONCE, | |
| 149 // User edited a previously autofilled field. | |
| 150 USER_DID_EDIT_AUTOFILLED_FIELD, | |
| 151 // Same as above, but only logged once per page load. | |
| 152 USER_DID_EDIT_AUTOFILLED_FIELD_ONCE, | |
| 153 NUM_USER_HAPPINESS_METRICS, | |
| 154 }; | |
| 155 | |
| 156 AutofillMetrics(); | |
| 157 virtual ~AutofillMetrics(); | |
| 158 | |
| 159 // Logs how the user interacted with the Autocheckout bubble. | |
| 160 virtual void LogAutocheckoutBubbleMetric(BubbleMetric metric) const; | |
| 161 | |
| 162 virtual void LogCreditCardInfoBarMetric(InfoBarMetric metric) const; | |
| 163 | |
| 164 virtual void LogDeveloperEngagementMetric( | |
| 165 DeveloperEngagementMetric metric) const; | |
| 166 | |
| 167 virtual void LogHeuristicTypePrediction( | |
| 168 FieldTypeQualityMetric metric, | |
| 169 AutofillFieldType field_type, | |
| 170 const std::string& experiment_id) const; | |
| 171 virtual void LogOverallTypePrediction( | |
| 172 FieldTypeQualityMetric metric, | |
| 173 AutofillFieldType field_type, | |
| 174 const std::string& experiment_id) const; | |
| 175 virtual void LogServerTypePrediction(FieldTypeQualityMetric metric, | |
| 176 AutofillFieldType field_type, | |
| 177 const std::string& experiment_id) const; | |
| 178 | |
| 179 virtual void LogQualityMetric(QualityMetric metric, | |
| 180 const std::string& experiment_id) const; | |
| 181 | |
| 182 virtual void LogServerQueryMetric(ServerQueryMetric metric) const; | |
| 183 | |
| 184 virtual void LogUserHappinessMetric(UserHappinessMetric metric) const; | |
| 185 | |
| 186 // This should be called when the requestAutocomplete dialog, invoked by the | |
| 187 // |requester|, is closed. |duration| should be the time elapsed between the | |
| 188 // dialog being shown and it being closed. |dismissal_action| should indicate | |
| 189 // whether the user dismissed the dialog by submitting the form data or by | |
| 190 // cancelling. | |
| 191 virtual void LogRequestAutocompleteUiDuration( | |
| 192 const base::TimeDelta& duration, | |
| 193 autofill::DialogType dialog_type, | |
| 194 DialogDismissalAction dismissal_action) const; | |
| 195 | |
| 196 virtual void LogAutocheckoutDuration( | |
| 197 const base::TimeDelta& duration, | |
| 198 AutocheckoutCompletionStatus status) const; | |
| 199 | |
| 200 // This should be called when a form that has been Autofilled is submitted. | |
| 201 // |duration| should be the time elapsed between form load and submission. | |
| 202 virtual void LogFormFillDurationFromLoadWithAutofill( | |
| 203 const base::TimeDelta& duration) const; | |
| 204 | |
| 205 // This should be called when a fillable form that has not been Autofilled is | |
| 206 // submitted. |duration| should be the time elapsed between form load and | |
| 207 // submission. | |
| 208 virtual void LogFormFillDurationFromLoadWithoutAutofill( | |
| 209 const base::TimeDelta& duration) const; | |
| 210 | |
| 211 // This should be called when a form that has been Autofilled is submitted. | |
| 212 // |duration| should be the time elapsed between the initial form interaction | |
| 213 // and submission. | |
| 214 virtual void LogFormFillDurationFromInteractionWithAutofill( | |
| 215 const base::TimeDelta& duration) const; | |
| 216 | |
| 217 // This should be called when a fillable form that has not been Autofilled is | |
| 218 // submitted. |duration| should be the time elapsed between the initial form | |
| 219 // interaction and submission. | |
| 220 virtual void LogFormFillDurationFromInteractionWithoutAutofill( | |
| 221 const base::TimeDelta& duration) const; | |
| 222 | |
| 223 // This should be called each time a page containing forms is loaded. | |
| 224 virtual void LogIsAutofillEnabledAtPageLoad(bool enabled) const; | |
| 225 | |
| 226 // This should be called each time a new profile is launched. | |
| 227 virtual void LogIsAutofillEnabledAtStartup(bool enabled) const; | |
| 228 | |
| 229 // This should be called each time a new profile is launched. | |
| 230 virtual void LogStoredProfileCount(size_t num_profiles) const; | |
| 231 | |
| 232 // Log the number of Autofill suggestions presented to the user when filling a | |
| 233 // form. | |
| 234 virtual void LogAddressSuggestionsCount(size_t num_suggestions) const; | |
| 235 | |
| 236 // Logs the experiment id corresponding to a server query response. | |
| 237 virtual void LogServerExperimentIdForQuery( | |
| 238 const std::string& experiment_id) const; | |
| 239 | |
| 240 // Logs the experiment id corresponding to an upload to the server. | |
| 241 virtual void LogServerExperimentIdForUpload( | |
| 242 const std::string& experiment_id) const; | |
| 243 | |
| 244 private: | |
| 245 DISALLOW_COPY_AND_ASSIGN(AutofillMetrics); | |
| 246 }; | |
| 247 | |
| 248 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_METRICS_H_ | |
| OLD | NEW |