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" | |
19 | |
20 namespace internal { | |
21 const char kUKMCardUploadDecisionEntryName[] = "Autofill.CardUploadDecision"; | |
22 const char kUKMCardUploadDecisionMetricName[] = "UploadDecision"; | |
23 } // namespace internal | |
17 | 24 |
18 namespace autofill { | 25 namespace autofill { |
19 | 26 |
20 namespace { | 27 namespace { |
21 | 28 |
22 // Note: if adding an enum value here, update the corresponding description for | 29 // Note: if adding an enum value here, update the corresponding description for |
23 // AutofillTypeQualityByFieldType in histograms.xml. | 30 // AutofillTypeQualityByFieldType in histograms.xml. |
24 enum FieldTypeGroupForMetrics { | 31 enum FieldTypeGroupForMetrics { |
25 GROUP_AMBIGUOUS = 0, | 32 GROUP_AMBIGUOUS = 0, |
26 GROUP_NAME, | 33 GROUP_NAME, |
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
682 UMA_HISTOGRAM_ENUMERATION("Autofill.WalletAddressConversionType", type, | 689 UMA_HISTOGRAM_ENUMERATION("Autofill.WalletAddressConversionType", type, |
683 NUM_CONVERTED_ADDRESS_CONVERSION_TYPES); | 690 NUM_CONVERTED_ADDRESS_CONVERSION_TYPES); |
684 } | 691 } |
685 | 692 |
686 // static | 693 // static |
687 void AutofillMetrics::LogShowedHttpNotSecureExplanation() { | 694 void AutofillMetrics::LogShowedHttpNotSecureExplanation() { |
688 base::RecordAction( | 695 base::RecordAction( |
689 base::UserMetricsAction("Autofill_ShowedHttpNotSecureExplanation")); | 696 base::UserMetricsAction("Autofill_ShowedHttpNotSecureExplanation")); |
690 } | 697 } |
691 | 698 |
699 // static | |
700 void AutofillMetrics::LogCardUploadDecisionMetricUkm( | |
701 ukm::UkmService* ukm_service, | |
702 const GURL& url, | |
703 AutofillMetrics::CardUploadDecisionMetric upload_decision) { | |
704 if (upload_decision >= AutofillMetrics::NUM_CARD_UPLOAD_DECISION_METRICS) | |
705 return; | |
706 | |
707 std::map<std::string, int> metrics = { | |
rkaplow
2017/03/10 19:00:27
hm, right now LogUKM supports a map, but we're onl
sebsg
2017/03/10 19:25:33
The Payment Request ukm that I'm adding now in ano
rkaplow
2017/03/10 20:26:16
yes, we can probably do that though.
Can you add
sebsg
2017/03/10 20:38:07
Done.
| |
708 {internal::kUKMCardUploadDecisionMetricName, | |
709 static_cast<int>(upload_decision)}}; | |
710 LogUkm(ukm_service, url, internal::kUKMCardUploadDecisionEntryName, metrics); | |
711 } | |
712 | |
713 // static | |
714 bool AutofillMetrics::LogUkm(ukm::UkmService* ukm_service, | |
715 const GURL& url, | |
716 const std::string& ukm, | |
717 const std::map<std::string, int>& metrics) { | |
718 if (!IsUkmLoggingEnabled() || !ukm_service || !url.is_valid() || | |
719 metrics.empty()) { | |
720 return false; | |
721 } | |
722 | |
723 int32_t source_id = ukm_service->GetNewSourceID(); | |
724 ukm_service->UpdateSourceURL(source_id, url); | |
725 std::unique_ptr<ukm::UkmEntryBuilder> builder = | |
726 ukm_service->GetEntryBuilder(source_id, ukm.c_str()); | |
727 | |
728 for (auto it = metrics.begin(); it != metrics.end(); ++it) { | |
729 builder->AddMetric(it->first.c_str(), it->second); | |
730 } | |
731 | |
732 return true; | |
733 } | |
734 | |
692 AutofillMetrics::FormEventLogger::FormEventLogger(bool is_for_credit_card) | 735 AutofillMetrics::FormEventLogger::FormEventLogger(bool is_for_credit_card) |
693 : is_for_credit_card_(is_for_credit_card), | 736 : is_for_credit_card_(is_for_credit_card), |
694 is_server_data_available_(false), | 737 is_server_data_available_(false), |
695 is_local_data_available_(false), | 738 is_local_data_available_(false), |
696 is_context_secure_(false), | 739 is_context_secure_(false), |
697 has_logged_interacted_(false), | 740 has_logged_interacted_(false), |
698 has_logged_suggestions_shown_(false), | 741 has_logged_suggestions_shown_(false), |
699 has_logged_masked_server_card_suggestion_selected_(false), | 742 has_logged_masked_server_card_suggestion_selected_(false), |
700 has_logged_suggestion_filled_(false), | 743 has_logged_suggestion_filled_(false), |
701 has_logged_will_submit_(false), | 744 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_) | 929 else if (is_server_data_available_ && !is_local_data_available_) |
887 name += ".WithOnlyServerData"; | 930 name += ".WithOnlyServerData"; |
888 else if (!is_server_data_available_ && is_local_data_available_) | 931 else if (!is_server_data_available_ && is_local_data_available_) |
889 name += ".WithOnlyLocalData"; | 932 name += ".WithOnlyLocalData"; |
890 else | 933 else |
891 name += ".WithBothServerAndLocalData"; | 934 name += ".WithBothServerAndLocalData"; |
892 LogUMAHistogramEnumeration(name, event, NUM_FORM_EVENTS); | 935 LogUMAHistogramEnumeration(name, event, NUM_FORM_EVENTS); |
893 } | 936 } |
894 | 937 |
895 } // namespace autofill | 938 } // namespace autofill |
OLD | NEW |