| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_METRICS_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_METRICS_H_ |
| 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_METRICS_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_METRICS_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/strings/string_piece_forward.h" |
| 14 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 15 #include "components/autofill/core/browser/autofill_client.h" | 16 #include "components/autofill/core/browser/autofill_client.h" |
| 16 #include "components/autofill/core/browser/autofill_profile.h" | 17 #include "components/autofill/core/browser/autofill_profile.h" |
| 17 #include "components/autofill/core/browser/credit_card.h" | 18 #include "components/autofill/core/browser/credit_card.h" |
| 18 #include "components/autofill/core/browser/field_types.h" | 19 #include "components/autofill/core/browser/field_types.h" |
| 19 #include "components/autofill/core/common/autofill_pref_names.h" | 20 #include "components/autofill/core/common/autofill_pref_names.h" |
| 20 #include "components/autofill/core/common/form_field_data.h" | 21 #include "components/autofill/core/common/form_field_data.h" |
| 21 #include "components/ukm/public/ukm_recorder.h" | 22 #include "components/ukm/public/ukm_recorder.h" |
| 22 | 23 |
| 23 namespace internal { | 24 namespace internal { |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 // the prompt was hidden. | 313 // the prompt was hidden. |
| 313 SAVE_CARD_PROMPT_END_NAVIGATION_HIDDEN, | 314 SAVE_CARD_PROMPT_END_NAVIGATION_HIDDEN, |
| 314 // The prompt was dismissed because the user clicked the "Learn more" link. | 315 // The prompt was dismissed because the user clicked the "Learn more" link. |
| 315 SAVE_CARD_PROMPT_DISMISS_CLICK_LEARN_MORE, | 316 SAVE_CARD_PROMPT_DISMISS_CLICK_LEARN_MORE, |
| 316 // The prompt was dismissed because the user clicked a legal message link. | 317 // The prompt was dismissed because the user clicked a legal message link. |
| 317 SAVE_CARD_PROMPT_DISMISS_CLICK_LEGAL_MESSAGE, | 318 SAVE_CARD_PROMPT_DISMISS_CLICK_LEGAL_MESSAGE, |
| 318 | 319 |
| 319 NUM_SAVE_CARD_PROMPT_METRICS, | 320 NUM_SAVE_CARD_PROMPT_METRICS, |
| 320 }; | 321 }; |
| 321 | 322 |
| 322 // Metrics measuring how well we predict field types. Exactly three such | 323 // Metrics measuring how well we predict field types. These metric values are |
| 323 // metrics are logged for each fillable field in a submitted form: for | 324 // logged for each field in a submitted form for: |
| 324 // the heuristic prediction, for the crowd-sourced prediction, and for the | 325 // - the heuristic prediction |
| 325 // overall prediction. | 326 // - the crowd-sourced (server) prediction |
| 327 // - for the overall prediction |
| 328 // |
| 329 // For each of these prediction types, these metrics are also logged by |
| 330 // actual and predicted field type. |
| 326 enum FieldTypeQualityMetric { | 331 enum FieldTypeQualityMetric { |
| 327 // The field was found to be of type T, but autofill made no prediction. | |
| 328 TYPE_UNKNOWN = 0, | |
| 329 // The field was found to be of type T, which matches the predicted type. | 332 // The field was found to be of type T, which matches the predicted type. |
| 330 TYPE_MATCH, | 333 // i.e. actual_type == predicted type == T |
| 331 // The field was found to be of type T, autofill predicted some other type. | 334 // |
| 332 TYPE_MISMATCH, | 335 // This is captured as a type-specific log entry for T. Is is also captured |
| 333 // The field was left empty and autofil predicted that the field type would | 336 // as an aggregate (non-type-specific) log entry. |
| 334 // be UNKNOWN. | 337 TRUE_POSITIVE = 0, |
| 335 TYPE_MATCH_EMPTY, | 338 |
| 336 // The field was populated with data that did not match any part of the | 339 // The field type is AMBIGUOUS and autofill made no prediction. |
| 337 // user's profile (it's type could not be determined). Autofill predicted | 340 // i.e. actual_type == AMBIGUOUS,predicted type == UNKNOWN|NO_SERVER_DATA. |
| 338 // the field's type would be UNKNOWN. | 341 // |
| 339 TYPE_MATCH_UNKNOWN, | 342 // This is captured as an aggregate (non-type-specific) log entry. It is |
| 340 // The field was left empty, autofill predicted the user would populate it | 343 // NOT captured by type-specific logging. |
| 341 // with autofillable data. | 344 TRUE_NEGATIVE_AMBIGUOUS, |
| 342 TYPE_MISMATCH_EMPTY, | 345 |
| 343 // The field was populated with data that did not match any part of the | 346 // The field type is UNKNOWN and autofill made no prediction. |
| 344 // user's profile (it's type could not be determined). Autofill predicted | 347 // i.e. actual_type == UNKNOWN and predicted type == UNKNOWN|NO_SERVER_DATA. |
| 345 // the user would populate it with autofillable data. | 348 // |
| 346 TYPE_MISMATCH_UNKNOWN, | 349 // This is captured as an aggregate (non-type-specific) log entry. It is |
| 347 // This must be the last value. | 350 // NOT captured by type-specific logging. |
| 348 NUM_FIELD_TYPE_QUALITY_METRICS, | 351 TRUE_NEGATIVE_UNKNOWN, |
| 352 |
| 353 // The field type is EMPTY and autofill predicted UNKNOWN |
| 354 // i.e. actual_type == EMPTY and predicted type == UNKNOWN|NO_SERVER_DATA. |
| 355 // |
| 356 // This is captured as an aggregate (non-type-specific) log entry. It is |
| 357 // NOT captured by type-specific logging. |
| 358 TRUE_NEGATIVE_EMPTY, |
| 359 |
| 360 // Autofill predicted type T, but the field actually had a different type. |
| 361 // i.e., actual_type == T, predicted_type = U, T != U, |
| 362 // UNKNOWN not in (T,U). |
| 363 // |
| 364 // This is captured as a type-specific log entry for U. It is NOT captured |
| 365 // as an aggregate (non-type-specific) entry as this would double count with |
| 366 // FALSE_NEGATIVE_MISMATCH logging captured for T. |
| 367 FALSE_POSITIVE_MISMATCH, |
| 368 |
| 369 // Autofill predicted type T, but the field actually matched multiple |
| 370 // pieces of autofill data, none of which are T. |
| 371 // i.e., predicted_type == T, actual_type = {U, V, ...), |
| 372 // T not in {U, V, ...}. |
| 373 // |
| 374 // This is captured as a type-specific log entry for T. It is also captured |
| 375 // as an aggregate (non-type-specific) log entry. |
| 376 FALSE_POSITIVE_AMBIGUOUS, |
| 377 |
| 378 // The field type is UNKNOWN, but autofill predicted it to be of type T. |
| 379 // i.e., actual_type == UNKNOWN, predicted_type = T, T != UNKNOWN |
| 380 // |
| 381 // This is captured as a type-specific log entry for T. Is is also captured |
| 382 // as an aggregate (non-type-specific) log entry. |
| 383 FALSE_POSITIVE_UNKNOWN, |
| 384 |
| 385 // The field type is EMPTY, but autofill predicted it to be of type T. |
| 386 // i.e., actual_type == EMPTY, predicted_type = T, T != UNKNOWN |
| 387 // |
| 388 // This is captured as a type-specific log entry for T. Is is also captured |
| 389 // as an aggregate (non-type-specific) log entry. |
| 390 FALSE_POSITIVE_EMPTY, |
| 391 |
| 392 // The field is of type T, but autofill did not make a type prediction. |
| 393 // i.e., actual_type == T, predicted_type = UNKNOWN, T != UNKNOWN. |
| 394 // |
| 395 // This is captured as a type-specific log entry for T. Is is also captured |
| 396 // as an aggregate (non-type-specific) log entry. |
| 397 FALSE_NEGATIVE_UNKNOWN, |
| 398 |
| 399 // The field is of type T, but autofill predicted it to be of type U. |
| 400 // i.e., actual_type == T, predicted_type = U, T != U, |
| 401 // UNKNOWN not in (T,U). |
| 402 // |
| 403 // This is captured as a type-specific log entry for T. Is is also captured |
| 404 // as an aggregate (non-type-specific) log entry. |
| 405 FALSE_NEGATIVE_MISMATCH, |
| 406 |
| 407 // This must be last. |
| 408 NUM_FIELD_TYPE_QUALITY_METRICS |
| 349 }; | 409 }; |
| 350 | 410 |
| 351 enum QualityMetricType { | 411 enum QualityMetricType { |
| 352 TYPE_SUBMISSION = 0, // Logged based on user's submitted data. | 412 TYPE_SUBMISSION = 0, // Logged based on user's submitted data. |
| 353 TYPE_NO_SUBMISSION, // Logged based on user's entered data. | 413 TYPE_NO_SUBMISSION, // Logged based on user's entered data. |
| 354 TYPE_AUTOCOMPLETE_BASED, // Logged based on the value of autocomplete attr. | 414 TYPE_AUTOCOMPLETE_BASED, // Logged based on the value of autocomplete attr. |
| 355 NUM_QUALITY_METRIC_TYPES, | 415 NUM_QUALITY_METRIC_TYPES, |
| 356 }; | 416 }; |
| 357 | 417 |
| 358 // Each of these is logged at most once per query to the server, which in turn | 418 // Each of these is logged at most once per query to the server, which in turn |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 | 728 |
| 669 // Should be called when credit card scan is finished. |duration| should be | 729 // Should be called when credit card scan is finished. |duration| should be |
| 670 // the time elapsed between launching the credit card scanner and getting back | 730 // the time elapsed between launching the credit card scanner and getting back |
| 671 // the result. |completed| should be true if a credit card was scanned, false | 731 // the result. |completed| should be true if a credit card was scanned, false |
| 672 // if the scan was cancelled. | 732 // if the scan was cancelled. |
| 673 static void LogScanCreditCardCompleted(const base::TimeDelta& duration, | 733 static void LogScanCreditCardCompleted(const base::TimeDelta& duration, |
| 674 bool completed); | 734 bool completed); |
| 675 | 735 |
| 676 static void LogDeveloperEngagementMetric(DeveloperEngagementMetric metric); | 736 static void LogDeveloperEngagementMetric(DeveloperEngagementMetric metric); |
| 677 | 737 |
| 678 static void LogHeuristicTypePrediction(FieldTypeQualityMetric metric, | 738 static void LogHeuristicPredictionQualityMetrics( |
| 679 ServerFieldType field_type, | 739 const ServerFieldTypeSet& possible_types, |
| 680 QualityMetricType metric_type); | 740 ServerFieldType predicted_type, |
| 681 static void LogOverallTypePrediction(FieldTypeQualityMetric metric, | 741 QualityMetricType metric_type); |
| 682 ServerFieldType field_type, | 742 static void LogServerPredictionQualityMetrics( |
| 683 QualityMetricType metric_type); | 743 const ServerFieldTypeSet& possible_types, |
| 684 static void LogServerTypePrediction(FieldTypeQualityMetric metric, | 744 ServerFieldType predicted_type, |
| 685 ServerFieldType field_type, | 745 QualityMetricType metric_type); |
| 686 QualityMetricType metric_type); | 746 static void LogOverallPredictionQualityMetrics( |
| 747 const ServerFieldTypeSet& possible_types, |
| 748 ServerFieldType predicted_type, |
| 749 QualityMetricType metric_type); |
| 687 | 750 |
| 688 static void LogServerQueryMetric(ServerQueryMetric metric); | 751 static void LogServerQueryMetric(ServerQueryMetric metric); |
| 689 | 752 |
| 690 static void LogUserHappinessMetric(UserHappinessMetric metric); | 753 static void LogUserHappinessMetric(UserHappinessMetric metric); |
| 691 | 754 |
| 692 // Logs |event| to the unmask prompt events histogram. | 755 // Logs |event| to the unmask prompt events histogram. |
| 693 static void LogUnmaskPromptEvent(UnmaskPromptEvent event); | 756 static void LogUnmaskPromptEvent(UnmaskPromptEvent event); |
| 694 | 757 |
| 695 // Logs the time elapsed between the unmask prompt being shown and it | 758 // Logs the time elapsed between the unmask prompt being shown and it |
| 696 // being closed. | 759 // being closed. |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 | 962 |
| 900 private: | 963 private: |
| 901 static const int kNumCardUploadDecisionMetrics = 12; | 964 static const int kNumCardUploadDecisionMetrics = 12; |
| 902 | 965 |
| 903 DISALLOW_IMPLICIT_CONSTRUCTORS(AutofillMetrics); | 966 DISALLOW_IMPLICIT_CONSTRUCTORS(AutofillMetrics); |
| 904 }; | 967 }; |
| 905 | 968 |
| 906 } // namespace autofill | 969 } // namespace autofill |
| 907 | 970 |
| 908 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_METRICS_H_ | 971 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_METRICS_H_ |
| OLD | NEW |