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 <memory> 10 #include <set> 11 #include <string> 12 #include <utility> 13 #include <vector> 14 15 #include "base/macros.h" 16 #include "base/time/time.h" 17 #include "components/autofill/core/browser/autofill_client.h" 18 #include "components/autofill/core/browser/data_model/autofill_profile.h" 19 #include "components/autofill/core/browser/data_model/credit_card.h" 20 #include "components/autofill/core/browser/field_types.h" 21 #include "components/autofill/core/browser/form_types.h" 22 #include "components/autofill/core/browser/metrics/form_events.h" 23 #include "components/autofill/core/browser/sync_utils.h" 24 #include "components/autofill/core/browser/ui/popup_types.h" 25 #include "components/autofill/core/common/form_field_data.h" 26 #include "components/autofill/core/common/mojom/autofill_types.mojom.h" 27 #include "components/autofill/core/common/signatures.h" 28 #include "components/security_state/core/security_state.h" 29 #include "services/metrics/public/cpp/ukm_recorder.h" 30 31 namespace autofill { 32 33 class AutofillField; 34 class CreditCard; 35 struct AutofillOfferData; 36 37 // A given maximum is enforced to minimize the number of buckets generated. 38 extern const int kMaxBucketsCount; 39 40 class AutofillMetrics { 41 public: 42 enum AutofillProfileAction { 43 EXISTING_PROFILE_USED, 44 EXISTING_PROFILE_UPDATED, 45 NEW_PROFILE_CREATED, 46 AUTOFILL_PROFILE_ACTION_ENUM_SIZE, 47 }; 48 49 enum AutofillFormSubmittedState { 50 NON_FILLABLE_FORM_OR_NEW_DATA, 51 FILLABLE_FORM_AUTOFILLED_ALL, 52 FILLABLE_FORM_AUTOFILLED_SOME, 53 FILLABLE_FORM_AUTOFILLED_NONE_DID_SHOW_SUGGESTIONS, 54 FILLABLE_FORM_AUTOFILLED_NONE_DID_NOT_SHOW_SUGGESTIONS, 55 AUTOFILL_FORM_SUBMITTED_STATE_ENUM_SIZE, 56 }; 57 58 enum CardUploadDecisionMetric { 59 // All the required conditions were satisfied using either the form fields 60 // or we prompted the user to fix one or more conditions in the card upload 61 // prompt. 62 UPLOAD_OFFERED = 1 << 0, 63 // CVC field was not found in the form. 64 CVC_FIELD_NOT_FOUND = 1 << 1, 65 // CVC field was found, but field did not have a value. 66 CVC_VALUE_NOT_FOUND = 1 << 2, 67 // CVC field had a value, but it was not valid for the card network. 68 INVALID_CVC_VALUE = 1 << 3, 69 // A field had a syntactically valid CVC value, but it was in a field that 70 // was not heuristically determined as |CREDIT_CARD_VERIFICATION_CODE|. 71 // Set only if |CVC_FIELD_NOT_FOUND| is not set. 72 FOUND_POSSIBLE_CVC_VALUE_IN_NON_CVC_FIELD = 1 << 4, 73 // No address profile was available. 74 // We don't know whether we would have been able to get upload details. 75 UPLOAD_NOT_OFFERED_NO_ADDRESS_PROFILE = 1 << 5, 76 // Found one or more address profiles but none were recently modified or 77 // recently used -i.e. not used in expected duration of a checkout flow. 78 // We don't know whether we would have been able to get upload details. 79 UPLOAD_NOT_OFFERED_NO_RECENTLY_USED_ADDRESS = 1 << 6, 80 // One or more recently used addresses were available but no zip code was 81 // found on any of the address(es). We don't know whether we would have 82 // been able to get upload details. 83 UPLOAD_NOT_OFFERED_NO_ZIP_CODE = 1 << 7, 84 // Multiple recently used addresses were available but the addresses had 85 // conflicting zip codes.We don't know whether we would have been able to 86 // get upload details. 87 UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS = 1 << 8, 88 // One or more recently used addresses were available but no name was found 89 // on either the card or the address(es). We don't know whether the 90 // address(es) were otherwise valid nor whether we would have been able to 91 // get upload details. 92 UPLOAD_NOT_OFFERED_NO_NAME = 1 << 9, 93 // One or more recently used addresses were available but the names on the 94 // card and/or the addresses didn't match. We don't know whether the 95 // address(es) were otherwise valid nor whether we would have been able to 96 // get upload details. 97 UPLOAD_NOT_OFFERED_CONFLICTING_NAMES = 1 << 10, 98 // One or more valid addresses, and a name were available but the request to 99 // Payments for upload details failed. 100 UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED = 1 << 11, 101 // A textfield for the user to enter/confirm cardholder name was surfaced 102 // in the offer-to-save dialog. 103 USER_REQUESTED_TO_PROVIDE_CARDHOLDER_NAME = 1 << 12, 104 // The Autofill StrikeDatabase decided not to allow offering to save for 105 // this card. On mobile, that means no save prompt is shown at all. 106 UPLOAD_NOT_OFFERED_MAX_STRIKES_ON_MOBILE = 1 << 13, 107 // A pair of dropdowns for the user to select expiration date was surfaced 108 // in the offer-to-save dialog. 109 USER_REQUESTED_TO_PROVIDE_EXPIRATION_DATE = 1 << 14, 110 // All the required conditions were satisfied even though the form is 111 // unfocused after the user entered information into it. 112 UPLOAD_OFFERED_FROM_NON_FOCUSABLE_FIELD = 1 << 15, 113 // The card does not satisfy any of the ranges of supported BIN ranges. 114 UPLOAD_NOT_OFFERED_UNSUPPORTED_BIN_RANGE = 1 << 16, 115 // All the required conditions were satisfied even though the form is 116 // dynamic changed. 117 UPLOAD_OFFERED_FROM_DYNAMIC_CHANGE_FORM = 1 << 17, 118 // The legal message was invalid. 119 UPLOAD_NOT_OFFERED_INVALID_LEGAL_MESSAGE = 1 << 18, 120 // Update |kNumCardUploadDecisionMetrics| when adding new enum here. 121 }; 122 123 enum DeveloperEngagementMetric { 124 // Parsed a form that is potentially autofillable and does not contain any 125 // web developer-specified field type hint. 126 FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS = 0, 127 // Parsed a form that is potentially autofillable and contains at least one 128 // web developer-specified field type hint, a la 129 // http://is.gd/whatwg_autocomplete 130 FILLABLE_FORM_PARSED_WITH_TYPE_HINTS, 131 // Parsed a form that is potentially autofillable and contains at least one 132 // UPI Virtual Payment Address hint (upi-vpa) 133 FORM_CONTAINS_UPI_VPA_HINT, 134 NUM_DEVELOPER_ENGAGEMENT_METRICS, 135 }; 136 137 enum InfoBarMetric { 138 INFOBAR_SHOWN = 0, // We showed an infobar, e.g. prompting to save credit 139 // card info. 140 INFOBAR_ACCEPTED, // The user explicitly accepted the infobar. 141 INFOBAR_DENIED, // The user explicitly denied the infobar. 142 INFOBAR_IGNORED, // The user completely ignored the infobar (logged on 143 // tab close). 144 INFOBAR_NOT_SHOWN_INVALID_LEGAL_MESSAGE, // We didn't show the infobar 145 // because the provided legal 146 // message was invalid. 147 NUM_INFO_BAR_METRICS, 148 }; 149 150 // Autocomplete Events. 151 // These events are not based on forms nor submissions, but depend on the 152 // the usage of the Autocomplete feature. 153 enum AutocompleteEvent { 154 // A dropdown with Autocomplete suggestions was shown. 155 AUTOCOMPLETE_SUGGESTIONS_SHOWN = 0, 156 157 // An Autocomplete suggestion was selected. 158 AUTOCOMPLETE_SUGGESTION_SELECTED, 159 160 NUM_AUTOCOMPLETE_EVENTS 161 }; 162 163 // Represents card submitted state. 164 enum SubmittedCardStateMetric { 165 // Submitted card has valid card number and expiration date. 166 HAS_CARD_NUMBER_AND_EXPIRATION_DATE, 167 // Submitted card has a valid card number but an invalid or missing 168 // expiration date. 169 HAS_CARD_NUMBER_ONLY, 170 // Submitted card has a valid expiration date but an invalid or missing card 171 // number. 172 HAS_EXPIRATION_DATE_ONLY, 173 NUM_SUBMITTED_CARD_STATE_METRICS, 174 }; 175 176 // Metric to measure if a submitted card's expiration date matches the same 177 // server card's expiration date (unmasked or not). Cards are considered to 178 // be the same if they have the same card number (if unmasked) or if they have 179 // the same last four digits (if masked). 180 enum SubmittedServerCardExpirationStatusMetric { 181 // The submitted card and the unmasked server card had the same expiration 182 // date. 183 FULL_SERVER_CARD_EXPIRATION_DATE_MATCHED, 184 // The submitted card and the unmasked server card had different expiration 185 // dates. 186 FULL_SERVER_CARD_EXPIRATION_DATE_DID_NOT_MATCH, 187 // The submitted card and the masked server card had the same expiration 188 // date. 189 MASKED_SERVER_CARD_EXPIRATION_DATE_MATCHED, 190 // The submitted card and the masked server card had different expiration 191 // dates. 192 MASKED_SERVER_CARD_EXPIRATION_DATE_DID_NOT_MATCH, 193 NUM_SUBMITTED_SERVER_CARD_EXPIRATION_STATUS_METRICS, 194 }; 195 196 // Metric to distinguish between local credit card saves and upload credit 197 // card saves. 198 enum class SaveTypeMetric { 199 LOCAL = 0, 200 SERVER = 1, 201 kMaxValue = SERVER, 202 }; 203 204 // Metric to measure if a card for which upload was offered is already stored 205 // as a local card on the device or if it has not yet been seen. 206 enum UploadOfferedCardOriginMetric { 207 // Credit card upload was offered for a local card already on the device. 208 OFFERING_UPLOAD_OF_LOCAL_CARD, 209 // Credit card upload was offered for a newly-seen credit card. 210 OFFERING_UPLOAD_OF_NEW_CARD, 211 NUM_UPLOAD_OFFERED_CARD_ORIGIN_METRICS, 212 }; 213 214 // Metric to measure if a card for which upload was accepted is already stored 215 // as a local card on the device or if it has not yet been seen. 216 enum UploadAcceptedCardOriginMetric { 217 // The user accepted upload of a local card already on the device. 218 USER_ACCEPTED_UPLOAD_OF_LOCAL_CARD, 219 // The user accepted upload of a newly-seen credit card. 220 USER_ACCEPTED_UPLOAD_OF_NEW_CARD, 221 NUM_UPLOAD_ACCEPTED_CARD_ORIGIN_METRICS, 222 }; 223 224 // Represents requesting expiration date reason. 225 enum class SaveCardRequestExpirationDateReasonMetric { 226 // Submitted card has empty month. 227 kMonthMissingOnly, 228 // Submitted card has empty year. 229 kYearMissingOnly, 230 // Submitted card has both empty month and year. 231 kMonthAndYearMissing, 232 // Submitted card has expired expiration date. 233 kExpirationDatePresentButExpired, 234 kMaxValue = kExpirationDatePresentButExpired, 235 }; 236 237 // Metrics to track event when the save card prompt is offered. 238 enum SaveCardPromptOfferMetric { 239 // The prompt is actually shown. 240 SAVE_CARD_PROMPT_SHOWN, 241 // The prompt is not shown because the prompt has been declined by the user 242 // too many times. 243 SAVE_CARD_PROMPT_NOT_SHOWN_MAX_STRIKES_REACHED, 244 NUM_SAVE_CARD_PROMPT_OFFER_METRICS, 245 }; 246 247 enum SaveCardPromptResultMetric { 248 // The user explicitly accepted the prompt by clicking the ok button. 249 SAVE_CARD_PROMPT_ACCEPTED, 250 // The user explicitly cancelled the prompt by clicking the cancel button. 251 SAVE_CARD_PROMPT_CANCELLED, 252 // The user explicitly closed the prompt with the close button or ESC. 253 SAVE_CARD_PROMPT_CLOSED, 254 // The user did not interact with the prompt. 255 SAVE_CARD_PROMPT_NOT_INTERACTED, 256 // The prompt lost focus and was deactivated. 257 SAVE_CARD_PROMPT_LOST_FOCUS, 258 // The reason why the prompt is closed is not clear. Possible reason is the 259 // logging function is invoked before the closed reason is correctly set. 260 SAVE_CARD_PROMPT_RESULT_UNKNOWN, 261 NUM_SAVE_CARD_PROMPT_RESULT_METRICS, 262 }; 263 264 // Metrics to measure user interaction with the save credit card prompt. 265 // 266 // SAVE_CARD_PROMPT_DISMISS_FOCUS is not stored explicitly, but can be 267 // inferred from the other metrics: 268 // SAVE_CARD_PROMPT_DISMISS_FOCUS = SHOW_REQUESTED - END_* - DISMISS_* 269 enum SaveCardPromptMetric { 270 // Prompt was requested to be shown due to: 271 // CC info being submitted (first show), or 272 // location bar icon being clicked while bubble is hidden (reshows). 273 SAVE_CARD_PROMPT_SHOW_REQUESTED, 274 // The prompt was shown successfully. 275 SAVE_CARD_PROMPT_SHOWN_DEPRECATED, 276 // The prompt was not shown because the legal message was invalid. 277 SAVE_CARD_PROMPT_END_INVALID_LEGAL_MESSAGE, 278 // The user explicitly accepted the prompt. 279 SAVE_CARD_PROMPT_END_ACCEPTED, 280 // The user explicitly denied the prompt. 281 SAVE_CARD_PROMPT_END_DENIED, 282 // The prompt and icon were removed because of navigation away from the 283 // page that caused the prompt to be shown. The navigation occurred while 284 // the prompt was showing. 285 SAVE_CARD_PROMPT_END_NAVIGATION_SHOWING, 286 // The prompt and icon were removed because of navigation away from the 287 // page that caused the prompt to be shown. The navigation occurred while 288 // the prompt was hidden. 289 SAVE_CARD_PROMPT_END_NAVIGATION_HIDDEN, 290 // The prompt was dismissed because the user clicked the "Learn more" link. 291 // Deprecated. 292 DEPRECATED_SAVE_CARD_PROMPT_DISMISS_CLICK_LEARN_MORE, 293 // The prompt was dismissed because the user clicked a legal message link. 294 SAVE_CARD_PROMPT_DISMISS_CLICK_LEGAL_MESSAGE, 295 296 // The following _CVC_FIX_FLOW_ metrics are independent of the ones above, 297 // and were relevant when the CVC fix flow was active M62-M64. During that 298 // time, for instance, accepting the CVC fix flow would trigger both 299 // SAVE_CARD_PROMPT_CVC_FIX_FLOW_END_ACCEPTED as well as 300 // SAVE_CARD_PROMPT_END_ACCEPTED. They were split apart in order to track 301 // acceptance/abandonment rates of the multi-stage dialog user experience. 302 // (SAVE_CARD_PROMPT_CVC_FIX_FLOW_END_DENIED was an impossible state because 303 // the CVC fix flow uses a close button instead of a cancel button.) 304 305 // The prompt moved to a second stage that requested CVC from the user. 306 SAVE_CARD_PROMPT_CVC_FIX_FLOW_SHOWN, 307 // The user explicitly entered CVC and accepted the prompt. 308 SAVE_CARD_PROMPT_CVC_FIX_FLOW_END_ACCEPTED, 309 // The prompt and icon were removed because of navigation away from the page 310 // that caused the prompt to be shown. The navigation occurred while the 311 // prompt was showing, at the CVC request stage. 312 SAVE_CARD_PROMPT_CVC_FIX_FLOW_END_NAVIGATION_SHOWING, 313 // The prompt and icon were removed because of navigation away from the page 314 // that caused the prompt to be shown. The navigation occurred while the 315 // prompt was hidden, at the CVC request stage. 316 SAVE_CARD_PROMPT_CVC_FIX_FLOW_END_NAVIGATION_HIDDEN, 317 // The prompt was dismissed because the user clicked a legal message link. 318 SAVE_CARD_PROMPT_CVC_FIX_FLOW_DISMISS_CLICK_LEGAL_MESSAGE, 319 320 // The save card bubble was not shown due to the card having too many 321 // offer-to-save strikes, but the omnibox icon was still displayed. 322 SAVE_CARD_ICON_SHOWN_WITHOUT_PROMPT, 323 324 NUM_SAVE_CARD_PROMPT_METRICS, 325 }; 326 327 enum CreditCardUploadFeedbackMetric { 328 // The loading indicator animation which indicates uploading is in progress 329 // is successfully shown. 330 CREDIT_CARD_UPLOAD_FEEDBACK_LOADING_ANIMATION_SHOWN, 331 // The credit card icon with the saving failure badge is shown. 332 CREDIT_CARD_UPLOAD_FEEDBACK_FAILURE_ICON_SHOWN, 333 // The failure icon is clicked and the save card failure bubble is shown. 334 CREDIT_CARD_UPLOAD_FEEDBACK_FAILURE_BUBBLE_SHOWN, 335 NUM_CREDIT_CARD_UPLOAD_FEEDBACK_METRICS, 336 }; 337 338 // Metrics to measure user interaction with the Manage Cards view 339 // shown when user clicks on the save card icon after accepting 340 // to save a card. 341 enum ManageCardsPromptMetric { 342 // The manage cards promo was shown. 343 MANAGE_CARDS_SHOWN, 344 // The user clicked on [Done]. 345 MANAGE_CARDS_DONE, 346 // The user clicked on [Manage cards]. 347 MANAGE_CARDS_MANAGE_CARDS, 348 349 NUM_MANAGE_CARDS_PROMPT_METRICS 350 }; 351 352 // Metrics measuring how well we predict field types. These metric values are 353 // logged for each field in a submitted form for: 354 // - the heuristic prediction 355 // - the crowd-sourced (server) prediction 356 // - for the overall prediction 357 // 358 // For each of these prediction types, these metrics are also logged by 359 // actual and predicted field type. 360 enum FieldTypeQualityMetric { 361 // The field was found to be of type T, which matches the predicted type. 362 // i.e. actual_type == predicted type == T 363 // 364 // This is captured as a type-specific log entry for T. Is is also captured 365 // as an aggregate (non-type-specific) log entry. 366 TRUE_POSITIVE = 0, 367 368 // The field type is AMBIGUOUS and autofill made no prediction. 369 // i.e. actual_type == AMBIGUOUS,predicted type == UNKNOWN|NO_SERVER_DATA. 370 // 371 // This is captured as an aggregate (non-type-specific) log entry. It is 372 // NOT captured by type-specific logging. 373 TRUE_NEGATIVE_AMBIGUOUS, 374 375 // The field type is UNKNOWN and autofill made no prediction. 376 // i.e. actual_type == UNKNOWN and predicted type == UNKNOWN|NO_SERVER_DATA. 377 // 378 // This is captured as an aggregate (non-type-specific) log entry. It is 379 // NOT captured by type-specific logging. 380 TRUE_NEGATIVE_UNKNOWN, 381 382 // The field type is EMPTY and autofill predicted UNKNOWN 383 // i.e. actual_type == EMPTY and predicted type == UNKNOWN|NO_SERVER_DATA. 384 // 385 // This is captured as an aggregate (non-type-specific) log entry. It is 386 // NOT captured by type-specific logging. 387 TRUE_NEGATIVE_EMPTY, 388 389 // Autofill predicted type T, but the field actually had a different type. 390 // i.e., actual_type == T, predicted_type = U, T != U, 391 // UNKNOWN not in (T,U). 392 // 393 // This is captured as a type-specific log entry for U. It is NOT captured 394 // as an aggregate (non-type-specific) entry as this would double count with 395 // FALSE_NEGATIVE_MISMATCH logging captured for T. 396 FALSE_POSITIVE_MISMATCH, 397 398 // Autofill predicted type T, but the field actually matched multiple 399 // pieces of autofill data, none of which are T. 400 // i.e., predicted_type == T, actual_type = {U, V, ...), 401 // T not in {U, V, ...}. 402 // 403 // This is captured as a type-specific log entry for T. It is also captured 404 // as an aggregate (non-type-specific) log entry. 405 FALSE_POSITIVE_AMBIGUOUS, 406 407 // The field type is UNKNOWN, but autofill predicted it to be of type T. 408 // i.e., actual_type == UNKNOWN, predicted_type = T, T != UNKNOWN 409 // 410 // This is captured as a type-specific log entry for T. Is is also captured 411 // as an aggregate (non-type-specific) log entry. 412 FALSE_POSITIVE_UNKNOWN, 413 414 // The field type is EMPTY, but autofill predicted it to be of type T. 415 // i.e., actual_type == EMPTY, predicted_type = T, T != UNKNOWN 416 // 417 // This is captured as a type-specific log entry for T. Is is also captured 418 // as an aggregate (non-type-specific) log entry. 419 FALSE_POSITIVE_EMPTY, 420 421 // The field is of type T, but autofill did not make a type prediction. 422 // i.e., actual_type == T, predicted_type = UNKNOWN, T != UNKNOWN. 423 // 424 // This is captured as a type-specific log entry for T. Is is also captured 425 // as an aggregate (non-type-specific) log entry. 426 FALSE_NEGATIVE_UNKNOWN, 427 428 // The field is of type T, but autofill predicted it to be of type U. 429 // i.e., actual_type == T, predicted_type = U, T != U, 430 // UNKNOWN not in (T,U). 431 // 432 // This is captured as a type-specific log entry for T. Is is also captured 433 // as an aggregate (non-type-specific) log entry. 434 FALSE_NEGATIVE_MISMATCH, 435 436 // This must be last. 437 NUM_FIELD_TYPE_QUALITY_METRICS 438 }; 439 440 // Metrics measuring how well rationalization has performed given user's 441 // actual input. 442 enum RationalizationQualityMetric { 443 // Rationalization did make it better for the user. Most commonly, user 444 // have left it empty as rationalization predicted. 445 RATIONALIZATION_GOOD, 446 447 // Rationalization did not make it better or worse. Meaning user have 448 // input some value that would not be filled correctly automatically. 449 RATIONALIZATION_OK, 450 451 // Rationalization did make it worse, user has to fill 452 // in a value that would have been automatically filled 453 // if there was no rationalization at all. 454 RATIONALIZATION_BAD, 455 456 // This must be last. 457 NUM_RATIONALIZATION_QUALITY_METRICS 458 }; 459 460 enum QualityMetricPredictionSource { 461 PREDICTION_SOURCE_UNKNOWN, // Not used. The prediction source is unknown. 462 PREDICTION_SOURCE_HEURISTIC, // Local heuristic field-type prediction. 463 PREDICTION_SOURCE_SERVER, // Crowd-sourced server field type prediction. 464 PREDICTION_SOURCE_OVERALL, // Overall field-type prediction seen by user. 465 NUM_QUALITY_METRIC_SOURCES 466 }; 467 468 enum QualityMetricType { 469 TYPE_SUBMISSION = 0, // Logged based on user's submitted data. 470 TYPE_NO_SUBMISSION, // Logged based on user's entered data. 471 TYPE_AUTOCOMPLETE_BASED, // Logged based on the value of autocomplete attr. 472 NUM_QUALITY_METRIC_TYPES, 473 }; 474 475 // Each of these is logged at most once per query to the server, which in turn 476 // occurs at most once per page load. 477 enum ServerQueryMetric { 478 QUERY_SENT = 0, // Sent a query to the server. 479 QUERY_RESPONSE_RECEIVED, // Received a response. 480 QUERY_RESPONSE_PARSED, // Successfully parsed the server response. 481 482 // The response was parseable, but provided no improvements relative to our 483 // heuristics. 484 QUERY_RESPONSE_MATCHED_LOCAL_HEURISTICS, 485 486 // Our heuristics detected at least one auto-fillable field, and the server 487 // response overrode the type of at least one field. 488 QUERY_RESPONSE_OVERRODE_LOCAL_HEURISTICS, 489 490 // Our heuristics did not detect any auto-fillable fields, but the server 491 // response did detect at least one. 492 QUERY_RESPONSE_WITH_NO_LOCAL_HEURISTICS, 493 NUM_SERVER_QUERY_METRICS, 494 }; 495 496 // Logs usage of "Scan card" control item. 497 enum ScanCreditCardPromptMetric { 498 // "Scan card" was presented to the user. 499 SCAN_CARD_ITEM_SHOWN, 500 // "Scan card" was selected by the user. 501 SCAN_CARD_ITEM_SELECTED, 502 // The user selected something in the dropdown besides "scan card". 503 SCAN_CARD_OTHER_ITEM_SELECTED, 504 NUM_SCAN_CREDIT_CARD_PROMPT_METRICS, 505 }; 506 507 // Metrics to record the decision on whether to offer local card migration. 508 enum class LocalCardMigrationDecisionMetric { 509 // All the required conditions are satisfied and main prompt is shown. 510 OFFERED = 0, 511 // Migration not offered because user uses new card. 512 NOT_OFFERED_USE_NEW_CARD = 1, 513 // Migration not offered because failed migration prerequisites. 514 NOT_OFFERED_FAILED_PREREQUISITES = 2, 515 // The Autofill StrikeDatabase decided not to allow offering migration 516 // because max strike count was reached. 517 NOT_OFFERED_REACHED_MAX_STRIKE_COUNT = 3, 518 // Migration not offered because no migratable cards. 519 NOT_OFFERED_NO_MIGRATABLE_CARDS = 4, 520 // Met the migration requirements but the request to Payments for upload 521 // details failed. 522 NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED = 5, 523 // Abandoned the migration because no supported local cards were left after 524 // filtering out unsupported cards. 525 NOT_OFFERED_NO_SUPPORTED_CARDS = 6, 526 // User used a local card and they only have a single migratable local card 527 // on file, we will offer Upstream instead. 528 NOT_OFFERED_SINGLE_LOCAL_CARD = 7, 529 // User used an unsupported local card, we will abort the migration. 530 NOT_OFFERED_USE_UNSUPPORTED_LOCAL_CARD = 8, 531 // Legal message was invalid, we will abort the migration. 532 NOT_OFFERED_INVALID_LEGAL_MESSAGE = 9, 533 kMaxValue = NOT_OFFERED_INVALID_LEGAL_MESSAGE, 534 }; 535 536 // Metrics to track events when local credit card migration is offered. 537 enum LocalCardMigrationBubbleOfferMetric { 538 // The bubble is requested due to a credit card being used or 539 // local card migration icon in the omnibox being clicked. 540 LOCAL_CARD_MIGRATION_BUBBLE_REQUESTED = 0, 541 // The bubble is actually shown to the user. 542 LOCAL_CARD_MIGRATION_BUBBLE_SHOWN = 1, 543 NUM_LOCAL_CARD_MIGRATION_BUBBLE_OFFER_METRICS, 544 }; 545 546 // Metrics to track user interactions with the bubble. 547 // TODO(crbug.com/1070799): Remove this enum once the old logging is cleaned 548 // up. 549 enum LocalCardMigrationBubbleUserInteractionMetric { 550 // The user explicitly accepts the offer. 551 LOCAL_CARD_MIGRATION_BUBBLE_CLOSED_ACCEPTED = 0, 552 // The user explicitly denies the offer (clicks the cancel button). 553 LOCAL_CARD_MIGRATION_BUBBLE_CLOSED_DENIED = 1, 554 // The bubble is closed due to user navigating away from the page 555 // while the bubble was showing. 556 LOCAL_CARD_MIGRATION_BUBBLE_CLOSED_NAVIGATED_WHILE_SHOWING = 2, 557 // The bubble is closed due to user navigating away from the page 558 // while the bubble was hidden. 559 LOCAL_CARD_MIGRATION_BUBBLE_CLOSED_NAVIGATED_WHILE_HIDDEN = 3, 560 NUM_LOCAL_CARD_MIGRATION_BUBBLE_USER_INTERACTION_METRICS, 561 }; 562 563 // Metrics to track user action result of the bubble when the bubble is 564 // closed. 565 enum LocalCardMigrationBubbleResultMetric { 566 // The user explicitly accepted the offer. 567 LOCAL_CARD_MIGRATION_BUBBLE_ACCEPTED = 0, 568 // The user explicitly closed the bubble with the close button or ESC. 569 LOCAL_CARD_MIGRATION_BUBBLE_CLOSED = 1, 570 // The user did not interact with the bubble. 571 LOCAL_CARD_MIGRATION_BUBBLE_NOT_INTERACTED = 2, 572 // The bubble lost its focus and was deactivated. 573 LOCAL_CARD_MIGRATION_BUBBLE_LOST_FOCUS = 3, 574 // The reason why the prompt is closed is not clear. Possible reason is the 575 // logging function is invoked before the closed reason is correctly set. 576 LOCAL_CARD_MIGRATION_BUBBLE_RESULT_UNKNOWN = 4, 577 NUM_LOCAL_CARD_MIGRATION_BUBBLE_RESULT_METRICS, 578 }; 579 580 // Metrics to track events when local card migration dialog is offered. 581 enum LocalCardMigrationDialogOfferMetric { 582 // The dialog is shown to the user. 583 LOCAL_CARD_MIGRATION_DIALOG_SHOWN = 0, 584 // The dialog is not shown due to legal message being invalid. 585 LOCAL_CARD_MIGRATION_DIALOG_NOT_SHOWN_INVALID_LEGAL_MESSAGE = 1, 586 // The dialog is shown when migration feedback is available. 587 LOCAL_CARD_MIGRATION_DIALOG_FEEDBACK_SHOWN = 2, 588 // The dialog is shown when migration fails due to server error. 589 LOCAL_CARD_MIGRATION_DIALOG_FEEDBACK_SERVER_ERROR_SHOWN = 3, 590 NUM_LOCAL_CARD_MIGRATION_DIALOG_OFFER_METRICS, 591 }; 592 593 // Metrics to track user interactions with the dialog. 594 enum LocalCardMigrationDialogUserInteractionMetric { 595 // The user explicitly accepts the offer by clicking the save button. 596 LOCAL_CARD_MIGRATION_DIALOG_CLOSED_SAVE_BUTTON_CLICKED = 0, 597 // The user explicitly denies the offer by clicking the cancel button. 598 LOCAL_CARD_MIGRATION_DIALOG_CLOSED_CANCEL_BUTTON_CLICKED = 1, 599 // The user clicks the legal message. 600 LOCAL_CARD_MIGRATION_DIALOG_LEGAL_MESSAGE_CLICKED = 2, 601 // The user clicks the view card button after successfully migrated cards. 602 LOCAL_CARD_MIGRATION_DIALOG_CLOSED_VIEW_CARDS_BUTTON_CLICKED = 3, 603 // The user clicks the done button to close dialog after migration. 604 LOCAL_CARD_MIGRATION_DIALOG_CLOSED_DONE_BUTTON_CLICKED = 4, 605 // The user clicks the trash icon to delete invalid card. 606 LOCAL_CARD_MIGRATION_DIALOG_DELETE_CARD_ICON_CLICKED = 5, 607 NUM_LOCAL_CARD_MIGRATION_DIALOG_USER_INTERACTION_METRICS, 608 }; 609 610 // These metrics are logged for each local card migration origin. These are 611 // used to derive the conversion rate for each triggering source. 612 enum LocalCardMigrationPromptMetric { 613 // The intermediate bubble is shown to the user. 614 INTERMEDIATE_BUBBLE_SHOWN = 0, 615 // The intermediate bubble is accepted by the user. 616 INTERMEDIATE_BUBBLE_ACCEPTED = 1, 617 // The main dialog is shown to the user. 618 MAIN_DIALOG_SHOWN = 2, 619 // The main dialog is accepted by the user. 620 MAIN_DIALOG_ACCEPTED = 3, 621 NUM_LOCAL_CARD_MIGRATION_PROMPT_METRICS, 622 }; 623 624 // Local card migration origin denotes from where the migration is triggered. 625 enum LocalCardMigrationOrigin { 626 // Trigger when user submitted a form using local card. 627 UseOfLocalCard, 628 // Trigger when user submitted a form using server card. 629 UseOfServerCard, 630 // Trigger from settings page. 631 SettingsPage, 632 }; 633 634 // Each of these metrics is logged only for potentially autofillable forms, 635 // i.e. forms with at least three fields, etc. 636 // These are used to derive certain "user happiness" metrics. For example, we 637 // can compute the ratio (USER_DID_EDIT_AUTOFILLED_FIELD / USER_DID_AUTOFILL) 638 // to see how often users have to correct autofilled data. 639 enum UserHappinessMetric { 640 // Loaded a page containing forms. 641 FORMS_LOADED, 642 // Submitted a fillable form -- i.e. one with at least three field values 643 // that match the user's stored Autofill data -- and all matching fields 644 // were autofilled. 645 SUBMITTED_FILLABLE_FORM_AUTOFILLED_ALL, 646 // Submitted a fillable form and some (but not all) matching fields were 647 // autofilled. 648 SUBMITTED_FILLABLE_FORM_AUTOFILLED_SOME, 649 // Submitted a fillable form and no fields were autofilled. 650 SUBMITTED_FILLABLE_FORM_AUTOFILLED_NONE, 651 // Submitted a non-fillable form. This also counts entering new data into 652 // a form with identified fields. Because we didn't have the data the user 653 // wanted, from the user's perspective, the form was not autofillable. 654 SUBMITTED_NON_FILLABLE_FORM, 655 656 // User manually filled one of the form fields. 657 USER_DID_TYPE, 658 // We showed a popup containing Autofill suggestions. 659 SUGGESTIONS_SHOWN, 660 // Same as above, but only logged once per page load. 661 SUGGESTIONS_SHOWN_ONCE, 662 // User autofilled at least part of the form. 663 USER_DID_AUTOFILL, 664 // Same as above, but only logged once per page load. 665 USER_DID_AUTOFILL_ONCE, 666 // User edited a previously autofilled field. 667 USER_DID_EDIT_AUTOFILLED_FIELD, 668 // Same as above, but only logged once per page load. 669 USER_DID_EDIT_AUTOFILLED_FIELD_ONCE, 670 671 // User entered form data that appears to be a UPI Virtual Payment Address. 672 USER_DID_ENTER_UPI_VPA, 673 674 // A field was populated by autofill. 675 FIELD_WAS_AUTOFILLED, 676 677 NUM_USER_HAPPINESS_METRICS, 678 }; 679 680 // Cardholder name fix flow prompt metrics. 681 enum CardholderNameFixFlowPromptEvent { 682 // The prompt was shown. 683 CARDHOLDER_NAME_FIX_FLOW_PROMPT_SHOWN = 0, 684 // The prompt was accepted by user. 685 CARDHOLDER_NAME_FIX_FLOW_PROMPT_ACCEPTED, 686 // The prompt was dismissed by user. 687 CARDHOLDER_NAME_FIX_FLOW_PROMPT_DISMISSED, 688 // The prompt was closed without user interaction. 689 CARDHOLDER_NAME_FIX_FLOW_PROMPT_CLOSED_WITHOUT_INTERACTION, 690 NUM_CARDHOLDER_NAME_FIXFLOW_PROMPT_EVENTS, 691 }; 692 693 // Expiration date fix flow prompt metrics. 694 enum class ExpirationDateFixFlowPromptEvent { 695 // The prompt was accepted by user. 696 EXPIRATION_DATE_FIX_FLOW_PROMPT_ACCEPTED = 0, 697 // The prompt was dismissed by user. 698 EXPIRATION_DATE_FIX_FLOW_PROMPT_DISMISSED, 699 // The prompt was closed without user interaction. 700 EXPIRATION_DATE_FIX_FLOW_PROMPT_CLOSED_WITHOUT_INTERACTION, 701 kMaxValue = EXPIRATION_DATE_FIX_FLOW_PROMPT_CLOSED_WITHOUT_INTERACTION, 702 }; 703 704 // Events related to the Unmask Credit Card Prompt. 705 enum UnmaskPromptEvent { 706 // The prompt was shown. 707 UNMASK_PROMPT_SHOWN = 0, 708 // The prompt was closed without attempting to unmask the card. 709 UNMASK_PROMPT_CLOSED_NO_ATTEMPTS, 710 // The prompt was closed without unmasking the card, but with at least 711 // one attempt. The last failure was retriable. 712 UNMASK_PROMPT_CLOSED_FAILED_TO_UNMASK_RETRIABLE_FAILURE, 713 // The prompt was closed without unmasking the card, but with at least 714 // one attempt. The last failure was non retriable. 715 UNMASK_PROMPT_CLOSED_FAILED_TO_UNMASK_NON_RETRIABLE_FAILURE, 716 // Successfully unmasked the card in the first attempt. 717 UNMASK_PROMPT_UNMASKED_CARD_FIRST_ATTEMPT, 718 // Successfully unmasked the card after retriable failures. 719 UNMASK_PROMPT_UNMASKED_CARD_AFTER_FAILED_ATTEMPTS, 720 // Saved the card locally (masked card was upgraded to a full card). 721 UNMASK_PROMPT_SAVED_CARD_LOCALLY, 722 // User chose to opt in (checked the checkbox when it was empty). 723 // Only logged if there was an attempt to unmask. 724 UNMASK_PROMPT_LOCAL_SAVE_DID_OPT_IN, 725 // User did not opt in when they had the chance (left the checkbox 726 // unchecked). Only logged if there was an attempt to unmask. 727 UNMASK_PROMPT_LOCAL_SAVE_DID_NOT_OPT_IN, 728 // User chose to opt out (unchecked the checkbox when it was check). 729 // Only logged if there was an attempt to unmask. 730 UNMASK_PROMPT_LOCAL_SAVE_DID_OPT_OUT, 731 // User did not opt out when they had a chance (left the checkbox checked). 732 // Only logged if there was an attempt to unmask. 733 UNMASK_PROMPT_LOCAL_SAVE_DID_NOT_OPT_OUT, 734 // The prompt was closed while chrome was unmasking the card (user pressed 735 // verify and we were waiting for the server response). 736 UNMASK_PROMPT_CLOSED_ABANDON_UNMASKING, 737 NUM_UNMASK_PROMPT_EVENTS, 738 }; 739 740 // Events related to user-perceived latency due to GetDetailsForGetRealPan 741 // call. 742 enum class PreflightCallEvent { 743 // Returned before card chosen. 744 kPreflightCallReturnedBeforeCardChosen = 0, 745 // Did not return before card was chosen. When opted-in, this means 746 // the UI had to wait for the call to return. When opted-out, this means we 747 // did not offer to opt-in. 748 kCardChosenBeforePreflightCallReturned = 1, 749 // Preflight call was irrelevant; skipped waiting. 750 kDidNotChooseMaskedCard = 2, 751 kMaxValue = kDidNotChooseMaskedCard, 752 }; 753 754 // Metric for tracking which authentication method was used for a user with 755 // FIDO authentication enabled. 756 enum class CardUnmaskTypeDecisionMetric { 757 // Only WebAuthn prompt was shown. 758 kFidoOnly = 0, 759 // CVC authentication was required in addition to WebAuthn. 760 kCvcThenFido = 1, 761 kMaxValue = kCvcThenFido, 762 }; 763 764 // Possible scenarios where a WebAuthn prompt may show. 765 enum class WebauthnFlowEvent { 766 // WebAuthn is immediately prompted for unmasking. 767 kImmediateAuthentication = 0, 768 // WebAuthn is prompted after a CVC check. 769 kAuthenticationAfterCvc = 1, 770 // WebAuthn is prompted after being offered to opt-in from a checkout flow. 771 kCheckoutOptIn = 2, 772 // WebAuthn is prompted after being offered to opt-in from the settings 773 // page. 774 kSettingsPageOptIn = 3, 775 kMaxValue = kSettingsPageOptIn, 776 }; 777 778 // The result of a WebAuthn user-verification prompt. 779 enum class WebauthnResultMetric { 780 // User-verification succeeded. 781 kSuccess = 0, 782 // Other checks failed (e.g. invalid domain, algorithm unsupported, etc.) 783 kOtherError = 1, 784 // User either failed verification or cancelled. 785 kNotAllowedError = 2, 786 kMaxValue = kNotAllowedError, 787 }; 788 789 // The user decision for the WebAuthn opt-in promo. 790 enum class WebauthnOptInPromoUserDecisionMetric { 791 // User accepted promo. 792 kAccepted = 0, 793 // User immediately declined promo. 794 kDeclinedImmediately = 1, 795 // Once user accepts the dialog, a round-trip call to Payments is sent, 796 // which is required for user authentication. The user has the option to 797 // cancel the dialog before the round-trip call is returned. 798 kDeclinedAfterAccepting = 2, 799 kMaxValue = kDeclinedAfterAccepting, 800 }; 801 802 // The parameters with which opt change was called. 803 enum class WebauthnOptInParameters { 804 // Call made to fetch a challenge. 805 kFetchingChallenge = 0, 806 // Call made with signature of creation challenge. 807 kWithCreationChallenge = 1, 808 // Call made with signature of request challenge. 809 kWithRequestChallenge = 2, 810 kMaxValue = kWithRequestChallenge, 811 }; 812 813 // Possible results of Payments RPCs. 814 enum PaymentsRpcResult { 815 // Request succeeded. 816 PAYMENTS_RESULT_SUCCESS = 0, 817 // Request failed; try again. 818 PAYMENTS_RESULT_TRY_AGAIN_FAILURE, 819 // Request failed; don't try again. 820 PAYMENTS_RESULT_PERMANENT_FAILURE, 821 // Unable to connect to Payments servers. 822 PAYMENTS_RESULT_NETWORK_ERROR, 823 NUM_PAYMENTS_RESULTS, 824 }; 825 826 // For measuring the network request time of various Wallet API calls. See 827 // WalletClient::RequestType. 828 enum WalletApiCallMetric { 829 UNKNOWN_API_CALL, // Catch all. Should never be used. 830 ACCEPT_LEGAL_DOCUMENTS, 831 AUTHENTICATE_INSTRUMENT, 832 GET_FULL_WALLET, 833 GET_WALLET_ITEMS, 834 SAVE_TO_WALLET, 835 NUM_WALLET_API_CALLS 836 }; 837 838 // For measuring the frequency of errors while communicating with the Wallet 839 // server. 840 enum WalletErrorMetric { 841 // Baseline metric: Issued a request to the Wallet server. 842 WALLET_ERROR_BASELINE_ISSUED_REQUEST = 0, 843 // A fatal error occured while communicating with the Wallet server. This 844 // value has been deprecated. 845 WALLET_FATAL_ERROR_DEPRECATED, 846 // Received a malformed response from the Wallet server. 847 WALLET_MALFORMED_RESPONSE, 848 // A network error occured while communicating with the Wallet server. 849 WALLET_NETWORK_ERROR, 850 // The request was malformed. 851 WALLET_BAD_REQUEST, 852 // Risk deny, unsupported country, or account closed. 853 WALLET_BUYER_ACCOUNT_ERROR, 854 // Unknown server side error. 855 WALLET_INTERNAL_ERROR, 856 // API call had missing or invalid parameters. 857 WALLET_INVALID_PARAMS, 858 // Online Wallet is down. 859 WALLET_SERVICE_UNAVAILABLE, 860 // User needs make a cheaper transaction or not use Online Wallet. 861 WALLET_SPENDING_LIMIT_EXCEEDED, 862 // The server API version of the request is no longer supported. 863 WALLET_UNSUPPORTED_API_VERSION, 864 // Catch all error type. 865 WALLET_UNKNOWN_ERROR, 866 // The merchant has been blocked for Online Wallet due to some manner of 867 // compliance violation. 868 WALLET_UNSUPPORTED_MERCHANT, 869 // Buyer Legal Address has a country which is unsupported by Wallet. 870 WALLET_BUYER_LEGAL_ADDRESS_NOT_SUPPORTED, 871 // Wallet's Know Your Customer(KYC) action is pending/failed for this user. 872 WALLET_UNVERIFIED_KNOW_YOUR_CUSTOMER_STATUS, 873 // Chrome version is unsupported or provided API key not allowed. 874 WALLET_UNSUPPORTED_USER_AGENT_OR_API_KEY, 875 NUM_WALLET_ERROR_METRICS 876 }; 877 878 // For measuring the frequency of "required actions" returned by the Wallet 879 // server. This is similar to the autofill::wallet::RequiredAction enum; 880 // but unlike that enum, the values in this one must remain constant over 881 // time, so that the metrics can be consistently interpreted on the 882 // server-side. 883 enum WalletRequiredActionMetric { 884 // Baseline metric: Issued a request to the Wallet server. 885 WALLET_REQUIRED_ACTION_BASELINE_ISSUED_REQUEST = 0, 886 // Values from the autofill::wallet::RequiredAction enum: 887 UNKNOWN_REQUIRED_ACTION, // Catch all type. 888 GAIA_AUTH, 889 PASSIVE_GAIA_AUTH, 890 SETUP_WALLET, 891 ACCEPT_TOS, 892 UPDATE_EXPIRATION_DATE, 893 UPGRADE_MIN_ADDRESS, 894 CHOOSE_ANOTHER_INSTRUMENT_OR_ADDRESS, 895 VERIFY_CVV, 896 INVALID_FORM_FIELD, 897 REQUIRE_PHONE_NUMBER, 898 NUM_WALLET_REQUIRED_ACTIONS 899 }; 900 901 // For measuring how wallet addresses are converted to local profiles. 902 enum WalletAddressConversionType : int { 903 // The converted wallet address was merged into an existing local profile. 904 CONVERTED_ADDRESS_MERGED, 905 // The converted wallet address was added as a new local profile. 906 CONVERTED_ADDRESS_ADDED, 907 NUM_CONVERTED_ADDRESS_CONVERSION_TYPES 908 }; 909 910 // To record whether the upload event was sent. 911 enum class UploadEventStatus { kNotSent, kSent, kMaxValue = kSent }; 912 913 // Log all the scenarios that contribute to the decision of whether card 914 // upload is enabled or not. 915 enum class CardUploadEnabledMetric { 916 SYNC_SERVICE_NULL = 0, 917 SYNC_SERVICE_PERSISTENT_AUTH_ERROR = 1, 918 SYNC_SERVICE_MISSING_AUTOFILL_WALLET_DATA_ACTIVE_TYPE = 2, 919 SYNC_SERVICE_MISSING_AUTOFILL_PROFILE_ACTIVE_TYPE = 3, 920 // Deprecated: ACCOUNT_WALLET_STORAGE_UPLOAD_DISABLED = 4, 921 USING_SECONDARY_SYNC_PASSPHRASE = 5, 922 LOCAL_SYNC_ENABLED = 6, 923 PAYMENTS_INTEGRATION_DISABLED = 7, 924 EMAIL_EMPTY = 8, 925 EMAIL_DOMAIN_NOT_SUPPORTED = 9, 926 AUTOFILL_UPSTREAM_DISABLED = 10, 927 CARD_UPLOAD_ENABLED = 11, 928 kMaxValue = CARD_UPLOAD_ENABLED, 929 }; 930 931 // Enumerates the status of the different requirements to successfully import 932 // an address profile from a form submission. 933 enum class AddressProfileImportRequirementMetric { 934 // The form must contain either no or only a single unique email address. 935 EMAIL_ADDRESS_UNIQUE_REQUIREMENT_FULFILLED = 0, 936 EMAIL_ADDRESS_UNIQUE_REQUIREMENT_VIOLATED = 1, 937 // The form is not allowed to contain invalid field types. 938 NO_INVALID_FIELD_TYPES_REQUIREMENT_FULFILLED = 2, 939 NO_INVALID_FIELD_TYPES_REQUIREMENT_VIOLATED = 3, 940 // If required by |CountryData|, the form must contain a city entry. 941 CITY_REQUIREMENT_FULFILLED = 4, 942 CITY_REQUIREMENT_VIOLATED = 5, 943 // If required by |CountryData|, the form must contain a state entry. 944 STATE_REQUIREMENT_FULFILLED = 6, 945 STATE_REQUIREMENT_VIOLATED = 7, 946 // If required by |CountryData|, the form must contain a ZIP entry. 947 ZIP_REQUIREMENT_FULFILLED = 8, 948 ZIP_REQUIREMENT_VIOLATED = 9, 949 // If present, the email address must be valid. 950 EMAIL_VALID_REQUIREMENT_FULFILLED = 10, 951 EMAIL_VALID_REQUIREMENT_VIOLATED = 11, 952 // If present, the country must be valid. 953 COUNTRY_VALID_REQUIREMENT_FULFILLED = 12, 954 COUNTRY_VALID_REQUIREMENT_VIOLATED = 13, 955 // If present, the state must be valid (if verifiable). 956 STATE_VALID_REQUIREMENT_FULFILLED = 14, 957 STATE_VALID_REQUIREMENT_VIOLATED = 15, 958 // If present, the ZIP must be valid (if verifiable). 959 ZIP_VALID_REQUIREMENT_FULFILLED = 16, 960 ZIP_VALID_REQUIREMENT_VIOLATED = 17, 961 // If present, the phone number must be valid (if verifiable). 962 PHONE_VALID_REQUIREMENT_FULFILLED = 18, 963 PHONE_VALID_REQUIREMENT_VIOLATED = 19, 964 // Indicates the overall status of the import requirements check. 965 OVERALL_REQUIREMENT_FULFILLED = 20, 966 OVERALL_REQUIREMENT_VIOLATED = 21, 967 // If required by |CountryData|, the form must contain a line1 entry. 968 LINE1_REQUIREMENT_FULFILLED = 22, 969 LINE1_REQUIREMENT_VIOLATED = 23, 970 // If required by |CountryData|, the form must contain a either a zip or a 971 // state entry. 972 ZIP_OR_STATE_REQUIREMENT_FULFILLED = 24, 973 ZIP_OR_STATE_REQUIREMENT_VIOLATED = 25, 974 // Must be set to the last entry. 975 kMaxValue = ZIP_OR_STATE_REQUIREMENT_VIOLATED, 976 }; 977 978 // Represents the status of the field type requirements that are specific to 979 // countries. 980 enum class AddressProfileImportCountrySpecificFieldRequirementsMetric { 981 ALL_GOOD = 0, 982 ZIP_REQUIREMENT_VIOLATED = 1, 983 STATE_REQUIREMENT_VIOLATED = 2, 984 ZIP_STATE_REQUIREMENT_VIOLATED = 3, 985 CITY_REQUIREMENT_VIOLATED = 4, 986 ZIP_CITY_REQUIREMENT_VIOLATED = 5, 987 STATE_CITY_REQUIREMENT_VIOLATED = 6, 988 ZIP_STATE_CITY_REQUIREMENT_VIOLATED = 7, 989 LINE1_REQUIREMENT_VIOLATED = 8, 990 LINE1_ZIP_REQUIREMENT_VIOLATED = 9, 991 LINE1_STATE_REQUIREMENT_VIOLATED = 10, 992 LINE1_ZIP_STATE_REQUIREMENT_VIOLATED = 11, 993 LINE1_CITY_REQUIREMENT_VIOLATED = 12, 994 LINE1_ZIP_CITY_REQUIREMENT_VIOLATED = 13, 995 LINE1_STATE_CITY_REQUIREMENT_VIOLATED = 14, 996 LINE1_ZIP_STATE_CITY_REQUIREMENT_VIOLATED = 15, 997 kMaxValue = LINE1_ZIP_STATE_CITY_REQUIREMENT_VIOLATED, 998 }; 999 1000 // To record if the value in an autofilled field was edited by the user. 1001 enum class AutofilledFieldUserEditingStatusMetric { 1002 AUTOFILLED_FIELD_WAS_EDITED = 0, 1003 AUTOFILLED_FIELD_WAS_NOT_EDITED = 1, 1004 kMaxValue = AUTOFILLED_FIELD_WAS_NOT_EDITED, 1005 }; 1006 1007 // Represent the overall status of a profile import. 1008 enum class AddressProfileImportStatusMetric { 1009 NO_IMPORT = 0, 1010 REGULAR_IMPORT = 1, 1011 SECTION_UNION_IMPORT = 2, 1012 kMaxValue = SECTION_UNION_IMPORT, 1013 }; 1014 1015 // Utility to log URL keyed form interaction events. 1016 class FormInteractionsUkmLogger { 1017 public: 1018 FormInteractionsUkmLogger(ukm::UkmRecorder* ukm_recorder, 1019 const ukm::SourceId source_id); 1020 has_pinned_timestamp()1021 bool has_pinned_timestamp() const { return !pinned_timestamp_.is_null(); } set_pinned_timestamp(base::TimeTicks t)1022 void set_pinned_timestamp(base::TimeTicks t) { pinned_timestamp_ = t; } 1023 1024 // Initializes this logger with a source_id. Unless forms is parsed no 1025 // autofill UKM is recorded. However due to autofill_manager resets, 1026 // it is possible to have the UKM being recorded after the forms were 1027 // parsed. So, rely on autofill_client to pass correct source_id 1028 // However during some cases there is a race for setting AutofillClient 1029 // and generation of new source_id (by UKM) as they are both observing tab 1030 // navigation. Ideally we need to refactor ownership of this logger 1031 // so as not to rely on OnFormsParsed to record the metrics correctly. 1032 // TODO(nikunjb): Refactor the logger to be owned by AutofillClient. 1033 void OnFormsParsed(const ukm::SourceId source_id); 1034 void LogInteractedWithForm(bool is_for_credit_card, 1035 size_t local_record_type_count, 1036 size_t server_record_type_count, 1037 FormSignature form_signature); 1038 void LogSuggestionsShown(const FormStructure& form, 1039 const AutofillField& field, 1040 const base::TimeTicks& form_parsed_timestamp, 1041 bool off_the_record); 1042 void LogDidFillSuggestion(int record_type, 1043 bool is_for_credit_card, 1044 const FormStructure& form, 1045 const AutofillField& field); 1046 void LogTextFieldDidChange(const FormStructure& form, 1047 const AutofillField& field); 1048 void LogEditedAutofilledFieldAtSubmission(const FormStructure& form, 1049 const AutofillField& field); 1050 void LogFieldFillStatus(const FormStructure& form, 1051 const AutofillField& field, 1052 QualityMetricType metric_type); 1053 void LogFieldType(const base::TimeTicks& form_parsed_timestamp, 1054 FormSignature form_signature, 1055 FieldSignature field_signature, 1056 QualityMetricPredictionSource prediction_source, 1057 QualityMetricType metric_type, 1058 ServerFieldType predicted_type, 1059 ServerFieldType actual_type); 1060 void LogFormSubmitted(bool is_for_credit_card, 1061 bool has_upi_vpa_field, 1062 const std::set<FormType>& form_types, 1063 AutofillFormSubmittedState state, 1064 const base::TimeTicks& form_parsed_timestamp, 1065 FormSignature form_signature); 1066 void LogFormEvent(FormEvent form_event, 1067 const std::set<FormType>& form_types, 1068 const base::TimeTicks& form_parsed_timestamp); 1069 1070 // Log whether the autofill decided to skip or to fill each 1071 // hidden/representational field. 1072 void LogHiddenRepresentationalFieldSkipDecision(const FormStructure& form, 1073 const AutofillField& field, 1074 bool is_skipped); 1075 1076 // Log the fields for which the autofill decided to rationalize the server 1077 // type predictions due to repetition of the type. 1078 void LogRepeatedServerTypePredictionRationalized( 1079 const FormSignature form_signature, 1080 const AutofillField& field, 1081 ServerFieldType old_type); 1082 1083 private: 1084 bool CanLog() const; 1085 int64_t MillisecondsSinceFormParsed( 1086 const base::TimeTicks& form_parsed_timestamp) const; 1087 1088 ukm::UkmRecorder* ukm_recorder_; // Weak reference. 1089 ukm::SourceId source_id_; 1090 base::TimeTicks pinned_timestamp_; 1091 }; 1092 1093 // Utility class to pin the timestamp used by the FormInteractionsUkmLogger 1094 // while an instance of this class is in scope. Pinned timestamps cannot be 1095 // nested. 1096 class UkmTimestampPin { 1097 public: 1098 explicit UkmTimestampPin(FormInteractionsUkmLogger* logger); 1099 ~UkmTimestampPin(); 1100 1101 private: 1102 FormInteractionsUkmLogger* const logger_; 1103 DISALLOW_IMPLICIT_CONSTRUCTORS(UkmTimestampPin); 1104 }; 1105 1106 // When the autofill-use-improved-label-disambiguation experiment is enabled 1107 // and suggestions are available, records if a LabelFormatter successfully 1108 // created the suggestions. 1109 static void LogProfileSuggestionsMadeWithFormatter(bool made_with_formatter); 1110 1111 static void LogSubmittedCardStateMetric(SubmittedCardStateMetric metric); 1112 1113 // If a credit card that matches a server card (unmasked or not) was submitted 1114 // on a form, logs whether the submitted card's expiration date matched the 1115 // server card's known expiration date. 1116 static void LogSubmittedServerCardExpirationStatusMetric( 1117 SubmittedServerCardExpirationStatusMetric metric); 1118 1119 // When credit card save is not offered (either at all on mobile or by simply 1120 // not showing the bubble on desktop), logs the occurrence. 1121 static void LogCreditCardSaveNotOfferedDueToMaxStrikesMetric( 1122 SaveTypeMetric metric); 1123 1124 // When local card migration is not offered due to max strike limit reached, 1125 // logs the occurrence. 1126 static void LogLocalCardMigrationNotOfferedDueToMaxStrikesMetric( 1127 SaveTypeMetric metric); 1128 1129 // When credit card upload is offered, logs whether the card being offered is 1130 // already a local card on the device or not. 1131 static void LogUploadOfferedCardOriginMetric( 1132 UploadOfferedCardOriginMetric metric); 1133 1134 // When credit card upload is accepted, logs whether the card being accepted 1135 // is already a local card on the device or not. 1136 static void LogUploadAcceptedCardOriginMetric( 1137 UploadAcceptedCardOriginMetric metric); 1138 1139 // When a cardholder name fix flow is shown during credit card upload, logs 1140 // whether the cardholder name was prefilled or not. 1141 static void LogSaveCardCardholderNamePrefilled(bool prefilled); 1142 1143 // When a cardholder name fix flow is shown during credit card upload and the 1144 // user accepts upload, logs whether the final cardholder name was changed 1145 // from its prefilled value or not. 1146 static void LogSaveCardCardholderNameWasEdited(bool edited); 1147 1148 // |upload_decision_metrics| is a bitmask of |CardUploadDecisionMetric|. 1149 static void LogCardUploadDecisionMetrics(int upload_decision_metrics); 1150 static void LogCreditCardInfoBarMetric( 1151 InfoBarMetric metric, 1152 bool is_uploading, 1153 AutofillClient::SaveCreditCardOptions options, 1154 int previous_save_credit_card_prompt_user_decision); 1155 static void LogCreditCardFillingInfoBarMetric(InfoBarMetric metric); 1156 static void LogSaveCardRequestExpirationDateReasonMetric( 1157 SaveCardRequestExpirationDateReasonMetric metric); 1158 static void LogSaveCardPromptOfferMetric( 1159 SaveCardPromptOfferMetric metric, 1160 bool is_uploading, 1161 bool is_reshow, 1162 AutofillClient::SaveCreditCardOptions options, 1163 int previous_save_credit_card_prompt_user_decision, 1164 security_state::SecurityLevel security_level, 1165 AutofillSyncSigninState sync_state); 1166 static void LogSaveCardPromptResultMetric( 1167 SaveCardPromptResultMetric metric, 1168 bool is_uploading, 1169 bool is_reshow, 1170 AutofillClient::SaveCreditCardOptions options, 1171 int previous_save_credit_card_prompt_user_decision, 1172 security_state::SecurityLevel security_level, 1173 AutofillSyncSigninState sync_state); 1174 static void LogSaveCardPromptMetric( 1175 SaveCardPromptMetric metric, 1176 bool is_uploading, 1177 bool is_reshow, 1178 AutofillClient::SaveCreditCardOptions options, 1179 int previous_save_credit_card_prompt_user_decision, 1180 security_state::SecurityLevel security_level, 1181 AutofillSyncSigninState sync_state); 1182 static void LogSaveCardPromptMetricBySecurityLevel( 1183 SaveCardPromptMetric metric, 1184 bool is_uploading, 1185 security_state::SecurityLevel security_level); 1186 static void LogCreditCardUploadLegalMessageLinkClicked(); 1187 static void LogCreditCardUploadFeedbackMetric( 1188 CreditCardUploadFeedbackMetric metric); 1189 static void LogManageCardsPromptMetric(ManageCardsPromptMetric metric, 1190 bool is_uploading); 1191 static void LogScanCreditCardPromptMetric(ScanCreditCardPromptMetric metric); 1192 static void LogLocalCardMigrationDecisionMetric( 1193 LocalCardMigrationDecisionMetric metric); 1194 static void LogLocalCardMigrationBubbleOfferMetric( 1195 LocalCardMigrationBubbleOfferMetric metric, 1196 bool is_reshow); 1197 // TODO(crbug.com/1070799): Delete the user interaction metrics when the 1198 // experiment is fully launched. 1199 static void LogLocalCardMigrationBubbleUserInteractionMetric( 1200 LocalCardMigrationBubbleUserInteractionMetric metric, 1201 bool is_reshow); 1202 static void LogLocalCardMigrationBubbleResultMetric( 1203 LocalCardMigrationBubbleResultMetric metric, 1204 bool is_reshow); 1205 static void LogLocalCardMigrationDialogOfferMetric( 1206 LocalCardMigrationDialogOfferMetric metric); 1207 static void LogLocalCardMigrationDialogUserInteractionMetric( 1208 const base::TimeDelta& duration, 1209 LocalCardMigrationDialogUserInteractionMetric metric); 1210 static void LogLocalCardMigrationDialogUserSelectionPercentageMetric( 1211 int selected, 1212 int total); 1213 static void LogLocalCardMigrationPromptMetric( 1214 LocalCardMigrationOrigin local_card_migration_origin, 1215 LocalCardMigrationPromptMetric metric); 1216 1217 // Should be called when credit card scan is finished. |duration| should be 1218 // the time elapsed between launching the credit card scanner and getting back 1219 // the result. |completed| should be true if a credit card was scanned, false 1220 // if the scan was cancelled. 1221 static void LogScanCreditCardCompleted(const base::TimeDelta& duration, 1222 bool completed); 1223 1224 static void LogSaveCardWithFirstAndLastNameOffered(bool is_local); 1225 static void LogSaveCardWithFirstAndLastNameComplete(bool is_local); 1226 1227 static void LogDeveloperEngagementMetric(DeveloperEngagementMetric metric); 1228 1229 static void LogHeuristicPredictionQualityMetrics( 1230 FormInteractionsUkmLogger* form_interactions_ukm_logger, 1231 const FormStructure& form, 1232 const AutofillField& field, 1233 QualityMetricType metric_type); 1234 static void LogServerPredictionQualityMetrics( 1235 FormInteractionsUkmLogger* form_interactions_ukm_logger, 1236 const FormStructure& form, 1237 const AutofillField& field, 1238 QualityMetricType metric_type); 1239 static void LogOverallPredictionQualityMetrics( 1240 FormInteractionsUkmLogger* form_interactions_ukm_logger, 1241 const FormStructure& form, 1242 const AutofillField& field, 1243 QualityMetricType metric_type); 1244 1245 static void LogServerQueryMetric(ServerQueryMetric metric); 1246 1247 static void LogUserHappinessMetric( 1248 UserHappinessMetric metric, 1249 FieldTypeGroup field_type_group, 1250 security_state::SecurityLevel security_level, 1251 uint32_t profile_form_bitmask); 1252 1253 static void LogUserHappinessMetric( 1254 UserHappinessMetric metric, 1255 const std::set<FormType>& form_types, 1256 security_state::SecurityLevel security_level, 1257 uint32_t profile_form_bitmask); 1258 1259 static void LogUserHappinessBySecurityLevel( 1260 UserHappinessMetric metric, 1261 FormType form_type, 1262 security_state::SecurityLevel security_level); 1263 1264 static void LogUserHappinessByProfileFormType(UserHappinessMetric metric, 1265 uint32_t profile_form_bitmask); 1266 1267 // Logs the card fetch latency after a WebAuthn prompt. 1268 static void LogCardUnmaskDurationAfterWebauthn( 1269 const base::TimeDelta& duration, 1270 AutofillClient::PaymentsRpcResult result); 1271 1272 // Logs the count of calls to PaymentsClient::GetUnmaskDetails() (aka 1273 // GetDetailsForGetRealPan). 1274 static void LogCardUnmaskPreflightCalled(); 1275 1276 // Logs the duration of the PaymentsClient::GetUnmaskDetails() call (aka 1277 // GetDetailsForGetRealPan). 1278 static void LogCardUnmaskPreflightDuration(const base::TimeDelta& duration); 1279 1280 // Logs the count of calls to PaymentsClient::OptChange() (aka 1281 // UpdateAutofillUserPreference). 1282 static void LogWebauthnOptChangeCalled(bool request_to_opt_in, 1283 bool is_checkout_flow, 1284 WebauthnOptInParameters metric); 1285 1286 // Logs the number of times the opt-in promo for enabling FIDO authentication 1287 // for card unmasking has been shown. 1288 static void LogWebauthnOptInPromoShown(bool is_checkout_flow); 1289 1290 // Logs the user response to the opt-in promo for enabling FIDO authentication 1291 // for card unmasking. 1292 static void LogWebauthnOptInPromoUserDecision( 1293 bool is_checkout_flow, 1294 WebauthnOptInPromoUserDecisionMetric metric); 1295 1296 // Logs which unmask type was used for a user with FIDO authentication 1297 // enabled. 1298 static void LogCardUnmaskTypeDecision(CardUnmaskTypeDecisionMetric metric); 1299 1300 // Logs the existence of any user-perceived latency between selecting a Google 1301 // Payments server card and seeing a card unmask prompt. 1302 static void LogUserPerceivedLatencyOnCardSelection(PreflightCallEvent event, 1303 bool fido_auth_enabled); 1304 1305 // Logs the duration of any user-perceived latency between selecting a Google 1306 // Payments server card and seeing a card unmask prompt (CVC or FIDO). 1307 static void LogUserPerceivedLatencyOnCardSelectionDuration( 1308 const base::TimeDelta duration); 1309 1310 // Logs whether or not the verifying pending dialog timed out between 1311 // selecting a Google Payments server card and seeing a card unmask prompt. 1312 static void LogUserPerceivedLatencyOnCardSelectionTimedOut(bool did_time_out); 1313 1314 // Logs the duration of WebAuthn's 1315 // IsUserVerifiablePlatformAuthenticatorAvailable() call. It is supposedly an 1316 // extremely quick IPC. 1317 static void LogUserVerifiabilityCheckDuration( 1318 const base::TimeDelta& duration); 1319 1320 // Logs the result of a WebAuthn prompt. 1321 static void LogWebauthnResult(WebauthnFlowEvent event, 1322 WebauthnResultMetric metric); 1323 1324 // Logs |event| to the unmask prompt events histogram. 1325 static void LogUnmaskPromptEvent(UnmaskPromptEvent event, 1326 bool has_valid_nickname); 1327 1328 // Logs |event| to cardholder name fix flow prompt events histogram. 1329 static void LogCardholderNameFixFlowPromptEvent( 1330 CardholderNameFixFlowPromptEvent event); 1331 1332 // Logs |event| to expiration date fix flow prompt events histogram. 1333 static void LogExpirationDateFixFlowPromptEvent( 1334 ExpirationDateFixFlowPromptEvent event); 1335 1336 // Logs the count of expiration date fix flow prompts shown histogram. 1337 static void LogExpirationDateFixFlowPromptShown(); 1338 1339 // Logs the time elapsed between the unmask prompt being shown and it 1340 // being closed. 1341 static void LogUnmaskPromptEventDuration(const base::TimeDelta& duration, 1342 UnmaskPromptEvent close_event, 1343 bool has_valid_nickname); 1344 1345 // Logs the time elapsed between the user clicking Verify and 1346 // hitting cancel when abandoning a pending unmasking operation 1347 // (aka GetRealPan). 1348 static void LogTimeBeforeAbandonUnmasking(const base::TimeDelta& duration, 1349 bool has_valid_nickname); 1350 1351 // Logs |result| to the get real pan result histogram. 1352 static void LogRealPanResult(AutofillClient::PaymentsRpcResult result); 1353 1354 // Logs |result| to duration of the GetRealPan RPC. 1355 static void LogRealPanDuration(const base::TimeDelta& duration, 1356 AutofillClient::PaymentsRpcResult result); 1357 1358 // Logs |result| to the get real pan result histogram. 1359 static void LogUnmaskingDuration(const base::TimeDelta& duration, 1360 AutofillClient::PaymentsRpcResult result); 1361 1362 // This should be called when a form that has been Autofilled is submitted. 1363 // |duration| should be the time elapsed between form load and submission. 1364 static void LogFormFillDurationFromLoadWithAutofill( 1365 const base::TimeDelta& duration); 1366 1367 // This should be called when a fillable form that has not been Autofilled is 1368 // submitted. |duration| should be the time elapsed between form load and 1369 // submission. 1370 static void LogFormFillDurationFromLoadWithoutAutofill( 1371 const base::TimeDelta& duration); 1372 1373 // This should be called when a form is submitted. |duration| should be the 1374 // time elapsed between the initial form interaction and submission. This 1375 // metric is sliced by |form_type| and |used_autofill|. 1376 static void LogFormFillDurationFromInteraction( 1377 const std::set<FormType>& form_types, 1378 bool used_autofill, 1379 const base::TimeDelta& duration); 1380 1381 static void LogFormFillDuration(const std::string& metric, 1382 const base::TimeDelta& duration); 1383 1384 // This should be called each time a page containing forms is loaded. 1385 static void LogIsAutofillEnabledAtPageLoad( 1386 bool enabled, 1387 AutofillSyncSigninState sync_state); 1388 1389 // This should be called each time a page containing forms is loaded. 1390 static void LogIsAutofillProfileEnabledAtPageLoad( 1391 bool enabled, 1392 AutofillSyncSigninState sync_state); 1393 1394 // This should be called each time a page containing forms is loaded. 1395 static void LogIsAutofillCreditCardEnabledAtPageLoad( 1396 bool enabled, 1397 AutofillSyncSigninState sync_state); 1398 1399 // This should be called each time a new chrome profile is launched. 1400 static void LogIsAutofillEnabledAtStartup(bool enabled); 1401 1402 // This should be called each time a new chrome profile is launched. 1403 static void LogIsAutofillProfileEnabledAtStartup(bool enabled); 1404 1405 // This should be called each time a new chrome profile is launched. 1406 static void LogIsAutofillCreditCardEnabledAtStartup(bool enabled); 1407 1408 // Records the number of stored address profiles. This is be called each time 1409 // a new chrome profile is launched. 1410 static void LogStoredProfileCount(size_t num_profiles); 1411 1412 // Records the number of stored address profiles which have not been used in 1413 // a long time. This is be called each time a new chrome profile is launched. 1414 static void LogStoredProfileDisusedCount(size_t num_profiles); 1415 1416 // Records the number of days since an address profile was last used. This is 1417 // called once per address profile each time a new chrome profile is launched. 1418 static void LogStoredProfileDaysSinceLastUse(size_t days); 1419 1420 // Logs various metrics about the local and server cards associated with a 1421 // profile. This should be called each time a new chrome profile is launched. 1422 static void LogStoredCreditCardMetrics( 1423 const std::vector<std::unique_ptr<CreditCard>>& local_cards, 1424 const std::vector<std::unique_ptr<CreditCard>>& server_cards, 1425 base::TimeDelta disused_data_threshold); 1426 1427 // Logs metrics about the offer data associated with a profile. This should be 1428 // called each time a chrome profile is launched. 1429 static void LogStoredOfferMetrics( 1430 const std::vector<std::unique_ptr<AutofillOfferData>>& offers); 1431 1432 // Logs whether the synced autofill offer data is valid. 1433 static void LogSyncedOfferDataBeingValid(bool invalid); 1434 1435 // Log the number of autofill credit card suggestions suppressed because they 1436 // have not been used for a long time and are expired. Note that these cards 1437 // are only suppressed when the user has not typed any data into the field 1438 // from which autofill is triggered. Credit cards matching something the user 1439 // has types are always offered, regardless of how recently they have been 1440 // used. 1441 static void LogNumberOfCreditCardsSuppressedForDisuse(size_t num_cards); 1442 1443 // Log the number of autofill credit card deleted during major version upgrade 1444 // because they have not been used for a long time and are expired. 1445 static void LogNumberOfCreditCardsDeletedForDisuse(size_t num_cards); 1446 1447 // Log the number of profiles available when an autofillable form is 1448 // submitted. 1449 static void LogNumberOfProfilesAtAutofillableFormSubmission( 1450 size_t num_profiles); 1451 1452 // Log the number of autofill address suggestions suppressed because they have 1453 // not been used for a long time. Note that these addresses are only 1454 // suppressed when the user has not typed any data into the field from which 1455 // autofill is triggered. Addresses matching something the user has types are 1456 // always offered, regardless of how recently they have been used. 1457 static void LogNumberOfAddressesSuppressedForDisuse(size_t num_profiles); 1458 1459 // Log the number of unverified autofill addresses deleted because they have 1460 // not been used for a long time, and are not used as billing addresses of 1461 // valid credit cards. Note the deletion only happens once per major version 1462 // upgrade. 1463 static void LogNumberOfAddressesDeletedForDisuse(size_t num_profiles); 1464 1465 // Log the number of Autofill address suggestions presented to the user when 1466 // filling a form. 1467 static void LogAddressSuggestionsCount(size_t num_suggestions); 1468 1469 // Log the index of the selected Autofill suggestion in the popup. 1470 static void LogAutofillSuggestionAcceptedIndex(int index, 1471 PopupType popup_type, 1472 bool off_the_record); 1473 1474 // Logs that the user cleared the form. 1475 static void LogAutofillFormCleared(); 1476 1477 // Log the number of days since an Autocomplete suggestion was last used. 1478 static void LogAutocompleteDaysSinceLastUse(size_t days); 1479 1480 // Log the index of the selected Autocomplete suggestion in the popup. 1481 static void LogAutocompleteSuggestionAcceptedIndex(int index); 1482 1483 // Log the fact that an autocomplete popup was shown. 1484 static void OnAutocompleteSuggestionsShown(); 1485 1486 // Log the number of autocomplete entries that were cleaned-up as a result 1487 // of the Autocomplete Retention Policy. 1488 static void LogNumberOfAutocompleteEntriesCleanedUp(int nb_entries); 1489 1490 // Log how many autofilled fields in a given form were edited before the 1491 // submission or when the user unfocused the form (depending on 1492 // |observed_submission|). 1493 static void LogNumberOfEditedAutofilledFields( 1494 size_t num_edited_autofilled_fields, 1495 bool observed_submission); 1496 1497 // This should be called each time a server response is parsed for a form. 1498 static void LogServerResponseHasDataForForm(bool has_data); 1499 1500 // This should be called at each form submission to indicate what profile 1501 // action happened. 1502 static void LogProfileActionOnFormSubmitted(AutofillProfileAction action); 1503 1504 // This should be called at each form submission to indicate the autofilled 1505 // state of the form. 1506 static void LogAutofillFormSubmittedState( 1507 AutofillFormSubmittedState state, 1508 bool is_for_credit_card, 1509 bool has_upi_vpa_field, 1510 const std::set<FormType>& form_types, 1511 const base::TimeTicks& form_parsed_timestamp, 1512 FormSignature form_signature, 1513 FormInteractionsUkmLogger* form_interactions_ukm_logger); 1514 1515 // This should be called when determining the heuristic types for a form's 1516 // fields. 1517 static void LogDetermineHeuristicTypesTiming(const base::TimeDelta& duration); 1518 1519 // This should be called when parsing each form. 1520 static void LogParseFormTiming(const base::TimeDelta& duration); 1521 1522 // Log how many profiles were considered for the deduplication process. 1523 static void LogNumberOfProfilesConsideredForDedupe(size_t num_considered); 1524 1525 // Log how many profiles were removed as part of the deduplication process. 1526 static void LogNumberOfProfilesRemovedDuringDedupe(size_t num_removed); 1527 1528 // Log whether the Autofill query on a credit card form is made in a secure 1529 // context. 1530 static void LogIsQueriedCreditCardFormSecure(bool is_secure); 1531 1532 // Log how the converted wallet address was added to the local autofill 1533 // profiles. 1534 static void LogWalletAddressConversionType(WalletAddressConversionType type); 1535 1536 // This should be called when the user selects the Form-Not-Secure warning 1537 // suggestion to show an explanation of the warning. 1538 static void LogShowedHttpNotSecureExplanation(); 1539 1540 // Logs if an autocomplete query was created for a field. 1541 static void LogAutocompleteQuery(bool created); 1542 1543 // Logs if there is any suggestions for an autocomplete query. 1544 static void LogAutocompleteSuggestions(bool has_suggestions); 1545 1546 // Returns the UMA metric used to track whether or not an upload was sent 1547 // after being triggered by |submission_source|. This is exposed for testing. 1548 static const char* SubmissionSourceToUploadEventMetric( 1549 mojom::SubmissionSource submission_source); 1550 1551 // Logs whether or not an upload |was_sent| after being triggered by a 1552 // |submission_source| event. 1553 static void LogUploadEvent(mojom::SubmissionSource submission_source, 1554 bool was_sent); 1555 1556 // Logs the card upload decisions ukm for the specified |url|. 1557 // |upload_decision_metrics| is a bitmask of |CardUploadDecisionMetric|. 1558 static void LogCardUploadDecisionsUkm(ukm::UkmRecorder* ukm_recorder, 1559 ukm::SourceId source_id, 1560 const GURL& url, 1561 int upload_decision_metrics); 1562 1563 // Logs the developer engagement ukm for the specified |url| and autofill 1564 // fields in the form structure. |developer_engagement_metrics| is a bitmask 1565 // of |AutofillMetrics::DeveloperEngagementMetric|. |is_for_credit_card| is 1566 // true if the form is a credit card form. |form_types| is set of 1567 // FormType recorded for the page. This will be stored as a bit vector 1568 // in UKM. 1569 static void LogDeveloperEngagementUkm(ukm::UkmRecorder* ukm_recorder, 1570 ukm::SourceId source_id, 1571 const GURL& url, 1572 bool is_for_credit_card, 1573 std::set<FormType> form_types, 1574 int developer_engagement_metrics, 1575 FormSignature form_signature); 1576 1577 // Log the number of hidden or presentational 'select' fields that were 1578 // autofilled to support synthetic fields. 1579 static void LogHiddenOrPresentationalSelectFieldsFilled(); 1580 1581 // Converts form type to bit vector to store in UKM. 1582 static int64_t FormTypesToBitVector(const std::set<FormType>& form_types); 1583 1584 // Records the fact that the server card link was clicked with information 1585 // about the current sync state. 1586 static void LogServerCardLinkClicked(AutofillSyncSigninState sync_state); 1587 1588 // Records whether the user had opted-in to seeing their server card when in 1589 // sync transport mode for Wallet. This should only be logged if the user had 1590 // server cards to be shown. 1591 static void LogWalletSyncTransportCardsOptIn(bool is_opted_in); 1592 1593 // Records the reason for why (or why not) card upload was enabled for the 1594 // user. 1595 static void LogCardUploadEnabledMetric(CardUploadEnabledMetric metric, 1596 AutofillSyncSigninState sync_state); 1597 1598 // Logs the status of an address import requirement defined by type. 1599 static void LogAddressFormImportRequirementMetric( 1600 AutofillMetrics::AddressProfileImportRequirementMetric metric); 1601 1602 // Logs the overall status of the country specific field requirements for 1603 // importing an address profile from a submitted form. 1604 static void LogAddressFormImportCountrySpecificFieldRequirementsMetric( 1605 bool is_zip_missing, 1606 bool is_state_missing, 1607 bool is_city_missing, 1608 bool is_line1_missing); 1609 1610 // Records if an autofilled field of a specific type was edited by the user. 1611 static void LogEditedAutofilledFieldAtSubmission( 1612 FormInteractionsUkmLogger* form_interactions_ukm_logger, 1613 const FormStructure& form, 1614 const AutofillField& field); 1615 1616 static void LogAddressFormImportStatustMetric( 1617 AddressProfileImportStatusMetric metric); 1618 1619 // Records if the page was translated upon form submission. 1620 static void LogFieldParsingPageTranslationStatusMetric(bool metric); 1621 1622 // Records the visible page language upon form submission. 1623 static void LogFieldParsingTranslatedFormLanguageMetric(base::StringPiece); 1624 1625 static const char* GetMetricsSyncStateSuffix( 1626 AutofillSyncSigninState sync_state); 1627 1628 // Records whether a document collected phone number, and/or used WebOTP, 1629 // and/or used OneTimeCode (OTC) during its lifecycle. 1630 static void LogWebOTPPhoneCollectionMetricStateUkm( 1631 ukm::UkmRecorder* ukm_recorder, 1632 ukm::SourceId source_id, 1633 uint32_t phone_collection_metric_state); 1634 1635 private: 1636 static void Log(AutocompleteEvent event); 1637 1638 static const int kNumCardUploadDecisionMetrics = 19; 1639 1640 DISALLOW_IMPLICIT_CONSTRUCTORS(AutofillMetrics); 1641 }; 1642 1643 #if defined(UNIT_TEST) 1644 int GetFieldTypeUserEditStatusMetric( 1645 ServerFieldType server_type, 1646 AutofillMetrics::AutofilledFieldUserEditingStatusMetric metric); 1647 #endif 1648 1649 } // namespace autofill 1650 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_METRICS_H_ 1651