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 #include "components/autofill/core/browser/autofill_metrics.h" | 5 #include "components/autofill/core/browser/autofill_metrics.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
11 #include "base/metrics/sparse_histogram.h" | 11 #include "base/metrics/sparse_histogram.h" |
12 #include "base/metrics/user_metrics.h" | 12 #include "base/metrics/user_metrics.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "components/autofill/core/browser/autofill_experiments.h" |
14 #include "components/autofill/core/browser/autofill_type.h" | 15 #include "components/autofill/core/browser/autofill_type.h" |
15 #include "components/autofill/core/browser/form_structure.h" | 16 #include "components/autofill/core/browser/form_structure.h" |
16 #include "components/autofill/core/common/form_data.h" | 17 #include "components/autofill/core/common/form_data.h" |
| 18 #include "components/ukm/ukm_entry_builder.h" |
17 | 19 |
18 namespace autofill { | 20 namespace autofill { |
19 | 21 |
20 namespace { | 22 namespace { |
21 | 23 |
22 // Note: if adding an enum value here, update the corresponding description for | 24 // Note: if adding an enum value here, update the corresponding description for |
23 // AutofillTypeQualityByFieldType in histograms.xml. | 25 // AutofillTypeQualityByFieldType in histograms.xml. |
24 enum FieldTypeGroupForMetrics { | 26 enum FieldTypeGroupForMetrics { |
25 GROUP_AMBIGUOUS = 0, | 27 GROUP_AMBIGUOUS = 0, |
26 GROUP_NAME, | 28 GROUP_NAME, |
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 UMA_HISTOGRAM_ENUMERATION("Autofill.WalletAddressConversionType", type, | 684 UMA_HISTOGRAM_ENUMERATION("Autofill.WalletAddressConversionType", type, |
683 NUM_CONVERTED_ADDRESS_CONVERSION_TYPES); | 685 NUM_CONVERTED_ADDRESS_CONVERSION_TYPES); |
684 } | 686 } |
685 | 687 |
686 // static | 688 // static |
687 void AutofillMetrics::LogShowedHttpNotSecureExplanation() { | 689 void AutofillMetrics::LogShowedHttpNotSecureExplanation() { |
688 base::RecordAction( | 690 base::RecordAction( |
689 base::UserMetricsAction("Autofill_ShowedHttpNotSecureExplanation")); | 691 base::UserMetricsAction("Autofill_ShowedHttpNotSecureExplanation")); |
690 } | 692 } |
691 | 693 |
| 694 // static |
| 695 bool AutofillMetrics::LogUkm(ukm::UkmService* ukm_service, |
| 696 const GURL& url, |
| 697 const std::string& ukm, |
| 698 const std::map<std::string, int>& metrics) { |
| 699 if (!IsUkmLoggingEnabled() || !ukm_service || !url.is_valid() || |
| 700 metrics.empty()) { |
| 701 return false; |
| 702 } |
| 703 |
| 704 int32_t source_id = ukm_service->GetNewSourceID(); |
| 705 ukm_service->UpdateSourceURL(source_id, url); |
| 706 std::unique_ptr<ukm::UkmEntryBuilder> builder = |
| 707 ukm_service->GetEntryBuilder(source_id, ukm.c_str()); |
| 708 |
| 709 for (auto it = metrics.begin(); it != metrics.end(); ++it) { |
| 710 builder->AddMetric(it->first.c_str(), it->second); |
| 711 } |
| 712 |
| 713 return true; |
| 714 } |
| 715 |
692 AutofillMetrics::FormEventLogger::FormEventLogger(bool is_for_credit_card) | 716 AutofillMetrics::FormEventLogger::FormEventLogger(bool is_for_credit_card) |
693 : is_for_credit_card_(is_for_credit_card), | 717 : is_for_credit_card_(is_for_credit_card), |
694 is_server_data_available_(false), | 718 is_server_data_available_(false), |
695 is_local_data_available_(false), | 719 is_local_data_available_(false), |
696 is_context_secure_(false), | 720 is_context_secure_(false), |
697 has_logged_interacted_(false), | 721 has_logged_interacted_(false), |
698 has_logged_suggestions_shown_(false), | 722 has_logged_suggestions_shown_(false), |
699 has_logged_masked_server_card_suggestion_selected_(false), | 723 has_logged_masked_server_card_suggestion_selected_(false), |
700 has_logged_suggestion_filled_(false), | 724 has_logged_suggestion_filled_(false), |
701 has_logged_will_submit_(false), | 725 has_logged_will_submit_(false), |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 else if (is_server_data_available_ && !is_local_data_available_) | 910 else if (is_server_data_available_ && !is_local_data_available_) |
887 name += ".WithOnlyServerData"; | 911 name += ".WithOnlyServerData"; |
888 else if (!is_server_data_available_ && is_local_data_available_) | 912 else if (!is_server_data_available_ && is_local_data_available_) |
889 name += ".WithOnlyLocalData"; | 913 name += ".WithOnlyLocalData"; |
890 else | 914 else |
891 name += ".WithBothServerAndLocalData"; | 915 name += ".WithBothServerAndLocalData"; |
892 LogUMAHistogramEnumeration(name, event, NUM_FORM_EVENTS); | 916 LogUMAHistogramEnumeration(name, event, NUM_FORM_EVENTS); |
893 } | 917 } |
894 | 918 |
895 } // namespace autofill | 919 } // namespace autofill |
OLD | NEW |