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

Unified Diff: components/autofill/core/browser/autofill_metrics.cc

Issue 2776223002: Adds UKM for autofill attributes in form_structure. (Closed)
Patch Set: Uses vector of pairs instead of map for metrics. Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: components/autofill/core/browser/autofill_metrics.cc
diff --git a/components/autofill/core/browser/autofill_metrics.cc b/components/autofill/core/browser/autofill_metrics.cc
index 239334c5e660612da4f9da3d85384c3f663ff38e..893c6d4bd5da2402b6ebd9c9e1a3e700bc493c09 100644
--- a/components/autofill/core/browser/autofill_metrics.cc
+++ b/components/autofill/core/browser/autofill_metrics.cc
@@ -20,6 +20,8 @@
namespace internal {
const char kUKMCardUploadDecisionEntryName[] = "Autofill.CardUploadDecision";
const char kUKMCardUploadDecisionMetricName[] = "UploadDecision";
+const char kUKMDeveloperEngagementEntryName[] = "Autofill.DeveloperEngagement";
+const char kUKMDeveloperEngagementMetricName[] = "DeveloperEngagement";
} // namespace internal
namespace autofill {
@@ -704,18 +706,33 @@ void AutofillMetrics::LogCardUploadDecisionUkm(
if (upload_decision >= AutofillMetrics::NUM_CARD_UPLOAD_DECISION_METRICS)
return;
- // Set up as a map because the follow-up CL will add more metrics.
- std::map<std::string, int> metrics = {
+ const std::vector<std::pair<const char*, int>> metrics = {
{internal::kUKMCardUploadDecisionMetricName,
static_cast<int>(upload_decision)}};
LogUkm(ukm_service, url, internal::kUKMCardUploadDecisionEntryName, metrics);
}
// static
-bool AutofillMetrics::LogUkm(ukm::UkmService* ukm_service,
- const GURL& url,
- const std::string& ukm_entry_name,
- const std::map<std::string, int>& metrics) {
+void AutofillMetrics::LogDeveloperEngagementUkm(
+ ukm::UkmService* ukm_service,
+ const GURL& url,
+ const std::vector<AutofillMetrics::DeveloperEngagementMetric>& metrics) {
+ std::vector<std::pair<const char*, int>> form_structure_metrics;
+ for (auto it = metrics.begin(); it != metrics.end(); ++it) {
+ if (*it < AutofillMetrics::NUM_DEVELOPER_ENGAGEMENT_METRICS)
+ form_structure_metrics.emplace_back(std::make_pair(
+ internal::kUKMDeveloperEngagementMetricName, static_cast<int>(*it)));
+ }
+ LogUkm(ukm_service, url, internal::kUKMDeveloperEngagementEntryName,
+ form_structure_metrics);
+}
+
+// static
+bool AutofillMetrics::LogUkm(
+ ukm::UkmService* ukm_service,
+ const GURL& url,
+ const std::string& ukm_entry_name,
+ const std::vector<std::pair<const char*, int>>& metrics) {
if (!IsUkmLoggingEnabled() || !ukm_service || !url.is_valid() ||
metrics.empty()) {
return false;
@@ -727,7 +744,7 @@ bool AutofillMetrics::LogUkm(ukm::UkmService* ukm_service,
ukm_service->GetEntryBuilder(source_id, ukm_entry_name.c_str());
for (auto it = metrics.begin(); it != metrics.end(); ++it) {
- builder->AddMetric(it->first.c_str(), it->second);
+ builder->AddMetric(it->first, it->second);
}
return true;

Powered by Google App Engine
This is Rietveld 408576698