Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: components/autofill/core/browser/autofill_metrics.cc

Issue 2776223002: Adds UKM for autofill attributes in form_structure. (Closed)
Patch Set: Resolves merge conflicts with FORM_CONTAINS_UPI_VPA_HINT. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_experiments.h"
15 #include "components/autofill/core/browser/autofill_type.h" 15 #include "components/autofill/core/browser/autofill_type.h"
16 #include "components/autofill/core/browser/form_structure.h" 16 #include "components/autofill/core/browser/form_structure.h"
17 #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" 18 #include "components/ukm/ukm_entry_builder.h"
19 19
20 namespace internal { 20 namespace internal {
21 const char kUKMCardUploadDecisionEntryName[] = "Autofill.CardUploadDecision"; 21 const char kUKMCardUploadDecisionEntryName[] = "Autofill.CardUploadDecision";
22 const char kUKMCardUploadDecisionMetricName[] = "UploadDecision"; 22 const char kUKMCardUploadDecisionMetricName[] = "UploadDecision";
23 const char kUKMDeveloperEngagementEntryName[] = "Autofill.DeveloperEngagement";
24 const char kUKMDeveloperEngagementMetricName[] = "DeveloperEngagement";
23 } // namespace internal 25 } // namespace internal
24 26
25 namespace autofill { 27 namespace autofill {
26 28
27 namespace { 29 namespace {
28 30
29 // Note: if adding an enum value here, update the corresponding description for 31 // Note: if adding an enum value here, update the corresponding description for
30 // AutofillTypeQualityByFieldType in histograms.xml. 32 // AutofillTypeQualityByFieldType in histograms.xml.
31 enum FieldTypeGroupForMetrics { 33 enum FieldTypeGroupForMetrics {
32 GROUP_AMBIGUOUS = 0, 34 GROUP_AMBIGUOUS = 0,
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 } 699 }
698 700
699 // static 701 // static
700 void AutofillMetrics::LogCardUploadDecisionUkm( 702 void AutofillMetrics::LogCardUploadDecisionUkm(
701 ukm::UkmService* ukm_service, 703 ukm::UkmService* ukm_service,
702 const GURL& url, 704 const GURL& url,
703 AutofillMetrics::CardUploadDecisionMetric upload_decision) { 705 AutofillMetrics::CardUploadDecisionMetric upload_decision) {
704 if (upload_decision >= AutofillMetrics::NUM_CARD_UPLOAD_DECISION_METRICS) 706 if (upload_decision >= AutofillMetrics::NUM_CARD_UPLOAD_DECISION_METRICS)
705 return; 707 return;
706 708
707 // Set up as a map because the follow-up CL will add more metrics. 709 const std::map<std::string, int> metrics = {
708 std::map<std::string, int> metrics = {
709 {internal::kUKMCardUploadDecisionMetricName, 710 {internal::kUKMCardUploadDecisionMetricName,
710 static_cast<int>(upload_decision)}}; 711 static_cast<int>(upload_decision)}};
711 LogUkm(ukm_service, url, internal::kUKMCardUploadDecisionEntryName, metrics); 712 LogUkm(ukm_service, url, internal::kUKMCardUploadDecisionEntryName, metrics);
712 } 713 }
713 714
714 // static 715 // static
716 void AutofillMetrics::LogDeveloperEngagementUkm(
717 ukm::UkmService* ukm_service,
718 const GURL& url,
719 AutofillMetrics::DeveloperEngagementMetric metric) {
720 const std::map<std::string, int> form_structure_metrics = {
721 {internal::kUKMDeveloperEngagementMetricName, static_cast<int>(metric)}};
722 LogUkm(ukm_service, url, internal::kUKMDeveloperEngagementEntryName,
723 form_structure_metrics);
724 }
725
726 // static
715 bool AutofillMetrics::LogUkm(ukm::UkmService* ukm_service, 727 bool AutofillMetrics::LogUkm(ukm::UkmService* ukm_service,
716 const GURL& url, 728 const GURL& url,
717 const std::string& ukm_entry_name, 729 const std::string& ukm_entry_name,
718 const std::map<std::string, int>& metrics) { 730 const std::map<std::string, int>& metrics) {
719 if (!IsUkmLoggingEnabled() || !ukm_service || !url.is_valid() || 731 if (!IsUkmLoggingEnabled() || !ukm_service || !url.is_valid() ||
720 metrics.empty()) { 732 metrics.empty()) {
721 return false; 733 return false;
722 } 734 }
723 735
724 int32_t source_id = ukm_service->GetNewSourceID(); 736 int32_t source_id = ukm_service->GetNewSourceID();
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 else if (is_server_data_available_ && !is_local_data_available_) 942 else if (is_server_data_available_ && !is_local_data_available_)
931 name += ".WithOnlyServerData"; 943 name += ".WithOnlyServerData";
932 else if (!is_server_data_available_ && is_local_data_available_) 944 else if (!is_server_data_available_ && is_local_data_available_)
933 name += ".WithOnlyLocalData"; 945 name += ".WithOnlyLocalData";
934 else 946 else
935 name += ".WithBothServerAndLocalData"; 947 name += ".WithBothServerAndLocalData";
936 LogUMAHistogramEnumeration(name, event, NUM_FORM_EVENTS); 948 LogUMAHistogramEnumeration(name, event, NUM_FORM_EVENTS);
937 } 949 }
938 950
939 } // namespace autofill 951 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_metrics.h ('k') | components/autofill/core/browser/autofill_metrics_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698