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

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

Issue 2776223002: Adds UKM for autofill attributes in form_structure. (Closed)
Patch Set: Adds UKM for autofill attributes in form_structure. 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 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 return; 707 return;
706 708
707 // Set up as a map because the follow-up CL will add more metrics. 709 // Set up as a map because the follow-up CL will add more metrics.
708 std::map<std::string, int> metrics = { 710 std::map<std::string, int> metrics = {
709 {internal::kUKMCardUploadDecisionMetricName, 711 {internal::kUKMCardUploadDecisionMetricName,
710 static_cast<int>(upload_decision)}}; 712 static_cast<int>(upload_decision)}};
711 LogUkm(ukm_service, url, internal::kUKMCardUploadDecisionEntryName, metrics); 713 LogUkm(ukm_service, url, internal::kUKMCardUploadDecisionEntryName, metrics);
712 } 714 }
713 715
714 // static 716 // static
717 void AutofillMetrics::LogDeveloperEngagementUkm(
718 ukm::UkmService* ukm_service,
719 const GURL& url,
720 AutofillMetrics::DeveloperEngagementMetric form_structure_metric) {
721 if (form_structure_metric >=
722 AutofillMetrics::NUM_DEVELOPER_ENGAGEMENT_METRICS)
723 return;
724
725 std::map<std::string, int> metrics = {
726 {internal::kUKMDeveloperEngagementMetricName,
727 static_cast<int>(form_structure_metric)}};
728 LogUkm(ukm_service, url, internal::kUKMDeveloperEngagementEntryName, metrics);
729 }
730
731 // static
715 bool AutofillMetrics::LogUkm(ukm::UkmService* ukm_service, 732 bool AutofillMetrics::LogUkm(ukm::UkmService* ukm_service,
716 const GURL& url, 733 const GURL& url,
717 const std::string& ukm_entry_name, 734 const std::string& ukm_entry_name,
718 const std::map<std::string, int>& metrics) { 735 const std::map<std::string, int>& metrics) {
719 if (!IsUkmLoggingEnabled() || !ukm_service || !url.is_valid() || 736 if (!IsUkmLoggingEnabled() || !ukm_service || !url.is_valid() ||
720 metrics.empty()) { 737 metrics.empty()) {
721 return false; 738 return false;
722 } 739 }
723 740
724 int32_t source_id = ukm_service->GetNewSourceID(); 741 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_) 947 else if (is_server_data_available_ && !is_local_data_available_)
931 name += ".WithOnlyServerData"; 948 name += ".WithOnlyServerData";
932 else if (!is_server_data_available_ && is_local_data_available_) 949 else if (!is_server_data_available_ && is_local_data_available_)
933 name += ".WithOnlyLocalData"; 950 name += ".WithOnlyLocalData";
934 else 951 else
935 name += ".WithBothServerAndLocalData"; 952 name += ".WithBothServerAndLocalData";
936 LogUMAHistogramEnumeration(name, event, NUM_FORM_EVENTS); 953 LogUMAHistogramEnumeration(name, event, NUM_FORM_EVENTS);
937 } 954 }
938 955
939 } // namespace autofill 956 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698