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