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 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
978 : is_for_credit_card_(is_for_credit_card), | 978 : is_for_credit_card_(is_for_credit_card), |
979 server_record_type_count_(0), | 979 server_record_type_count_(0), |
980 local_record_type_count_(0), | 980 local_record_type_count_(0), |
981 is_context_secure_(false), | 981 is_context_secure_(false), |
982 has_logged_interacted_(false), | 982 has_logged_interacted_(false), |
983 has_logged_suggestions_shown_(false), | 983 has_logged_suggestions_shown_(false), |
984 has_logged_masked_server_card_suggestion_selected_(false), | 984 has_logged_masked_server_card_suggestion_selected_(false), |
985 has_logged_suggestion_filled_(false), | 985 has_logged_suggestion_filled_(false), |
986 has_logged_will_submit_(false), | 986 has_logged_will_submit_(false), |
987 has_logged_submitted_(false), | 987 has_logged_submitted_(false), |
| 988 has_logged_bank_name_available_(false), |
988 logged_suggestion_filled_was_server_data_(false), | 989 logged_suggestion_filled_was_server_data_(false), |
989 logged_suggestion_filled_was_masked_server_card_(false), | 990 logged_suggestion_filled_was_masked_server_card_(false), |
990 form_interactions_ukm_logger_(form_interactions_ukm_logger) {} | 991 form_interactions_ukm_logger_(form_interactions_ukm_logger) {} |
991 | 992 |
992 void AutofillMetrics::FormEventLogger::OnDidInteractWithAutofillableForm() { | 993 void AutofillMetrics::FormEventLogger::OnDidInteractWithAutofillableForm() { |
993 if (!has_logged_interacted_) { | 994 if (!has_logged_interacted_) { |
994 has_logged_interacted_ = true; | 995 has_logged_interacted_ = true; |
995 form_interactions_ukm_logger_->LogInteractedWithForm( | 996 form_interactions_ukm_logger_->LogInteractedWithForm( |
996 is_for_credit_card_, local_record_type_count_, | 997 is_for_credit_card_, local_record_type_count_, |
997 server_record_type_count_); | 998 server_record_type_count_); |
(...skipping 21 matching lines...) Expand all Loading... |
1019 } | 1020 } |
1020 | 1021 |
1021 void AutofillMetrics::FormEventLogger::OnDidShowSuggestions( | 1022 void AutofillMetrics::FormEventLogger::OnDidShowSuggestions( |
1022 const AutofillField& field) { | 1023 const AutofillField& field) { |
1023 form_interactions_ukm_logger_->LogSuggestionsShown(field); | 1024 form_interactions_ukm_logger_->LogSuggestionsShown(field); |
1024 | 1025 |
1025 Log(AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN); | 1026 Log(AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN); |
1026 if (!has_logged_suggestions_shown_) { | 1027 if (!has_logged_suggestions_shown_) { |
1027 has_logged_suggestions_shown_ = true; | 1028 has_logged_suggestions_shown_ = true; |
1028 Log(AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN_ONCE); | 1029 Log(AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN_ONCE); |
| 1030 if (has_logged_bank_name_available_) { |
| 1031 Log(AutofillMetrics:: |
| 1032 FORM_EVENT_SUGGESTIONS_SHOWN_WITH_BANK_NAME_AVAILABLE_ONCE); |
| 1033 } |
1029 } | 1034 } |
1030 | 1035 |
1031 if (is_for_credit_card_) { | 1036 if (is_for_credit_card_) { |
1032 base::RecordAction( | 1037 base::RecordAction( |
1033 base::UserMetricsAction("Autofill_ShowedCreditCardSuggestions")); | 1038 base::UserMetricsAction("Autofill_ShowedCreditCardSuggestions")); |
1034 } else { | 1039 } else { |
1035 base::RecordAction( | 1040 base::RecordAction( |
1036 base::UserMetricsAction("Autofill_ShowedProfileSuggestions")); | 1041 base::UserMetricsAction("Autofill_ShowedProfileSuggestions")); |
1037 } | 1042 } |
1038 } | 1043 } |
(...skipping 28 matching lines...) Expand all Loading... |
1067 logged_suggestion_filled_was_server_data_ = | 1072 logged_suggestion_filled_was_server_data_ = |
1068 credit_card.record_type() == CreditCard::MASKED_SERVER_CARD || | 1073 credit_card.record_type() == CreditCard::MASKED_SERVER_CARD || |
1069 credit_card.record_type() == CreditCard::FULL_SERVER_CARD; | 1074 credit_card.record_type() == CreditCard::FULL_SERVER_CARD; |
1070 logged_suggestion_filled_was_masked_server_card_ = | 1075 logged_suggestion_filled_was_masked_server_card_ = |
1071 credit_card.record_type() == CreditCard::MASKED_SERVER_CARD; | 1076 credit_card.record_type() == CreditCard::MASKED_SERVER_CARD; |
1072 if (credit_card.record_type() == CreditCard::MASKED_SERVER_CARD) { | 1077 if (credit_card.record_type() == CreditCard::MASKED_SERVER_CARD) { |
1073 Log(AutofillMetrics:: | 1078 Log(AutofillMetrics:: |
1074 FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED_ONCE); | 1079 FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED_ONCE); |
1075 } else if (credit_card.record_type() == CreditCard::FULL_SERVER_CARD) { | 1080 } else if (credit_card.record_type() == CreditCard::FULL_SERVER_CARD) { |
1076 Log(AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_FILLED_ONCE); | 1081 Log(AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_FILLED_ONCE); |
| 1082 if (has_logged_bank_name_available_) { |
| 1083 Log(AutofillMetrics:: |
| 1084 FORM_EVENT_SERVER_SUGGESTION_FILLED_WITH_BANK_NAME_AVAILABLE_ONCE); |
| 1085 } |
1077 } else { | 1086 } else { |
1078 Log(AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED_ONCE); | 1087 Log(AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED_ONCE); |
1079 } | 1088 } |
1080 } | 1089 } |
1081 | 1090 |
1082 base::RecordAction( | 1091 base::RecordAction( |
1083 base::UserMetricsAction("Autofill_FilledCreditCardSuggestion")); | 1092 base::UserMetricsAction("Autofill_FilledCreditCardSuggestion")); |
1084 } | 1093 } |
1085 | 1094 |
1086 void AutofillMetrics::FormEventLogger::OnDidFillSuggestion( | 1095 void AutofillMetrics::FormEventLogger::OnDidFillSuggestion( |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1154 Log(AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE); | 1163 Log(AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE); |
1155 } else { | 1164 } else { |
1156 Log(AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE); | 1165 Log(AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE); |
1157 } | 1166 } |
1158 | 1167 |
1159 if (has_logged_suggestions_shown_) { | 1168 if (has_logged_suggestions_shown_) { |
1160 Log(AutofillMetrics::FORM_EVENT_SUGGESTION_SHOWN_SUBMITTED_ONCE); | 1169 Log(AutofillMetrics::FORM_EVENT_SUGGESTION_SHOWN_SUBMITTED_ONCE); |
1161 } | 1170 } |
1162 } | 1171 } |
1163 | 1172 |
| 1173 void AutofillMetrics::FormEventLogger::SetBankNameAvailable() { |
| 1174 has_logged_bank_name_available_ = true; |
| 1175 } |
| 1176 |
1164 void AutofillMetrics::FormEventLogger::Log(FormEvent event) const { | 1177 void AutofillMetrics::FormEventLogger::Log(FormEvent event) const { |
1165 DCHECK_LT(event, NUM_FORM_EVENTS); | 1178 DCHECK_LT(event, NUM_FORM_EVENTS); |
1166 std::string name("Autofill.FormEvents."); | 1179 std::string name("Autofill.FormEvents."); |
1167 if (is_for_credit_card_) | 1180 if (is_for_credit_card_) |
1168 name += "CreditCard"; | 1181 name += "CreditCard"; |
1169 else | 1182 else |
1170 name += "Address"; | 1183 name += "Address"; |
1171 LogUMAHistogramEnumeration(name, event, NUM_FORM_EVENTS); | 1184 LogUMAHistogramEnumeration(name, event, NUM_FORM_EVENTS); |
1172 | 1185 |
1173 // Log again in a different histogram for credit card forms on nonsecure | 1186 // Log again in a different histogram for credit card forms on nonsecure |
(...skipping 11 matching lines...) Expand all Loading... |
1185 name += ".WithNoData"; | 1198 name += ".WithNoData"; |
1186 else if (server_record_type_count_ > 0 && local_record_type_count_ == 0) | 1199 else if (server_record_type_count_ > 0 && local_record_type_count_ == 0) |
1187 name += ".WithOnlyServerData"; | 1200 name += ".WithOnlyServerData"; |
1188 else if (server_record_type_count_ == 0 && local_record_type_count_ > 0) | 1201 else if (server_record_type_count_ == 0 && local_record_type_count_ > 0) |
1189 name += ".WithOnlyLocalData"; | 1202 name += ".WithOnlyLocalData"; |
1190 else | 1203 else |
1191 name += ".WithBothServerAndLocalData"; | 1204 name += ".WithBothServerAndLocalData"; |
1192 LogUMAHistogramEnumeration(name, event, NUM_FORM_EVENTS); | 1205 LogUMAHistogramEnumeration(name, event, NUM_FORM_EVENTS); |
1193 } | 1206 } |
1194 | 1207 |
| 1208 void AutofillMetrics::FormEventLogger::Log( |
| 1209 BankNameExperimentFormEvent event) const { |
| 1210 DCHECK_LT(event, BANK_NAME_NUM_FORM_EVENTS); |
| 1211 std::string name("Autofill.FormEvents.CreditCard.BankNameExperiment"); |
| 1212 LogUMAHistogramEnumeration(name, event, BANK_NAME_NUM_FORM_EVENTS); |
| 1213 } |
| 1214 |
1195 AutofillMetrics::FormInteractionsUkmLogger::FormInteractionsUkmLogger( | 1215 AutofillMetrics::FormInteractionsUkmLogger::FormInteractionsUkmLogger( |
1196 ukm::UkmRecorder* ukm_recorder) | 1216 ukm::UkmRecorder* ukm_recorder) |
1197 : ukm_recorder_(ukm_recorder) {} | 1217 : ukm_recorder_(ukm_recorder) {} |
1198 | 1218 |
1199 void AutofillMetrics::FormInteractionsUkmLogger::OnFormsParsed( | 1219 void AutofillMetrics::FormInteractionsUkmLogger::OnFormsParsed( |
1200 const GURL& url) { | 1220 const GURL& url) { |
1201 if (ukm_recorder_ == nullptr) | 1221 if (ukm_recorder_ == nullptr) |
1202 return; | 1222 return; |
1203 | 1223 |
1204 url_ = url; | 1224 url_ = url; |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1343 DCHECK(!form_parsed_timestamp_.is_null()); | 1363 DCHECK(!form_parsed_timestamp_.is_null()); |
1344 return (base::TimeTicks::Now() - form_parsed_timestamp_).InMilliseconds(); | 1364 return (base::TimeTicks::Now() - form_parsed_timestamp_).InMilliseconds(); |
1345 } | 1365 } |
1346 | 1366 |
1347 void AutofillMetrics::FormInteractionsUkmLogger::GetNewSourceID() { | 1367 void AutofillMetrics::FormInteractionsUkmLogger::GetNewSourceID() { |
1348 source_id_ = ukm_recorder_->GetNewSourceID(); | 1368 source_id_ = ukm_recorder_->GetNewSourceID(); |
1349 ukm_recorder_->UpdateSourceURL(source_id_, url_); | 1369 ukm_recorder_->UpdateSourceURL(source_id_, url_); |
1350 } | 1370 } |
1351 | 1371 |
1352 } // namespace autofill | 1372 } // namespace autofill |
OLD | NEW |