Chromium Code Reviews| 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 21ca9f840d9ecad5624ba2474946b25d9dea0de2..1fc5f20406c01ceff77aedf4fb2b2eac8c730c0a 100644 |
| --- a/components/autofill/core/browser/autofill_metrics.cc |
| +++ b/components/autofill/core/browser/autofill_metrics.cc |
| @@ -465,4 +465,52 @@ void AutofillMetrics::LogAddressSuggestionsCount(size_t num_suggestions) { |
| UMA_HISTOGRAM_COUNTS("Autofill.AddressSuggestionsCount", num_suggestions); |
| } |
| +AutofillMetrics::FormEventLogger::FormEventLogger(bool is_credit_card) |
| + : is_credit_card_(is_credit_card), |
| + is_server_data_available_(false), |
| + is_local_data_available_(false), |
| + has_logged_interacted_(false) {}; |
| + |
| +void AutofillMetrics::FormEventLogger::set_is_server_data_available( |
| + bool is_server_data_available) { |
| + is_server_data_available_ = is_server_data_available; |
| +} |
| + |
| +void AutofillMetrics::FormEventLogger::set_is_local_data_available( |
| + bool is_local_data_available) { |
| + is_local_data_available_ = is_local_data_available; |
| +} |
| + |
| +void AutofillMetrics::FormEventLogger::OnDidInteractWithAutofillableForm() { |
| + if (!has_logged_interacted_) { |
| + has_logged_interacted_ = true; |
| + Log(AutofillMetrics::INTERACTED_ONCE); |
| + } |
| +} |
| + |
| +void AutofillMetrics::FormEventLogger::Log(AutofillFormEvent event) const { |
| + DCHECK_LT(event, NUM_AUTOFILL_FORM_EVENTS); |
| + std::string name("Autofill.FormEvents."); |
| + if (is_credit_card_) { |
| + name += "CreditCard"; |
| + } else { |
| + name += "Address"; |
| + } |
| + LogUMAHistogramEnumeration(name, event, NUM_AUTOFILL_FORM_EVENTS); |
| + |
| + // Logging again in a different histogram for segmentation purposes. |
| + // TODO(waltercacau): Re-evaluate if we still need such fine grained |
| + // segmentation. |
|
Ilya Sherman
2015/01/31 01:54:05
nit: Please link to the bug that you filed, as "ht
Walter Cacau
2015/02/01 01:19:27
Done.
|
| + if (!is_server_data_available_ && !is_local_data_available_) { |
| + name += ".WithNoData"; |
| + } else if (is_server_data_available_ && !is_local_data_available_) { |
| + name += ".WithOnlyServerData"; |
| + } else if (!is_server_data_available_ && is_local_data_available_) { |
| + name += ".WithOnlyLocalData"; |
| + } else { |
| + name += ".WithBothServerAndLocalData"; |
| + } |
| + LogUMAHistogramEnumeration(name, event, NUM_AUTOFILL_FORM_EVENTS); |
| +} |
| + |
| } // namespace autofill |