autofill_metrics.h revision 3240926e260ce088908e02ac07a6cf7b0c0cbf44
1// Copyright 2013 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 COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_METRICS_H_ 6#define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_METRICS_H_ 7 8#include <stddef.h> 9#include <string> 10 11#include "base/basictypes.h" 12#include "components/autofill/core/browser/autofill_manager_delegate.h" 13#include "components/autofill/core/browser/field_types.h" 14 15namespace base { 16class TimeDelta; 17} 18 19namespace autofill { 20 21class AutofillMetrics { 22 public: 23 // The possible results of an Autocheckout flow. 24 enum AutocheckoutBuyFlowMetric { 25 // The user has initated Autocheckout. The baseline metric. 26 AUTOCHECKOUT_BUY_FLOW_STARTED, 27 // Autocheckout completed successfully. 28 AUTOCHECKOUT_BUY_FLOW_SUCCESS, 29 // Autocheckout failed due to missing server side data. 30 AUTOCHECKOUT_BUY_FLOW_MISSING_FIELDMAPPING, 31 // Autocheckout failed due to a missing proceed element. 32 AUTOCHECKOUT_BUY_FLOW_MISSING_ADVANCE_ELEMENT, 33 // Autocheckout failed for any number of other reasons, e.g, the proceed 34 // element click failed, the page numbers were not increasing, etc. 35 AUTOCHECKOUT_BUY_FLOW_CANNOT_PROCEED, 36 // Autocheckout failed due to a missing click element before form filling. 37 AUTOCHECKOUT_BUY_FLOW_MISSING_CLICK_ELEMENT_BEFORE_FORM_FILLING, 38 // Autocheckout failed due to a missing click element after form filling. 39 AUTOCHECKOUT_BUY_FLOW_MISSING_CLICK_ELEMENT_AFTER_FORM_FILLING, 40 NUM_AUTOCHECKOUT_BUY_FLOW_METRICS 41 }; 42 43 // The success or failure of Autocheckout. 44 enum AutocheckoutCompletionStatus { 45 AUTOCHECKOUT_CANCELLED, // The user canceled Autocheckout while it was in 46 // progress. 47 AUTOCHECKOUT_FAILED, // The user canceled out of the dialog after 48 // an Autocheckout failure. 49 AUTOCHECKOUT_SUCCEEDED, // The dialog was closed after Autocheckout 50 // succeeded. 51 }; 52 53 // The action a user took to dismiss a bubble. 54 enum BubbleMetric { 55 BUBBLE_CREATED = 0, // The bubble was created. 56 BUBBLE_ACCEPTED, // The user accepted, i.e. confirmed, the 57 // bubble. 58 BUBBLE_DISMISSED, // The user dismissed the bubble. 59 BUBBLE_IGNORED, // The user did not interact with the bubble. 60 BUBBLE_COULD_BE_DISPLAYED, // The bubble could be displayed. 61 NUM_BUBBLE_METRICS, 62 }; 63 64 enum DeveloperEngagementMetric { 65 // Parsed a form that is potentially autofillable. 66 FILLABLE_FORM_PARSED = 0, 67 // Parsed a form that is potentially autofillable and contains at least one 68 // web developer-specified field type hint, a la 69 // http://is.gd/whatwg_autocomplete 70 FILLABLE_FORM_CONTAINS_TYPE_HINTS, 71 NUM_DEVELOPER_ENGAGEMENT_METRICS, 72 }; 73 74 // The action the user took to dismiss a dialog. 75 enum DialogDismissalAction { 76 DIALOG_ACCEPTED = 0, // The user accepted, i.e. submitted, the dialog. 77 DIALOG_CANCELED, // The user canceled out of the dialog. 78 }; 79 80 // The state of the Autofill dialog when it was dismissed. 81 enum DialogDismissalState { 82 // The user submitted with no data available to save. 83 DIALOG_ACCEPTED_EXISTING_DATA, 84 // The saved details to Online Wallet on submit. 85 DIALOG_ACCEPTED_SAVE_TO_WALLET, 86 // The saved details to the local Autofill database on submit. 87 DIALOG_ACCEPTED_SAVE_TO_AUTOFILL, 88 // The user submitted without saving any edited sections. 89 DIALOG_ACCEPTED_NO_SAVE, 90 // The user canceled with no edit UI showing. 91 DIALOG_CANCELED_NO_EDITS, 92 // The user canceled with edit UI showing, but no invalid fields. 93 DIALOG_CANCELED_NO_INVALID_FIELDS, 94 // The user canceled with at least one invalid field. 95 DIALOG_CANCELED_WITH_INVALID_FIELDS, 96 // The user canceled while the sign-in form was showing. 97 DIALOG_CANCELED_DURING_SIGNIN, 98 NUM_DIALOG_DISMISSAL_STATES 99 }; 100 101 // The initial state of user that's interacting with a freshly shown Autofill 102 // dialog. 103 enum DialogInitialUserStateMetric { 104 // Could not determine the user's state due to failure to communicate with 105 // the Wallet server. 106 DIALOG_USER_STATE_UNKNOWN = 0, 107 // Not signed in, no verified Autofill profiles. 108 DIALOG_USER_NOT_SIGNED_IN_NO_AUTOFILL, 109 // Not signed in, has verified Autofill profiles. 110 DIALOG_USER_NOT_SIGNED_IN_HAS_AUTOFILL, 111 // Signed in, no Wallet items, no verified Autofill profiles. 112 DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL, 113 // Signed in, no Wallet items, has verified Autofill profiles. 114 DIALOG_USER_SIGNED_IN_NO_WALLET_HAS_AUTOFILL, 115 // Signed in, has Wallet items, no verified Autofill profiles. 116 DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL, 117 // Signed in, has Wallet items, has verified Autofill profiles. 118 DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL, 119 NUM_DIALOG_INITIAL_USER_STATE_METRICS 120 }; 121 122 // Events related to the Autofill popup shown in a requestAutocomplete or 123 // Autocheckout dialog. 124 enum DialogPopupEvent { 125 // An Autofill popup was shown. 126 DIALOG_POPUP_SHOWN = 0, 127 // The user chose to fill the form with a suggestion from the popup. 128 DIALOG_POPUP_FORM_FILLED, 129 NUM_DIALOG_POPUP_EVENTS 130 }; 131 132 // For measuring the frequency of security warnings or errors that can come 133 // up as part of the requestAutocomplete flow. 134 enum DialogSecurityMetric { 135 // Baseline metric: The dialog was shown. 136 SECURITY_METRIC_DIALOG_SHOWN = 0, 137 // Credit card requested over non-secure protocol. 138 SECURITY_METRIC_CREDIT_CARD_OVER_HTTP, 139 // Autocomplete data requested from a frame hosted on an origin not matching 140 // the main frame's origin. 141 SECURITY_METRIC_CROSS_ORIGIN_FRAME, 142 NUM_DIALOG_SECURITY_METRICS 143 }; 144 145 // For measuring how users are interacting with the Autofill dialog UI. 146 enum DialogUiEvent { 147 // Baseline metric: The dialog was shown. 148 DIALOG_UI_SHOWN = 0, 149 150 // Dialog dismissal actions: 151 DIALOG_UI_ACCEPTED, 152 DIALOG_UI_CANCELED, 153 154 // Selections within the account switcher: 155 // Switched from a Wallet account to local Autofill data. 156 DIALOG_UI_ACCOUNT_CHOOSER_SWITCHED_TO_AUTOFILL, 157 // Switched from local Autofill data to a Wallet account. 158 DIALOG_UI_ACCOUNT_CHOOSER_SWITCHED_TO_WALLET, 159 // Switched from one Wallet account to another one. 160 DIALOG_UI_ACCOUNT_CHOOSER_SWITCHED_WALLET_ACCOUNT, 161 162 // The sign-in UI was shown. 163 DIALOG_UI_SIGNIN_SHOWN, 164 165 // Selecting a different item from a suggestion menu dropdown: 166 DIALOG_UI_EMAIL_SELECTED_SUGGESTION_CHANGED, 167 DIALOG_UI_BILLING_SELECTED_SUGGESTION_CHANGED, 168 DIALOG_UI_CC_BILLING_SELECTED_SUGGESTION_CHANGED, 169 DIALOG_UI_SHIPPING_SELECTED_SUGGESTION_CHANGED, 170 DIALOG_UI_CC_SELECTED_SUGGESTION_CHANGED, 171 172 // Showing the editing UI for a section of the dialog: 173 DIALOG_UI_EMAIL_EDIT_UI_SHOWN, 174 DIALOG_UI_BILLING_EDIT_UI_SHOWN, 175 DIALOG_UI_CC_BILLING_EDIT_UI_SHOWN, 176 DIALOG_UI_SHIPPING_EDIT_UI_SHOWN, 177 DIALOG_UI_CC_EDIT_UI_SHOWN, 178 179 // Adding a new item in a section of the dialog: 180 DIALOG_UI_EMAIL_ITEM_ADDED, 181 DIALOG_UI_BILLING_ITEM_ADDED, 182 DIALOG_UI_CC_BILLING_ITEM_ADDED, 183 DIALOG_UI_SHIPPING_ITEM_ADDED, 184 DIALOG_UI_CC_ITEM_ADDED, 185 186 NUM_DIALOG_UI_EVENTS 187 }; 188 189 enum InfoBarMetric { 190 INFOBAR_SHOWN = 0, // We showed an infobar, e.g. prompting to save credit 191 // card info. 192 INFOBAR_ACCEPTED, // The user explicitly accepted the infobar. 193 INFOBAR_DENIED, // The user explicitly denied the infobar. 194 INFOBAR_IGNORED, // The user completely ignored the infobar (logged on 195 // tab close). 196 NUM_INFO_BAR_METRICS, 197 }; 198 199 // Metrics measuring how well we predict field types. Exactly three such 200 // metrics are logged for each fillable field in a submitted form: for 201 // the heuristic prediction, for the crowd-sourced prediction, and for the 202 // overall prediction. 203 enum FieldTypeQualityMetric { 204 TYPE_UNKNOWN = 0, // Offered no prediction. 205 TYPE_MATCH, // Predicted correctly. 206 TYPE_MISMATCH, // Predicted incorrectly. 207 NUM_FIELD_TYPE_QUALITY_METRICS, 208 }; 209 210 enum QualityMetric { 211 // Logged for each potentially fillable field in a submitted form. 212 FIELD_SUBMITTED = 0, 213 214 // A simple successs metric, logged for each field that returns true for 215 // |is_autofilled()|. 216 FIELD_AUTOFILLED, 217 218 // A simple failure metric, logged for each field that returns false for 219 // |is_autofilled()| but has a value that is present in the personal data 220 // manager. 221 FIELD_NOT_AUTOFILLED, 222 223 // The below are only logged when |FIELD_AUTOFILL_FAILED| is also logged. 224 NOT_AUTOFILLED_HEURISTIC_TYPE_UNKNOWN, 225 NOT_AUTOFILLED_HEURISTIC_TYPE_MATCH, 226 NOT_AUTOFILLED_HEURISTIC_TYPE_MISMATCH, 227 NOT_AUTOFILLED_SERVER_TYPE_UNKNOWN, 228 NOT_AUTOFILLED_SERVER_TYPE_MATCH, 229 NOT_AUTOFILLED_SERVER_TYPE_MISMATCH, 230 NUM_QUALITY_METRICS, 231 }; 232 233 // Each of these is logged at most once per query to the server, which in turn 234 // occurs at most once per page load. 235 enum ServerQueryMetric { 236 QUERY_SENT = 0, // Sent a query to the server. 237 QUERY_RESPONSE_RECEIVED, // Received a response. 238 QUERY_RESPONSE_PARSED, // Successfully parsed the server response. 239 240 // The response was parseable, but provided no improvements relative to our 241 // heuristics. 242 QUERY_RESPONSE_MATCHED_LOCAL_HEURISTICS, 243 244 // Our heuristics detected at least one auto-fillable field, and the server 245 // response overrode the type of at least one field. 246 QUERY_RESPONSE_OVERRODE_LOCAL_HEURISTICS, 247 248 // Our heuristics did not detect any auto-fillable fields, but the server 249 // response did detect at least one. 250 QUERY_RESPONSE_WITH_NO_LOCAL_HEURISTICS, 251 NUM_SERVER_QUERY_METRICS, 252 }; 253 254 // Each of these metrics is logged only for potentially autofillable forms, 255 // i.e. forms with at least three fields, etc. 256 // These are used to derive certain "user happiness" metrics. For example, we 257 // can compute the ratio (USER_DID_EDIT_AUTOFILLED_FIELD / USER_DID_AUTOFILL) 258 // to see how often users have to correct autofilled data. 259 enum UserHappinessMetric { 260 // Loaded a page containing forms. 261 FORMS_LOADED, 262 // Submitted a fillable form -- i.e. one with at least three field values 263 // that match the user's stored Autofill data -- and all matching fields 264 // were autofilled. 265 SUBMITTED_FILLABLE_FORM_AUTOFILLED_ALL, 266 // Submitted a fillable form and some (but not all) matching fields were 267 // autofilled. 268 SUBMITTED_FILLABLE_FORM_AUTOFILLED_SOME, 269 // Submitted a fillable form and no fields were autofilled. 270 SUBMITTED_FILLABLE_FORM_AUTOFILLED_NONE, 271 // Submitted a non-fillable form. 272 SUBMITTED_NON_FILLABLE_FORM, 273 274 // User manually filled one of the form fields. 275 USER_DID_TYPE, 276 // We showed a popup containing Autofill suggestions. 277 SUGGESTIONS_SHOWN, 278 // Same as above, but only logged once per page load. 279 SUGGESTIONS_SHOWN_ONCE, 280 // User autofilled at least part of the form. 281 USER_DID_AUTOFILL, 282 // Same as above, but only logged once per page load. 283 USER_DID_AUTOFILL_ONCE, 284 // User edited a previously autofilled field. 285 USER_DID_EDIT_AUTOFILLED_FIELD, 286 // Same as above, but only logged once per page load. 287 USER_DID_EDIT_AUTOFILLED_FIELD_ONCE, 288 NUM_USER_HAPPINESS_METRICS, 289 }; 290 291 // For measuring the network request time of various Wallet API calls. See 292 // WalletClient::RequestType. 293 enum WalletApiCallMetric { 294 UNKNOWN_API_CALL, // Catch all. Should never be used. 295 ACCEPT_LEGAL_DOCUMENTS, 296 AUTHENTICATE_INSTRUMENT, 297 GET_FULL_WALLET, 298 GET_WALLET_ITEMS, 299 SEND_STATUS, 300 SAVE_TO_WALLET, 301 }; 302 303 // For measuring the frequency of errors while communicating with the Wallet 304 // server. 305 enum WalletErrorMetric { 306 // Baseline metric: Issued a request to the Wallet server. 307 WALLET_ERROR_BASELINE_ISSUED_REQUEST = 0, 308 // A fatal error occured while communicating with the Wallet server. This 309 // value has been deprecated. 310 WALLET_FATAL_ERROR_DEPRECATED, 311 // Received a malformed response from the Wallet server. 312 WALLET_MALFORMED_RESPONSE, 313 // A network error occured while communicating with the Wallet server. 314 WALLET_NETWORK_ERROR, 315 // The request was malformed. 316 WALLET_BAD_REQUEST, 317 // Risk deny, unsupported country, or account closed. 318 WALLET_BUYER_ACCOUNT_ERROR, 319 // Unknown server side error. 320 WALLET_INTERNAL_ERROR, 321 // API call had missing or invalid parameters. 322 WALLET_INVALID_PARAMS, 323 // Online Wallet is down. 324 WALLET_SERVICE_UNAVAILABLE, 325 // User needs make a cheaper transaction or not use Online Wallet. This 326 // value has been deprecated. 327 WALLET_SPENDING_LIMIT_EXCEEDED_DEPRECATED, 328 // The server API version of the request is no longer supported. 329 WALLET_UNSUPPORTED_API_VERSION, 330 // Catch all error type. 331 WALLET_UNKNOWN_ERROR, 332 NUM_WALLET_ERROR_METRICS 333 }; 334 335 // For measuring the frequency of "required actions" returned by the Wallet 336 // server. This is similar to the autofill::wallet::RequiredAction enum; 337 // but unlike that enum, the values in this one must remain constant over 338 // time, so that the metrics can be consistently interpreted on the 339 // server-side. 340 enum WalletRequiredActionMetric { 341 // Baseline metric: Issued a request to the Wallet server. 342 WALLET_REQUIRED_ACTION_BASELINE_ISSUED_REQUEST = 0, 343 // Values from the autofill::wallet::RequiredAction enum: 344 UNKNOWN_REQUIRED_ACTION, // Catch all type. 345 GAIA_AUTH, 346 PASSIVE_GAIA_AUTH, 347 SETUP_WALLET, 348 ACCEPT_TOS, 349 UPDATE_EXPIRATION_DATE, 350 UPGRADE_MIN_ADDRESS, 351 CHOOSE_ANOTHER_INSTRUMENT_OR_ADDRESS, 352 VERIFY_CVV, 353 INVALID_FORM_FIELD, 354 REQUIRE_PHONE_NUMBER, 355 NUM_WALLET_REQUIRED_ACTIONS 356 }; 357 358 // The success or failure of downloading Autocheckout whitelist file. 359 enum AutocheckoutWhitelistDownloadStatus { 360 AUTOCHECKOUT_WHITELIST_DOWNLOAD_FAILED, 361 AUTOCHECKOUT_WHITELIST_DOWNLOAD_SUCCEEDED, 362 }; 363 364 AutofillMetrics(); 365 virtual ~AutofillMetrics(); 366 367 // Logs how the user interacted with the Autocheckout bubble. 368 virtual void LogAutocheckoutBubbleMetric(BubbleMetric metric) const; 369 370 // Logs the result of an Autocheckout buy flow. 371 virtual void LogAutocheckoutBuyFlowMetric( 372 AutocheckoutBuyFlowMetric metric) const; 373 374 virtual void LogCreditCardInfoBarMetric(InfoBarMetric metric) const; 375 376 virtual void LogDeveloperEngagementMetric( 377 DeveloperEngagementMetric metric) const; 378 379 virtual void LogHeuristicTypePrediction( 380 FieldTypeQualityMetric metric, 381 ServerFieldType field_type, 382 const std::string& experiment_id) const; 383 virtual void LogOverallTypePrediction( 384 FieldTypeQualityMetric metric, 385 ServerFieldType field_type, 386 const std::string& experiment_id) const; 387 virtual void LogServerTypePrediction(FieldTypeQualityMetric metric, 388 ServerFieldType field_type, 389 const std::string& experiment_id) const; 390 391 virtual void LogQualityMetric(QualityMetric metric, 392 const std::string& experiment_id) const; 393 394 virtual void LogServerQueryMetric(ServerQueryMetric metric) const; 395 396 virtual void LogUserHappinessMetric(UserHappinessMetric metric) const; 397 398 // Logs |state| to the dismissal states histogram for |dialog_type|. 399 virtual void LogDialogDismissalState(autofill::DialogType dialog_type, 400 DialogDismissalState state) const; 401 402 // This should be called as soon as the user's signed-in status and Wallet 403 // item count is known. Records that a user starting out in |user_state| is 404 // interacting with a dialog of |dialog_type|. 405 virtual void LogDialogInitialUserState( 406 autofill::DialogType dialog_type, 407 DialogInitialUserStateMetric user_type) const; 408 409 // Logs the time elapsed between the dialog being shown for |dialog_type| and 410 // when it is ready for user interaction. 411 virtual void LogDialogLatencyToShow(autofill::DialogType dialog_type, 412 const base::TimeDelta& duration) const; 413 414 // Logs |event| to the popup events histogram for |dialog_type|. 415 virtual void LogDialogPopupEvent(autofill::DialogType dialog_type, 416 DialogPopupEvent event) const; 417 418 // Logs |metric| to the security metrics histogram for |dialog_type|. 419 virtual void LogDialogSecurityMetric(autofill::DialogType dialog_type, 420 DialogSecurityMetric metric) const; 421 422 // This should be called when the Autofill dialog, invoked by a dialog of type 423 // |dialog_type|, is closed. |duration| should be the time elapsed between 424 // the dialog being shown and it being closed. |dismissal_action| should 425 // indicate whether the user dismissed the dialog by submitting the form data 426 // or by canceling. 427 virtual void LogDialogUiDuration( 428 const base::TimeDelta& duration, 429 autofill::DialogType dialog_type, 430 DialogDismissalAction dismissal_action) const; 431 432 // Logs |event| to the UI events histogram for |dialog_type|. 433 virtual void LogDialogUiEvent(autofill::DialogType dialog_type, 434 DialogUiEvent event) const; 435 436 // Logs |metric| to the Wallet errors histogram for |dialog_type|. 437 virtual void LogWalletErrorMetric(autofill::DialogType dialog_type, 438 WalletErrorMetric metric) const; 439 440 // Logs the network request time of Wallet API calls. 441 virtual void LogWalletApiCallDuration( 442 WalletApiCallMetric metric, 443 const base::TimeDelta& duration) const; 444 445 // Logs |required_action| to the required actions histogram for |dialog_type|. 446 virtual void LogWalletRequiredActionMetric( 447 autofill::DialogType dialog_type, 448 WalletRequiredActionMetric required_action) const; 449 450 virtual void LogAutocheckoutDuration( 451 const base::TimeDelta& duration, 452 AutocheckoutCompletionStatus status) const; 453 454 // Logs the time taken to download Autocheckout whitelist file. 455 virtual void LogAutocheckoutWhitelistDownloadDuration( 456 const base::TimeDelta& duration, 457 AutocheckoutWhitelistDownloadStatus status) const; 458 459 // This should be called when a form that has been Autofilled is submitted. 460 // |duration| should be the time elapsed between form load and submission. 461 virtual void LogFormFillDurationFromLoadWithAutofill( 462 const base::TimeDelta& duration) const; 463 464 // This should be called when a fillable form that has not been Autofilled is 465 // submitted. |duration| should be the time elapsed between form load and 466 // submission. 467 virtual void LogFormFillDurationFromLoadWithoutAutofill( 468 const base::TimeDelta& duration) const; 469 470 // This should be called when a form that has been Autofilled is submitted. 471 // |duration| should be the time elapsed between the initial form interaction 472 // and submission. 473 virtual void LogFormFillDurationFromInteractionWithAutofill( 474 const base::TimeDelta& duration) const; 475 476 // This should be called when a fillable form that has not been Autofilled is 477 // submitted. |duration| should be the time elapsed between the initial form 478 // interaction and submission. 479 virtual void LogFormFillDurationFromInteractionWithoutAutofill( 480 const base::TimeDelta& duration) const; 481 482 // This should be called each time a page containing forms is loaded. 483 virtual void LogIsAutofillEnabledAtPageLoad(bool enabled) const; 484 485 // This should be called each time a new profile is launched. 486 virtual void LogIsAutofillEnabledAtStartup(bool enabled) const; 487 488 // This should be called each time a new profile is launched. 489 virtual void LogStoredProfileCount(size_t num_profiles) const; 490 491 // Log the number of Autofill suggestions presented to the user when filling a 492 // form. 493 virtual void LogAddressSuggestionsCount(size_t num_suggestions) const; 494 495 // Logs the experiment id corresponding to a server query response. 496 virtual void LogServerExperimentIdForQuery( 497 const std::string& experiment_id) const; 498 499 // Logs the experiment id corresponding to an upload to the server. 500 virtual void LogServerExperimentIdForUpload( 501 const std::string& experiment_id) const; 502 503 private: 504 DISALLOW_COPY_AND_ASSIGN(AutofillMetrics); 505}; 506 507} // namespace autofill 508 509#endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_METRICS_H_ 510