| 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" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 base::TimeDelta::FromMilliseconds(1), | 207 base::TimeDelta::FromMilliseconds(1), |
| 208 base::TimeDelta::FromHours(1), | 208 base::TimeDelta::FromHours(1), |
| 209 50, | 209 50, |
| 210 base::HistogramBase::kUmaTargetedHistogramFlag); | 210 base::HistogramBase::kUmaTargetedHistogramFlag); |
| 211 histogram->AddTime(duration); | 211 histogram->AddTime(duration); |
| 212 } | 212 } |
| 213 | 213 |
| 214 // Logs a type quality metric. The primary histogram name is constructed based | 214 // Logs a type quality metric. The primary histogram name is constructed based |
| 215 // on |base_name|. The field-specific histogram name also factors in the | 215 // on |base_name|. The field-specific histogram name also factors in the |
| 216 // |field_type|. Logs a sample of |metric|, which should be in the range | 216 // |field_type|. Logs a sample of |metric|, which should be in the range |
| 217 // [0, |num_possible_metrics|). | 217 // [0, |num_possible_metrics|). May log a suffixed version of the metric |
| 218 // depending on |metric_type|. |
| 218 void LogTypeQualityMetric(const std::string& base_name, | 219 void LogTypeQualityMetric(const std::string& base_name, |
| 219 AutofillMetrics::FieldTypeQualityMetric metric, | 220 AutofillMetrics::FieldTypeQualityMetric metric, |
| 220 ServerFieldType field_type, | 221 ServerFieldType field_type, |
| 221 bool observed_submission) { | 222 AutofillMetrics::QualityMetricType metric_type) { |
| 222 DCHECK_LT(metric, AutofillMetrics::NUM_FIELD_TYPE_QUALITY_METRICS); | 223 DCHECK_LT(metric, AutofillMetrics::NUM_FIELD_TYPE_QUALITY_METRICS); |
| 223 | 224 |
| 224 const std::string suffix(observed_submission ? "" : ".NoSubmission"); | 225 std::string suffix; |
| 226 switch (metric_type) { |
| 227 case AutofillMetrics::TYPE_SUBMISSION: |
| 228 break; |
| 229 case AutofillMetrics::TYPE_NO_SUBMISSION: |
| 230 suffix = ".NoSubmission"; |
| 231 break; |
| 232 case AutofillMetrics::TYPE_AUTOCOMPLETE_BASED: |
| 233 suffix = ".BasedOnAutocomplete"; |
| 234 break; |
| 235 default: |
| 236 NOTREACHED(); |
| 237 } |
| 225 LogUMAHistogramEnumeration(base_name + suffix, metric, | 238 LogUMAHistogramEnumeration(base_name + suffix, metric, |
| 226 AutofillMetrics::NUM_FIELD_TYPE_QUALITY_METRICS); | 239 AutofillMetrics::NUM_FIELD_TYPE_QUALITY_METRICS); |
| 227 | 240 |
| 228 int field_type_group_metric = GetFieldTypeGroupMetric(field_type, metric); | 241 int field_type_group_metric = GetFieldTypeGroupMetric(field_type, metric); |
| 229 int num_field_type_group_metrics = | 242 int num_field_type_group_metrics = |
| 230 AutofillMetrics::NUM_FIELD_TYPE_QUALITY_METRICS * | 243 AutofillMetrics::NUM_FIELD_TYPE_QUALITY_METRICS * |
| 231 NUM_FIELD_TYPE_GROUPS_FOR_METRICS; | 244 NUM_FIELD_TYPE_GROUPS_FOR_METRICS; |
| 232 LogUMAHistogramEnumeration(base_name + ".ByFieldType" + suffix, | 245 LogUMAHistogramEnumeration(base_name + ".ByFieldType" + suffix, |
| 233 field_type_group_metric, | 246 field_type_group_metric, |
| 234 num_field_type_group_metrics); | 247 num_field_type_group_metrics); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 | 414 |
| 402 // static | 415 // static |
| 403 void AutofillMetrics::LogDeveloperEngagementMetric( | 416 void AutofillMetrics::LogDeveloperEngagementMetric( |
| 404 DeveloperEngagementMetric metric) { | 417 DeveloperEngagementMetric metric) { |
| 405 DCHECK_LT(metric, NUM_DEVELOPER_ENGAGEMENT_METRICS); | 418 DCHECK_LT(metric, NUM_DEVELOPER_ENGAGEMENT_METRICS); |
| 406 UMA_HISTOGRAM_ENUMERATION("Autofill.DeveloperEngagement", metric, | 419 UMA_HISTOGRAM_ENUMERATION("Autofill.DeveloperEngagement", metric, |
| 407 NUM_DEVELOPER_ENGAGEMENT_METRICS); | 420 NUM_DEVELOPER_ENGAGEMENT_METRICS); |
| 408 } | 421 } |
| 409 | 422 |
| 410 // static | 423 // static |
| 411 void AutofillMetrics::LogHeuristicTypePrediction(FieldTypeQualityMetric metric, | 424 void AutofillMetrics::LogHeuristicTypePrediction( |
| 412 ServerFieldType field_type, | 425 FieldTypeQualityMetric metric, |
| 413 bool observed_submission) { | 426 ServerFieldType field_type, |
| 427 QualityMetricType metric_type) { |
| 414 LogTypeQualityMetric("Autofill.Quality.HeuristicType", metric, field_type, | 428 LogTypeQualityMetric("Autofill.Quality.HeuristicType", metric, field_type, |
| 415 observed_submission); | 429 metric_type); |
| 416 } | 430 } |
| 417 | 431 |
| 418 // static | 432 // static |
| 419 void AutofillMetrics::LogOverallTypePrediction(FieldTypeQualityMetric metric, | 433 void AutofillMetrics::LogOverallTypePrediction(FieldTypeQualityMetric metric, |
| 420 ServerFieldType field_type, | 434 ServerFieldType field_type, |
| 421 bool observed_submission) { | 435 QualityMetricType metric_type) { |
| 422 LogTypeQualityMetric("Autofill.Quality.PredictedType", metric, field_type, | 436 LogTypeQualityMetric("Autofill.Quality.PredictedType", metric, field_type, |
| 423 observed_submission); | 437 metric_type); |
| 424 } | 438 } |
| 425 | 439 |
| 426 // static | 440 // static |
| 427 void AutofillMetrics::LogServerTypePrediction(FieldTypeQualityMetric metric, | 441 void AutofillMetrics::LogServerTypePrediction(FieldTypeQualityMetric metric, |
| 428 ServerFieldType field_type, | 442 ServerFieldType field_type, |
| 429 bool observed_submission) { | 443 QualityMetricType metric_type) { |
| 430 LogTypeQualityMetric("Autofill.Quality.ServerType", metric, field_type, | 444 LogTypeQualityMetric("Autofill.Quality.ServerType", metric, field_type, |
| 431 observed_submission); | 445 metric_type); |
| 432 } | 446 } |
| 433 | 447 |
| 434 // static | 448 // static |
| 435 void AutofillMetrics::LogServerQueryMetric(ServerQueryMetric metric) { | 449 void AutofillMetrics::LogServerQueryMetric(ServerQueryMetric metric) { |
| 436 DCHECK_LT(metric, NUM_SERVER_QUERY_METRICS); | 450 DCHECK_LT(metric, NUM_SERVER_QUERY_METRICS); |
| 437 UMA_HISTOGRAM_ENUMERATION("Autofill.ServerQueryResponse", metric, | 451 UMA_HISTOGRAM_ENUMERATION("Autofill.ServerQueryResponse", metric, |
| 438 NUM_SERVER_QUERY_METRICS); | 452 NUM_SERVER_QUERY_METRICS); |
| 439 } | 453 } |
| 440 | 454 |
| 441 // static | 455 // static |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 else if (is_server_data_available_ && !is_local_data_available_) | 768 else if (is_server_data_available_ && !is_local_data_available_) |
| 755 name += ".WithOnlyServerData"; | 769 name += ".WithOnlyServerData"; |
| 756 else if (!is_server_data_available_ && is_local_data_available_) | 770 else if (!is_server_data_available_ && is_local_data_available_) |
| 757 name += ".WithOnlyLocalData"; | 771 name += ".WithOnlyLocalData"; |
| 758 else | 772 else |
| 759 name += ".WithBothServerAndLocalData"; | 773 name += ".WithBothServerAndLocalData"; |
| 760 LogUMAHistogramEnumeration(name, event, NUM_FORM_EVENTS); | 774 LogUMAHistogramEnumeration(name, event, NUM_FORM_EVENTS); |
| 761 } | 775 } |
| 762 | 776 |
| 763 } // namespace autofill | 777 } // namespace autofill |
| OLD | NEW |