| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "components/autofill/core/browser/autofill_type.h" | 10 #include "components/autofill/core/browser/autofill_type.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 // AMBIGUOUS+MATCH, | 72 // AMBIGUOUS+MATCH, |
| 73 // AMBIGUOUS+MISMATCH, | 73 // AMBIGUOUS+MISMATCH, |
| 74 // NAME+UNKNOWN, | 74 // NAME+UNKNOWN, |
| 75 // NAME+MATCH, | 75 // NAME+MATCH, |
| 76 // NAME+MISMATCH, | 76 // NAME+MISMATCH, |
| 77 // ... | 77 // ... |
| 78 // }. | 78 // }. |
| 79 // | 79 // |
| 80 // Clients must ensure that |field_type| is one of the types Chrome supports | 80 // Clients must ensure that |field_type| is one of the types Chrome supports |
| 81 // natively, e.g. |field_type| must not be a billng address. | 81 // natively, e.g. |field_type| must not be a billng address. |
| 82 int GetFieldTypeGroupMetric(const AutofillFieldType field_type, | 82 int GetFieldTypeGroupMetric(const ServerFieldType field_type, |
| 83 const int metric, | 83 const int metric, |
| 84 const int num_possible_metrics) { | 84 const int num_possible_metrics) { |
| 85 DCHECK_LT(metric, num_possible_metrics); | 85 DCHECK_LT(metric, num_possible_metrics); |
| 86 | 86 |
| 87 FieldTypeGroupForMetrics group; | 87 FieldTypeGroupForMetrics group; |
| 88 switch (AutofillType(field_type).group()) { | 88 switch (AutofillType(field_type).group()) { |
| 89 case ::autofill::NO_GROUP: | 89 case ::autofill::NO_GROUP: |
| 90 group = AMBIGUOUS; | 90 group = AMBIGUOUS; |
| 91 break; | 91 break; |
| 92 | 92 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 histogram->AddTime(duration); | 243 histogram->AddTime(duration); |
| 244 } | 244 } |
| 245 | 245 |
| 246 // Logs a type quality metric. The primary histogram name is constructed based | 246 // Logs a type quality metric. The primary histogram name is constructed based |
| 247 // on |base_name| and |experiment_id|. The field-specific histogram name also | 247 // on |base_name| and |experiment_id|. The field-specific histogram name also |
| 248 // factors in the |field_type|. Logs a sample of |metric|, which should be in | 248 // factors in the |field_type|. Logs a sample of |metric|, which should be in |
| 249 // the range [0, |num_possible_metrics|). | 249 // the range [0, |num_possible_metrics|). |
| 250 void LogTypeQualityMetric(const std::string& base_name, | 250 void LogTypeQualityMetric(const std::string& base_name, |
| 251 const int metric, | 251 const int metric, |
| 252 const int num_possible_metrics, | 252 const int num_possible_metrics, |
| 253 const AutofillFieldType field_type, | 253 const ServerFieldType field_type, |
| 254 const std::string& experiment_id) { | 254 const std::string& experiment_id) { |
| 255 DCHECK_LT(metric, num_possible_metrics); | 255 DCHECK_LT(metric, num_possible_metrics); |
| 256 | 256 |
| 257 std::string histogram_name = base_name; | 257 std::string histogram_name = base_name; |
| 258 if (!experiment_id.empty()) | 258 if (!experiment_id.empty()) |
| 259 histogram_name += "_" + experiment_id; | 259 histogram_name += "_" + experiment_id; |
| 260 LogUMAHistogramEnumeration(histogram_name, metric, num_possible_metrics); | 260 LogUMAHistogramEnumeration(histogram_name, metric, num_possible_metrics); |
| 261 | 261 |
| 262 std::string sub_histogram_name = base_name + ".ByFieldType"; | 262 std::string sub_histogram_name = base_name + ".ByFieldType"; |
| 263 if (!experiment_id.empty()) | 263 if (!experiment_id.empty()) |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 void AutofillMetrics::LogDeveloperEngagementMetric( | 474 void AutofillMetrics::LogDeveloperEngagementMetric( |
| 475 DeveloperEngagementMetric metric) const { | 475 DeveloperEngagementMetric metric) const { |
| 476 DCHECK_LT(metric, NUM_DEVELOPER_ENGAGEMENT_METRICS); | 476 DCHECK_LT(metric, NUM_DEVELOPER_ENGAGEMENT_METRICS); |
| 477 | 477 |
| 478 UMA_HISTOGRAM_ENUMERATION("Autofill.DeveloperEngagement", metric, | 478 UMA_HISTOGRAM_ENUMERATION("Autofill.DeveloperEngagement", metric, |
| 479 NUM_DEVELOPER_ENGAGEMENT_METRICS); | 479 NUM_DEVELOPER_ENGAGEMENT_METRICS); |
| 480 } | 480 } |
| 481 | 481 |
| 482 void AutofillMetrics::LogHeuristicTypePrediction( | 482 void AutofillMetrics::LogHeuristicTypePrediction( |
| 483 FieldTypeQualityMetric metric, | 483 FieldTypeQualityMetric metric, |
| 484 AutofillFieldType field_type, | 484 ServerFieldType field_type, |
| 485 const std::string& experiment_id) const { | 485 const std::string& experiment_id) const { |
| 486 LogTypeQualityMetric("Autofill.Quality.HeuristicType", | 486 LogTypeQualityMetric("Autofill.Quality.HeuristicType", |
| 487 metric, NUM_FIELD_TYPE_QUALITY_METRICS, | 487 metric, NUM_FIELD_TYPE_QUALITY_METRICS, |
| 488 field_type, experiment_id); | 488 field_type, experiment_id); |
| 489 } | 489 } |
| 490 | 490 |
| 491 void AutofillMetrics::LogOverallTypePrediction( | 491 void AutofillMetrics::LogOverallTypePrediction( |
| 492 FieldTypeQualityMetric metric, | 492 FieldTypeQualityMetric metric, |
| 493 AutofillFieldType field_type, | 493 ServerFieldType field_type, |
| 494 const std::string& experiment_id) const { | 494 const std::string& experiment_id) const { |
| 495 LogTypeQualityMetric("Autofill.Quality.PredictedType", | 495 LogTypeQualityMetric("Autofill.Quality.PredictedType", |
| 496 metric, NUM_FIELD_TYPE_QUALITY_METRICS, | 496 metric, NUM_FIELD_TYPE_QUALITY_METRICS, |
| 497 field_type, experiment_id); | 497 field_type, experiment_id); |
| 498 } | 498 } |
| 499 | 499 |
| 500 void AutofillMetrics::LogServerTypePrediction( | 500 void AutofillMetrics::LogServerTypePrediction( |
| 501 FieldTypeQualityMetric metric, | 501 FieldTypeQualityMetric metric, |
| 502 AutofillFieldType field_type, | 502 ServerFieldType field_type, |
| 503 const std::string& experiment_id) const { | 503 const std::string& experiment_id) const { |
| 504 LogTypeQualityMetric("Autofill.Quality.ServerType", | 504 LogTypeQualityMetric("Autofill.Quality.ServerType", |
| 505 metric, NUM_FIELD_TYPE_QUALITY_METRICS, | 505 metric, NUM_FIELD_TYPE_QUALITY_METRICS, |
| 506 field_type, experiment_id); | 506 field_type, experiment_id); |
| 507 } | 507 } |
| 508 | 508 |
| 509 void AutofillMetrics::LogQualityMetric(QualityMetric metric, | 509 void AutofillMetrics::LogQualityMetric(QualityMetric metric, |
| 510 const std::string& experiment_id) const { | 510 const std::string& experiment_id) const { |
| 511 DCHECK_LT(metric, NUM_QUALITY_METRICS); | 511 DCHECK_LT(metric, NUM_QUALITY_METRICS); |
| 512 | 512 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 const std::string& experiment_id) const { | 589 const std::string& experiment_id) const { |
| 590 LogServerExperimentId("Autofill.ServerExperimentId.Query", experiment_id); | 590 LogServerExperimentId("Autofill.ServerExperimentId.Query", experiment_id); |
| 591 } | 591 } |
| 592 | 592 |
| 593 void AutofillMetrics::LogServerExperimentIdForUpload( | 593 void AutofillMetrics::LogServerExperimentIdForUpload( |
| 594 const std::string& experiment_id) const { | 594 const std::string& experiment_id) const { |
| 595 LogServerExperimentId("Autofill.ServerExperimentId.Upload", experiment_id); | 595 LogServerExperimentId("Autofill.ServerExperimentId.Upload", experiment_id); |
| 596 } | 596 } |
| 597 | 597 |
| 598 } // namespace autofill | 598 } // namespace autofill |
| OLD | NEW |