Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / components / autofill / core / browser / autofill_metrics.h
blob89b0ebd6a9ade64e7913f62ded2a8ffea19e4ad6
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.
5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_METRICS_H_
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_METRICS_H_
8 #include <stddef.h>
9 #include <string>
11 #include "base/basictypes.h"
12 #include "components/autofill/core/browser/autofill_client.h"
13 #include "components/autofill/core/browser/autofill_profile.h"
14 #include "components/autofill/core/browser/credit_card.h"
15 #include "components/autofill/core/browser/field_types.h"
17 namespace base {
18 class TimeDelta;
21 namespace autofill {
23 class AutofillMetrics {
24 public:
25 enum DeveloperEngagementMetric {
26 // Parsed a form that is potentially autofillable.
27 FILLABLE_FORM_PARSED = 0,
28 // Parsed a form that is potentially autofillable and contains at least one
29 // web developer-specified field type hint, a la
30 // http://is.gd/whatwg_autocomplete
31 FILLABLE_FORM_CONTAINS_TYPE_HINTS,
32 NUM_DEVELOPER_ENGAGEMENT_METRICS,
35 // The action the user took to dismiss a dialog.
36 enum DialogDismissalAction {
37 DIALOG_ACCEPTED = 0, // The user accepted, i.e. submitted, the dialog.
38 DIALOG_CANCELED, // The user canceled out of the dialog.
41 // The state of the Autofill dialog when it was dismissed.
42 enum DialogDismissalState {
43 // The user submitted with no data available to save.
44 DEPRECATED_DIALOG_ACCEPTED_EXISTING_DATA,
45 // The saved details to Online Wallet on submit.
46 DIALOG_ACCEPTED_SAVE_TO_WALLET,
47 // The saved details to the local Autofill database on submit.
48 DIALOG_ACCEPTED_SAVE_TO_AUTOFILL,
49 // The user submitted without saving any edited sections.
50 DIALOG_ACCEPTED_NO_SAVE,
51 // The user canceled with no edit UI showing.
52 DIALOG_CANCELED_NO_EDITS,
53 // The user canceled with edit UI showing, but no invalid fields.
54 DIALOG_CANCELED_NO_INVALID_FIELDS,
55 // The user canceled with at least one invalid field.
56 DIALOG_CANCELED_WITH_INVALID_FIELDS,
57 // The user canceled while the sign-in form was showing.
58 DIALOG_CANCELED_DURING_SIGNIN,
59 // The user submitted using data already stored in Wallet.
60 DIALOG_ACCEPTED_EXISTING_WALLET_DATA,
61 // The user submitted using data already stored in Autofill.
62 DIALOG_ACCEPTED_EXISTING_AUTOFILL_DATA,
63 NUM_DIALOG_DISMISSAL_STATES
66 // The initial state of user that's interacting with a freshly shown Autofill
67 // dialog.
68 enum DialogInitialUserStateMetric {
69 // Could not determine the user's state due to failure to communicate with
70 // the Wallet server.
71 DIALOG_USER_STATE_UNKNOWN = 0,
72 // Not signed in, no verified Autofill profiles.
73 DIALOG_USER_NOT_SIGNED_IN_NO_AUTOFILL,
74 // Not signed in, has verified Autofill profiles.
75 DIALOG_USER_NOT_SIGNED_IN_HAS_AUTOFILL,
76 // Signed in, no Wallet items, no verified Autofill profiles.
77 DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL,
78 // Signed in, no Wallet items, has verified Autofill profiles.
79 DIALOG_USER_SIGNED_IN_NO_WALLET_HAS_AUTOFILL,
80 // Signed in, has Wallet items, no verified Autofill profiles.
81 DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL,
82 // Signed in, has Wallet items, has verified Autofill profiles.
83 DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL,
84 NUM_DIALOG_INITIAL_USER_STATE_METRICS
87 // Events related to the Autofill popup shown in a requestAutocomplete
88 // dialog.
89 enum DialogPopupEvent {
90 // An Autofill popup was shown.
91 DIALOG_POPUP_SHOWN = 0,
92 // The user chose to fill the form with a suggestion from the popup.
93 DIALOG_POPUP_FORM_FILLED,
94 NUM_DIALOG_POPUP_EVENTS
97 // For measuring the frequency of security warnings or errors that can come
98 // up as part of the requestAutocomplete flow.
99 enum DialogSecurityMetric {
100 // Baseline metric: The dialog was shown.
101 SECURITY_METRIC_DIALOG_SHOWN = 0,
102 // Credit card requested over non-secure protocol.
103 SECURITY_METRIC_CREDIT_CARD_OVER_HTTP,
104 // Autocomplete data requested from a frame hosted on an origin not matching
105 // the main frame's origin.
106 SECURITY_METRIC_CROSS_ORIGIN_FRAME,
107 NUM_DIALOG_SECURITY_METRICS
110 // For measuring how users are interacting with the Autofill dialog UI.
111 enum DialogUiEvent {
112 // Baseline metric: The dialog was shown.
113 DIALOG_UI_SHOWN = 0,
115 // Dialog dismissal actions:
116 DIALOG_UI_ACCEPTED,
117 DIALOG_UI_CANCELED,
119 // Selections within the account switcher:
120 // Switched from a Wallet account to local Autofill data.
121 DIALOG_UI_ACCOUNT_CHOOSER_SWITCHED_TO_AUTOFILL,
122 // Switched from local Autofill data to a Wallet account.
123 DIALOG_UI_ACCOUNT_CHOOSER_SWITCHED_TO_WALLET,
124 // Switched from one Wallet account to another one.
125 DIALOG_UI_ACCOUNT_CHOOSER_SWITCHED_WALLET_ACCOUNT,
127 // The sign-in UI was shown.
128 DIALOG_UI_SIGNIN_SHOWN,
130 // Selecting a different item from a suggestion menu dropdown:
131 DEPRECATED_DIALOG_UI_EMAIL_SELECTED_SUGGESTION_CHANGED,
132 DIALOG_UI_BILLING_SELECTED_SUGGESTION_CHANGED,
133 DIALOG_UI_CC_BILLING_SELECTED_SUGGESTION_CHANGED,
134 DIALOG_UI_SHIPPING_SELECTED_SUGGESTION_CHANGED,
135 DIALOG_UI_CC_SELECTED_SUGGESTION_CHANGED,
137 // Showing the editing UI for a section of the dialog:
138 DEPRECATED_DIALOG_UI_EMAIL_EDIT_UI_SHOWN,
139 DEPRECATED_DIALOG_UI_BILLING_EDIT_UI_SHOWN,
140 DEPRECATED_DIALOG_UI_CC_BILLING_EDIT_UI_SHOWN,
141 DEPRECATED_DIALOG_UI_SHIPPING_EDIT_UI_SHOWN,
142 DEPRECATED_DIALOG_UI_CC_EDIT_UI_SHOWN,
144 // Adding a new item in a section of the dialog:
145 DEPRECATED_DIALOG_UI_EMAIL_ITEM_ADDED,
146 DIALOG_UI_BILLING_ITEM_ADDED,
147 DIALOG_UI_CC_BILLING_ITEM_ADDED,
148 DIALOG_UI_SHIPPING_ITEM_ADDED,
149 DIALOG_UI_CC_ITEM_ADDED,
151 // Also an account switcher menu item. The user selected the
152 // "add account" option.
153 DIALOG_UI_ACCOUNT_CHOOSER_TRIED_TO_ADD_ACCOUNT,
155 NUM_DIALOG_UI_EVENTS
158 enum InfoBarMetric {
159 INFOBAR_SHOWN = 0, // We showed an infobar, e.g. prompting to save credit
160 // card info.
161 INFOBAR_ACCEPTED, // The user explicitly accepted the infobar.
162 INFOBAR_DENIED, // The user explicitly denied the infobar.
163 INFOBAR_IGNORED, // The user completely ignored the infobar (logged on
164 // tab close).
165 NUM_INFO_BAR_METRICS,
168 // Metrics measuring how well we predict field types. Exactly three such
169 // metrics are logged for each fillable field in a submitted form: for
170 // the heuristic prediction, for the crowd-sourced prediction, and for the
171 // overall prediction.
172 enum FieldTypeQualityMetric {
173 TYPE_UNKNOWN = 0, // Offered no prediction.
174 TYPE_MATCH, // Predicted correctly.
175 TYPE_MISMATCH, // Predicted incorrectly.
176 NUM_FIELD_TYPE_QUALITY_METRICS,
179 // Each of these is logged at most once per query to the server, which in turn
180 // occurs at most once per page load.
181 enum ServerQueryMetric {
182 QUERY_SENT = 0, // Sent a query to the server.
183 QUERY_RESPONSE_RECEIVED, // Received a response.
184 QUERY_RESPONSE_PARSED, // Successfully parsed the server response.
186 // The response was parseable, but provided no improvements relative to our
187 // heuristics.
188 QUERY_RESPONSE_MATCHED_LOCAL_HEURISTICS,
190 // Our heuristics detected at least one auto-fillable field, and the server
191 // response overrode the type of at least one field.
192 QUERY_RESPONSE_OVERRODE_LOCAL_HEURISTICS,
194 // Our heuristics did not detect any auto-fillable fields, but the server
195 // response did detect at least one.
196 QUERY_RESPONSE_WITH_NO_LOCAL_HEURISTICS,
197 NUM_SERVER_QUERY_METRICS,
200 // Logs usage of "Scan card" control item.
201 enum ScanCreditCardPromptMetric {
202 // "Scan card" was presented to the user.
203 SCAN_CARD_ITEM_SHOWN,
204 // "Scan card" was selected by the user.
205 SCAN_CARD_ITEM_SELECTED,
206 // The user selected something in the dropdown besides "scan card".
207 SCAN_CARD_OTHER_ITEM_SELECTED,
208 NUM_SCAN_CREDIT_CARD_PROMPT_METRICS,
211 // Each of these metrics is logged only for potentially autofillable forms,
212 // i.e. forms with at least three fields, etc.
213 // These are used to derive certain "user happiness" metrics. For example, we
214 // can compute the ratio (USER_DID_EDIT_AUTOFILLED_FIELD / USER_DID_AUTOFILL)
215 // to see how often users have to correct autofilled data.
216 enum UserHappinessMetric {
217 // Loaded a page containing forms.
218 FORMS_LOADED,
219 // Submitted a fillable form -- i.e. one with at least three field values
220 // that match the user's stored Autofill data -- and all matching fields
221 // were autofilled.
222 SUBMITTED_FILLABLE_FORM_AUTOFILLED_ALL,
223 // Submitted a fillable form and some (but not all) matching fields were
224 // autofilled.
225 SUBMITTED_FILLABLE_FORM_AUTOFILLED_SOME,
226 // Submitted a fillable form and no fields were autofilled.
227 SUBMITTED_FILLABLE_FORM_AUTOFILLED_NONE,
228 // Submitted a non-fillable form. This also counts entering new data into
229 // a form with identified fields. Because we didn't have the data the user
230 // wanted, from the user's perspective, the form was not autofillable.
231 SUBMITTED_NON_FILLABLE_FORM,
233 // User manually filled one of the form fields.
234 USER_DID_TYPE,
235 // We showed a popup containing Autofill suggestions.
236 SUGGESTIONS_SHOWN,
237 // Same as above, but only logged once per page load.
238 SUGGESTIONS_SHOWN_ONCE,
239 // User autofilled at least part of the form.
240 USER_DID_AUTOFILL,
241 // Same as above, but only logged once per page load.
242 USER_DID_AUTOFILL_ONCE,
243 // User edited a previously autofilled field.
244 USER_DID_EDIT_AUTOFILLED_FIELD,
245 // Same as above, but only logged once per page load.
246 USER_DID_EDIT_AUTOFILLED_FIELD_ONCE,
247 NUM_USER_HAPPINESS_METRICS,
250 // Form Events for autofill.
251 // These events are triggered separetly for address and credit card forms.
252 enum FormEvent {
253 // User interacted with a field of this kind of form. Logged only once per
254 // page load.
255 FORM_EVENT_INTERACTED_ONCE = 0,
256 // A dropdown with suggestions was shown.
257 FORM_EVENT_SUGGESTIONS_SHOWN,
258 // Same as above, but recoreded only once per page load.
259 FORM_EVENT_SUGGESTIONS_SHOWN_ONCE,
260 // A local suggestion was used to fill the form.
261 FORM_EVENT_LOCAL_SUGGESTION_FILLED,
262 // A server suggestion was used to fill the form.
263 // When dealing with credit cards, this means a full server card was used
264 // to fill.
265 FORM_EVENT_SERVER_SUGGESTION_FILLED,
266 // A masked server card suggestion was used to fill the form.
267 FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED,
268 // A suggestion was used to fill the form. The origin type (local or server
269 // or masked server card) of the first selected within a page load will
270 // determine which of the following two will be fired.
271 FORM_EVENT_LOCAL_SUGGESTION_FILLED_ONCE,
272 FORM_EVENT_SERVER_SUGGESTION_FILLED_ONCE,
273 FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED_ONCE,
274 // A form was submitted. Depending on the user filling a local, server,
275 // masked server card or no suggestion one of the following will be
276 // triggered. Only one of the following four will be triggered per page
277 // load.
278 FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE,
279 FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE,
280 FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE,
281 FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SUBMITTED_ONCE,
282 // A masked server card suggestion was selected to fill the form.
283 FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED,
284 // Same as above but only triggered once per page load.
285 FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED_ONCE,
286 // An autofillable form is about to be submitted. If the submission is not
287 // interrupted by JavaScript, the "form submitted" events above will also be
288 // logged. Depending on the user filling a local, server, masked server card
289 // or no suggestion one of the following will be triggered, at most once per
290 // page load.
291 FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE,
292 FORM_EVENT_LOCAL_SUGGESTION_WILL_SUBMIT_ONCE,
293 FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE,
294 FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_WILL_SUBMIT_ONCE,
296 NUM_FORM_EVENTS,
299 // Events related to the Unmask Credit Card Prompt.
300 enum UnmaskPromptEvent {
301 // The prompt was shown.
302 UNMASK_PROMPT_SHOWN = 0,
303 // The prompt was closed without attempting to unmask the card.
304 UNMASK_PROMPT_CLOSED_NO_ATTEMPTS,
305 // The prompt was closed without unmasking the card, but with at least
306 // one attempt. The last failure was retriable.
307 UNMASK_PROMPT_CLOSED_FAILED_TO_UNMASK_RETRIABLE_FAILURE,
308 // The prompt was closed without unmasking the card, but with at least
309 // one attempt. The last failure was non retriable.
310 UNMASK_PROMPT_CLOSED_FAILED_TO_UNMASK_NON_RETRIABLE_FAILURE,
311 // Successfully unmasked the card in the first attempt.
312 UNMASK_PROMPT_UNMASKED_CARD_FIRST_ATTEMPT,
313 // Successfully unmasked the card after retriable failures.
314 UNMASK_PROMPT_UNMASKED_CARD_AFTER_FAILED_ATTEMPTS,
315 // Saved the card locally (masked card was upgraded to a full card).
316 UNMASK_PROMPT_SAVED_CARD_LOCALLY,
317 // User chose to opt in (checked the checkbox when it was empty).
318 // Only logged if there was an attempt to unmask.
319 UNMASK_PROMPT_LOCAL_SAVE_DID_OPT_IN,
320 // User did not opt in when he had the chance (left the checkbox unchecked).
321 // Only logged if there was an attempt to unmask.
322 UNMASK_PROMPT_LOCAL_SAVE_DID_NOT_OPT_IN,
323 // User chose to opt out (unchecked the checkbox when it was check).
324 // Only logged if there was an attempt to unmask.
325 UNMASK_PROMPT_LOCAL_SAVE_DID_OPT_OUT,
326 // User did not opt out when he had a chance (left the checkbox checked).
327 // Only logged if there was an attempt to unmask.
328 UNMASK_PROMPT_LOCAL_SAVE_DID_NOT_OPT_OUT,
329 // The prompt was closed while chrome was unmasking the card (user pressed
330 // verify and we were waiting for the server response).
331 UNMASK_PROMPT_CLOSED_ABANDON_UNMASKING,
332 NUM_UNMASK_PROMPT_EVENTS,
335 // Possible results of the GetRealPan call.
336 enum GetRealPanResult {
337 // Request succeeded.
338 GET_REAL_PAN_RESULT_SUCCESS = 0,
339 // Request failed; try again.
340 GET_REAL_PAN_RESULT_TRY_AGAIN_FAILURE,
341 // Request failed; don't try again.
342 GET_REAL_PAN_RESULT_PERMANENT_FAILURE,
343 // Unable to connect to Wallet servers.
344 GET_REAL_PAN_RESULT_NETWORK_ERROR,
345 NUM_GET_REAL_PAN_RESULTS,
348 // For measuring the network request time of various Wallet API calls. See
349 // WalletClient::RequestType.
350 enum WalletApiCallMetric {
351 UNKNOWN_API_CALL, // Catch all. Should never be used.
352 ACCEPT_LEGAL_DOCUMENTS,
353 AUTHENTICATE_INSTRUMENT,
354 GET_FULL_WALLET,
355 GET_WALLET_ITEMS,
356 SAVE_TO_WALLET,
357 NUM_WALLET_API_CALLS
360 // For measuring the frequency of errors while communicating with the Wallet
361 // server.
362 enum WalletErrorMetric {
363 // Baseline metric: Issued a request to the Wallet server.
364 WALLET_ERROR_BASELINE_ISSUED_REQUEST = 0,
365 // A fatal error occured while communicating with the Wallet server. This
366 // value has been deprecated.
367 WALLET_FATAL_ERROR_DEPRECATED,
368 // Received a malformed response from the Wallet server.
369 WALLET_MALFORMED_RESPONSE,
370 // A network error occured while communicating with the Wallet server.
371 WALLET_NETWORK_ERROR,
372 // The request was malformed.
373 WALLET_BAD_REQUEST,
374 // Risk deny, unsupported country, or account closed.
375 WALLET_BUYER_ACCOUNT_ERROR,
376 // Unknown server side error.
377 WALLET_INTERNAL_ERROR,
378 // API call had missing or invalid parameters.
379 WALLET_INVALID_PARAMS,
380 // Online Wallet is down.
381 WALLET_SERVICE_UNAVAILABLE,
382 // User needs make a cheaper transaction or not use Online Wallet.
383 WALLET_SPENDING_LIMIT_EXCEEDED,
384 // The server API version of the request is no longer supported.
385 WALLET_UNSUPPORTED_API_VERSION,
386 // Catch all error type.
387 WALLET_UNKNOWN_ERROR,
388 // The merchant has been blacklisted for Online Wallet due to some manner
389 // of compliance violation.
390 WALLET_UNSUPPORTED_MERCHANT,
391 // Buyer Legal Address has a country which is unsupported by Wallet.
392 WALLET_BUYER_LEGAL_ADDRESS_NOT_SUPPORTED,
393 // Wallet's Know Your Customer(KYC) action is pending/failed for this user.
394 WALLET_UNVERIFIED_KNOW_YOUR_CUSTOMER_STATUS,
395 // Chrome version is unsupported or provided API key not allowed.
396 WALLET_UNSUPPORTED_USER_AGENT_OR_API_KEY,
397 NUM_WALLET_ERROR_METRICS
400 // For measuring the frequency of "required actions" returned by the Wallet
401 // server. This is similar to the autofill::wallet::RequiredAction enum;
402 // but unlike that enum, the values in this one must remain constant over
403 // time, so that the metrics can be consistently interpreted on the
404 // server-side.
405 enum WalletRequiredActionMetric {
406 // Baseline metric: Issued a request to the Wallet server.
407 WALLET_REQUIRED_ACTION_BASELINE_ISSUED_REQUEST = 0,
408 // Values from the autofill::wallet::RequiredAction enum:
409 UNKNOWN_REQUIRED_ACTION, // Catch all type.
410 GAIA_AUTH,
411 PASSIVE_GAIA_AUTH,
412 SETUP_WALLET,
413 ACCEPT_TOS,
414 UPDATE_EXPIRATION_DATE,
415 UPGRADE_MIN_ADDRESS,
416 CHOOSE_ANOTHER_INSTRUMENT_OR_ADDRESS,
417 VERIFY_CVV,
418 INVALID_FORM_FIELD,
419 REQUIRE_PHONE_NUMBER,
420 NUM_WALLET_REQUIRED_ACTIONS
423 // For measuring the increased load on the Autofill server if the restriction
424 // on querying for password forms with fewer than 3 fields were omitted.
425 enum PasswordFormQueryVolumeMetric {
426 NEW_PASSWORD_QUERY,
427 CURRENT_QUERY,
428 NUM_PASSWORD_FORM_QUERY_VOLUME_METRIC,
431 static void LogCreditCardInfoBarMetric(InfoBarMetric metric);
432 static void LogScanCreditCardPromptMetric(ScanCreditCardPromptMetric metric);
434 // Should be called when credit card scan is finished. |duration| should be
435 // the time elapsed between launching the credit card scanner and getting back
436 // the result. |completed| should be true if a credit card was scanned, false
437 // if the scan was cancelled.
438 static void LogScanCreditCardCompleted(const base::TimeDelta& duration,
439 bool completed);
441 static void LogDeveloperEngagementMetric(DeveloperEngagementMetric metric);
443 static void LogHeuristicTypePrediction(FieldTypeQualityMetric metric,
444 ServerFieldType field_type);
445 static void LogOverallTypePrediction(FieldTypeQualityMetric metric,
446 ServerFieldType field_type);
447 static void LogServerTypePrediction(FieldTypeQualityMetric metric,
448 ServerFieldType field_type);
450 static void LogServerQueryMetric(ServerQueryMetric metric);
452 static void LogUserHappinessMetric(UserHappinessMetric metric);
454 // Logs |state| to the dismissal states histogram.
455 static void LogDialogDismissalState(DialogDismissalState state);
457 // This should be called as soon as the user's signed-in status and Wallet
458 // item count is known. Records that a user starting out in |user_state| is
459 // interacting with a dialog.
460 static void LogDialogInitialUserState(DialogInitialUserStateMetric user_type);
462 // Logs the time elapsed between the dialog being shown and when it is ready
463 // for user interaction.
464 static void LogDialogLatencyToShow(const base::TimeDelta& duration);
466 // Logs |event| to the popup events histogram.
467 static void LogDialogPopupEvent(DialogPopupEvent event);
469 // Logs |metric| to the security metrics histogram.
470 static void LogDialogSecurityMetric(DialogSecurityMetric metric);
472 // This should be called when the Autofill dialog is closed. |duration|
473 // should be the time elapsed between the dialog being shown and it being
474 // closed. |dismissal_action| should indicate whether the user dismissed
475 // the dialog by submitting the form data or by canceling.
476 static void LogDialogUiDuration(const base::TimeDelta& duration,
477 DialogDismissalAction dismissal_action);
479 // Logs |event| to the UI events histogram.
480 static void LogDialogUiEvent(DialogUiEvent event);
482 // Logs |event| to the unmask prompt events histogram.
483 static void LogUnmaskPromptEvent(UnmaskPromptEvent event);
485 // Logs the time elapsed between the unmask prompt being shown and it
486 // being closed.
487 static void LogUnmaskPromptEventDuration(const base::TimeDelta& duration,
488 UnmaskPromptEvent close_event);
490 // Logs the time elapsed between the user clicking Verify and
491 // hitting cancel when abandoning a pending unmasking operation
492 // (aka GetRealPan).
493 static void LogTimeBeforeAbandonUnmasking(const base::TimeDelta& duration);
495 // Logs |result| to the get real pan result histogram.
496 static void LogRealPanResult(AutofillClient::GetRealPanResult result);
498 // Logs |result| to duration of the GetRealPan RPC.
499 static void LogRealPanDuration(const base::TimeDelta& duration,
500 AutofillClient::GetRealPanResult result);
502 // Logs |result| to the get real pan result histogram.
503 static void LogUnmaskingDuration(const base::TimeDelta& duration,
504 AutofillClient::GetRealPanResult result);
506 // Logs |metric| to the Wallet errors histogram.
507 static void LogWalletErrorMetric(WalletErrorMetric metric);
509 // Logs the network request time of Wallet API calls.
510 static void LogWalletApiCallDuration(WalletApiCallMetric metric,
511 const base::TimeDelta& duration);
513 // Logs that the Wallet API call corresponding to |metric| was malformed.
514 static void LogWalletMalformedResponseMetric(WalletApiCallMetric metric);
516 // Logs |required_action| to the required actions histogram.
517 static void LogWalletRequiredActionMetric(
518 WalletRequiredActionMetric required_action);
520 // Logs HTTP response codes recieved by wallet client.
521 static void LogWalletResponseCode(int response_code);
523 // This should be called when a form that has been Autofilled is submitted.
524 // |duration| should be the time elapsed between form load and submission.
525 static void LogFormFillDurationFromLoadWithAutofill(
526 const base::TimeDelta& duration);
528 // This should be called when a fillable form that has not been Autofilled is
529 // submitted. |duration| should be the time elapsed between form load and
530 // submission.
531 static void LogFormFillDurationFromLoadWithoutAutofill(
532 const base::TimeDelta& duration);
534 // This should be called when a form that has been Autofilled is submitted.
535 // |duration| should be the time elapsed between the initial form interaction
536 // and submission.
537 static void LogFormFillDurationFromInteractionWithAutofill(
538 const base::TimeDelta& duration);
540 // This should be called when a fillable form that has not been Autofilled is
541 // submitted. |duration| should be the time elapsed between the initial form
542 // interaction and submission.
543 static void LogFormFillDurationFromInteractionWithoutAutofill(
544 const base::TimeDelta& duration);
546 // This should be called each time a page containing forms is loaded.
547 static void LogIsAutofillEnabledAtPageLoad(bool enabled);
549 // This should be called each time a new profile is launched.
550 static void LogIsAutofillEnabledAtStartup(bool enabled);
552 // This should be called each time a new profile is launched.
553 static void LogStoredProfileCount(size_t num_profiles);
555 // Log the number of profiles available when an autofillable form is
556 // submitted.
557 static void LogNumberOfProfilesAtAutofillableFormSubmission(
558 size_t num_profiles);
560 // Log the number of Autofill suggestions presented to the user when filling a
561 // form.
562 static void LogAddressSuggestionsCount(size_t num_suggestions);
564 // Log the index of the selected suggestion in the Autofill popup.
565 static void LogSuggestionAcceptedIndex(int index);
567 // Log password form query: current and if one-to-two fields password forms
568 // were allowed.
569 static void LogPasswordFormQueryVolume(PasswordFormQueryVolumeMetric metric);
571 // Log how many autofilled fields in a given form were edited before
572 // submission.
573 static void LogNumberOfEditedAutofilledFieldsAtSubmission(
574 size_t num_edited_autofilled_fields);
576 // This should be called each time a server response is parsed for a form.
577 static void LogServerResponseHasDataForForm(bool has_data);
579 // Utility to autofill form events in the relevant histograms depending on
580 // the presence of server and/or local data.
581 class FormEventLogger {
582 public:
583 FormEventLogger(bool is_for_credit_card);
585 inline void set_is_server_data_available(bool is_server_data_available) {
586 is_server_data_available_ = is_server_data_available;
589 inline void set_is_local_data_available(bool is_local_data_available) {
590 is_local_data_available_ = is_local_data_available;
593 void OnDidInteractWithAutofillableForm();
595 void OnDidShowSuggestions();
597 void OnDidSelectMaskedServerCardSuggestion();
599 // In case of masked cards, caller must make sure this gets called before
600 // the card is upgraded to a full card.
601 void OnDidFillSuggestion(const CreditCard& credit_card);
603 void OnDidFillSuggestion(const AutofillProfile& profile);
605 void OnWillSubmitForm();
607 void OnFormSubmitted();
609 private:
610 void Log(FormEvent event) const;
612 bool is_for_credit_card_;
613 bool is_server_data_available_;
614 bool is_local_data_available_;
615 bool has_logged_interacted_;
616 bool has_logged_suggestions_shown_;
617 bool has_logged_masked_server_card_suggestion_selected_;
618 bool has_logged_suggestion_filled_;
619 bool has_logged_will_submit_;
620 bool has_logged_submitted_;
621 bool logged_suggestion_filled_was_server_data_;
622 bool logged_suggestion_filled_was_masked_server_card_;
625 private:
626 DISALLOW_IMPLICIT_CONSTRUCTORS(AutofillMetrics);
629 } // namespace autofill
631 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_METRICS_H_