| 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 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 AutofillMetrics::NUM_FIELD_TYPE_QUALITY_METRICS * | 300 AutofillMetrics::NUM_FIELD_TYPE_QUALITY_METRICS * |
| 301 NUM_FIELD_TYPE_GROUPS_FOR_METRICS; | 301 NUM_FIELD_TYPE_GROUPS_FOR_METRICS; |
| 302 LogUMAHistogramEnumeration(base_name + ".ByFieldType" + suffix, | 302 LogUMAHistogramEnumeration(base_name + ".ByFieldType" + suffix, |
| 303 field_type_group_metric, | 303 field_type_group_metric, |
| 304 num_field_type_group_metrics); | 304 num_field_type_group_metrics); |
| 305 } | 305 } |
| 306 | 306 |
| 307 } // namespace | 307 } // namespace |
| 308 | 308 |
| 309 // static | 309 // static |
| 310 void AutofillMetrics::LogCardUploadDecisionMetric( | 310 void AutofillMetrics::LogCardUploadDecisionMetrics( |
| 311 CardUploadDecisionMetric metric) { | 311 int upload_decision_metrics) { |
| 312 DCHECK_LT(metric, NUM_CARD_UPLOAD_DECISION_METRICS); | 312 DCHECK(upload_decision_metrics); |
| 313 UMA_HISTOGRAM_ENUMERATION("Autofill.CardUploadDecisionExpanded", metric, | 313 DCHECK_LT(upload_decision_metrics, 1 << kNumCardUploadDecisionMetrics); |
| 314 NUM_CARD_UPLOAD_DECISION_METRICS); | 314 |
| 315 for (int metric = 0; metric < kNumCardUploadDecisionMetrics; ++metric) |
| 316 if (upload_decision_metrics & (1 << metric)) |
| 317 UMA_HISTOGRAM_ENUMERATION("Autofill.CardUploadDecisionMetric", metric, |
| 318 kNumCardUploadDecisionMetrics); |
| 315 } | 319 } |
| 316 | 320 |
| 317 // static | 321 // static |
| 318 void AutofillMetrics::LogCreditCardInfoBarMetric( | 322 void AutofillMetrics::LogCreditCardInfoBarMetric( |
| 319 InfoBarMetric metric, | 323 InfoBarMetric metric, |
| 320 bool is_uploading, | 324 bool is_uploading, |
| 321 int previous_save_credit_card_prompt_user_decision) { | 325 int previous_save_credit_card_prompt_user_decision) { |
| 322 DCHECK_LT(metric, NUM_INFO_BAR_METRICS); | 326 DCHECK_LT(metric, NUM_INFO_BAR_METRICS); |
| 323 | 327 |
| 324 std::string destination = is_uploading ? ".Server" : ".Local"; | 328 std::string destination = is_uploading ? ".Server" : ".Local"; |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 NUM_CONVERTED_ADDRESS_CONVERSION_TYPES); | 746 NUM_CONVERTED_ADDRESS_CONVERSION_TYPES); |
| 743 } | 747 } |
| 744 | 748 |
| 745 // static | 749 // static |
| 746 void AutofillMetrics::LogShowedHttpNotSecureExplanation() { | 750 void AutofillMetrics::LogShowedHttpNotSecureExplanation() { |
| 747 base::RecordAction( | 751 base::RecordAction( |
| 748 base::UserMetricsAction("Autofill_ShowedHttpNotSecureExplanation")); | 752 base::UserMetricsAction("Autofill_ShowedHttpNotSecureExplanation")); |
| 749 } | 753 } |
| 750 | 754 |
| 751 // static | 755 // static |
| 752 void AutofillMetrics::LogCardUploadDecisionUkm( | 756 void AutofillMetrics::LogCardUploadDecisionsUkm(ukm::UkmService* ukm_service, |
| 753 ukm::UkmService* ukm_service, | 757 const GURL& url, |
| 754 const GURL& url, | 758 int upload_decision_metrics) { |
| 755 AutofillMetrics::CardUploadDecisionMetric upload_decision) { | 759 DCHECK(upload_decision_metrics); |
| 756 if (upload_decision >= AutofillMetrics::NUM_CARD_UPLOAD_DECISION_METRICS) | 760 DCHECK_LT(upload_decision_metrics, 1 << kNumCardUploadDecisionMetrics); |
| 757 return; | |
| 758 | 761 |
| 759 const std::vector<std::pair<const char*, int>> metrics = { | 762 const std::vector<std::pair<const char*, int>> metrics = { |
| 760 {internal::kUKMCardUploadDecisionMetricName, | 763 {internal::kUKMCardUploadDecisionMetricName, upload_decision_metrics}}; |
| 761 static_cast<int>(upload_decision)}}; | |
| 762 LogUkm(ukm_service, url, internal::kUKMCardUploadDecisionEntryName, metrics); | 764 LogUkm(ukm_service, url, internal::kUKMCardUploadDecisionEntryName, metrics); |
| 763 } | 765 } |
| 764 | 766 |
| 765 // static | 767 // static |
| 766 void AutofillMetrics::LogDeveloperEngagementUkm( | 768 void AutofillMetrics::LogDeveloperEngagementUkm( |
| 767 ukm::UkmService* ukm_service, | 769 ukm::UkmService* ukm_service, |
| 768 const GURL& url, | 770 const GURL& url, |
| 769 std::vector<AutofillMetrics::DeveloperEngagementMetric> metrics) { | 771 int developer_engagement_metrics) { |
| 770 std::vector<std::pair<const char*, int>> form_structure_metrics; | 772 DCHECK(developer_engagement_metrics); |
| 771 for (const auto it : metrics) | 773 DCHECK_LT(developer_engagement_metrics, |
| 772 form_structure_metrics.push_back( | 774 1 << NUM_DEVELOPER_ENGAGEMENT_METRICS); |
| 773 {internal::kUKMDeveloperEngagementMetricName, static_cast<int>(it)}); | |
| 774 | 775 |
| 775 LogUkm(ukm_service, url, internal::kUKMDeveloperEngagementEntryName, | 776 const std::vector<std::pair<const char*, int>> metrics = { |
| 776 form_structure_metrics); | 777 {internal::kUKMDeveloperEngagementMetricName, |
| 778 developer_engagement_metrics}}; |
| 779 |
| 780 LogUkm(ukm_service, url, internal::kUKMDeveloperEngagementEntryName, metrics); |
| 777 } | 781 } |
| 778 | 782 |
| 779 // static | 783 // static |
| 780 bool AutofillMetrics::LogUkm( | 784 bool AutofillMetrics::LogUkm( |
| 781 ukm::UkmService* ukm_service, | 785 ukm::UkmService* ukm_service, |
| 782 const GURL& url, | 786 const GURL& url, |
| 783 const std::string& ukm_entry_name, | 787 const std::string& ukm_entry_name, |
| 784 const std::vector<std::pair<const char*, int>>& metrics) { | 788 const std::vector<std::pair<const char*, int>>& metrics) { |
| 785 if (!IsUkmLoggingEnabled() || !ukm_service || !url.is_valid() || | 789 if (!IsUkmLoggingEnabled() || !ukm_service || !url.is_valid() || |
| 786 metrics.empty()) { | 790 metrics.empty()) { |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1151 DCHECK(!form_loaded_timestamp_.is_null()); | 1155 DCHECK(!form_loaded_timestamp_.is_null()); |
| 1152 return (base::TimeTicks::Now() - form_loaded_timestamp_).InMilliseconds(); | 1156 return (base::TimeTicks::Now() - form_loaded_timestamp_).InMilliseconds(); |
| 1153 } | 1157 } |
| 1154 | 1158 |
| 1155 void AutofillMetrics::FormInteractionsUkmLogger::GetNewSourceID() { | 1159 void AutofillMetrics::FormInteractionsUkmLogger::GetNewSourceID() { |
| 1156 source_id_ = ukm_service_->GetNewSourceID(); | 1160 source_id_ = ukm_service_->GetNewSourceID(); |
| 1157 ukm_service_->UpdateSourceURL(source_id_, url_); | 1161 ukm_service_->UpdateSourceURL(source_id_, url_); |
| 1158 } | 1162 } |
| 1159 | 1163 |
| 1160 } // namespace autofill | 1164 } // namespace autofill |
| OLD | NEW |