Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Side by Side Diff: components/autofill/core/browser/autofill_metrics.cc

Issue 2839063004: [Autofill] UKM for suggestions polled field. (Closed)
Patch Set: Address comments. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 13 matching lines...) Expand all
24 const char kUKMCardUploadDecisionEntryName[] = "Autofill.CardUploadDecision"; 24 const char kUKMCardUploadDecisionEntryName[] = "Autofill.CardUploadDecision";
25 const char kUKMCardUploadDecisionMetricName[] = "UploadDecision"; 25 const char kUKMCardUploadDecisionMetricName[] = "UploadDecision";
26 const char kUKMDeveloperEngagementEntryName[] = "Autofill.DeveloperEngagement"; 26 const char kUKMDeveloperEngagementEntryName[] = "Autofill.DeveloperEngagement";
27 const char kUKMDeveloperEngagementMetricName[] = "DeveloperEngagement"; 27 const char kUKMDeveloperEngagementMetricName[] = "DeveloperEngagement";
28 const char kUKMMillisecondsSinceFormLoadedMetricName[] = 28 const char kUKMMillisecondsSinceFormLoadedMetricName[] =
29 "MillisecondsSinceFormLoaded"; 29 "MillisecondsSinceFormLoaded";
30 const char kUKMInteractedWithFormEntryName[] = "Autofill.InteractedWithForm"; 30 const char kUKMInteractedWithFormEntryName[] = "Autofill.InteractedWithForm";
31 const char kUKMIsForCreditCardMetricName[] = "IsForCreditCard"; 31 const char kUKMIsForCreditCardMetricName[] = "IsForCreditCard";
32 const char kUKMLocalRecordTypeCountMetricName[] = "LocalRecordTypeCount"; 32 const char kUKMLocalRecordTypeCountMetricName[] = "LocalRecordTypeCount";
33 const char kUKMServerRecordTypeCountMetricName[] = "ServerRecordTypeCount"; 33 const char kUKMServerRecordTypeCountMetricName[] = "ServerRecordTypeCount";
34 const char kUKMPollSuggestionsEntryName[] = "PollSuggestions";
34 const char kUKMSuggestionsShownEntryName[] = "Autofill.SuggestionsShown"; 35 const char kUKMSuggestionsShownEntryName[] = "Autofill.SuggestionsShown";
35 const char kUKMSelectedMaskedServerCardEntryName[] = 36 const char kUKMSelectedMaskedServerCardEntryName[] =
36 "Autofill.SelectedMaskedServerCard"; 37 "Autofill.SelectedMaskedServerCard";
37 const char kUKMSuggestionFilledEntryName[] = "Autofill.SuggestionFilled"; 38 const char kUKMSuggestionFilledEntryName[] = "Autofill.SuggestionFilled";
38 const char kUKMRecordTypeMetricName[] = "RecordType"; 39 const char kUKMRecordTypeMetricName[] = "RecordType";
39 const char kUKMTextFieldDidChangeEntryName[] = "Autofill.TextFieldDidChange"; 40 const char kUKMTextFieldDidChangeEntryName[] = "Autofill.TextFieldDidChange";
40 const char kUKMFieldTypeGroupMetricName[] = "FieldTypeGroup"; 41 const char kUKMFieldTypeGroupMetricName[] = "FieldTypeGroup";
41 const char kUKMHeuristicTypeMetricName[] = "HeuristicType"; 42 const char kUKMHeuristicTypeMetricName[] = "HeuristicType";
42 const char kUKMServerTypeMetricName[] = "ServerType"; 43 const char kUKMServerTypeMetricName[] = "ServerType";
43 const char kUKMHtmlFieldTypeMetricName[] = "HtmlFieldType"; 44 const char kUKMHtmlFieldTypeMetricName[] = "HtmlFieldType";
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 if (!has_logged_interacted_) { 798 if (!has_logged_interacted_) {
798 has_logged_interacted_ = true; 799 has_logged_interacted_ = true;
799 form_interactions_ukm_logger_->LogInteractedWithForm( 800 form_interactions_ukm_logger_->LogInteractedWithForm(
800 is_for_credit_card_, local_record_type_count_, 801 is_for_credit_card_, local_record_type_count_,
801 server_record_type_count_); 802 server_record_type_count_);
802 Log(AutofillMetrics::FORM_EVENT_INTERACTED_ONCE); 803 Log(AutofillMetrics::FORM_EVENT_INTERACTED_ONCE);
803 } 804 }
804 } 805 }
805 806
806 void AutofillMetrics::FormEventLogger::OnDidPollSuggestions( 807 void AutofillMetrics::FormEventLogger::OnDidPollSuggestions(
807 const FormFieldData& field) { 808 const FormFieldData& field,
809 const AutofillField& autofill_field) {
808 // Record only one poll user action for consecutive polls of the same field. 810 // Record only one poll user action for consecutive polls of the same field.
809 // This is to avoid recording too many poll actions (for example when a user 811 // This is to avoid recording too many poll actions (for example when a user
810 // types in a field, triggering multiple queries) to make the analysis more 812 // types in a field, triggering multiple queries) to make the analysis more
811 // simple. 813 // simple.
812 if (!field.SameFieldAs(last_polled_field_)) { 814 if (!field.SameFieldAs(last_polled_field_)) {
815 form_interactions_ukm_logger_->LogPollSuggestions(autofill_field);
816
813 if (is_for_credit_card_) { 817 if (is_for_credit_card_) {
814 base::RecordAction( 818 base::RecordAction(
815 base::UserMetricsAction("Autofill_PolledCreditCardSuggestions")); 819 base::UserMetricsAction("Autofill_PolledCreditCardSuggestions"));
816 } else { 820 } else {
817 base::RecordAction( 821 base::RecordAction(
818 base::UserMetricsAction("Autofill_PolledProfileSuggestions")); 822 base::UserMetricsAction("Autofill_PolledProfileSuggestions"));
819 } 823 }
820 824
821 last_polled_field_ = field; 825 last_polled_field_ = field;
822 } 826 }
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 std::unique_ptr<ukm::UkmEntryBuilder> builder = ukm_service_->GetEntryBuilder( 1025 std::unique_ptr<ukm::UkmEntryBuilder> builder = ukm_service_->GetEntryBuilder(
1022 source_id_, internal::kUKMInteractedWithFormEntryName); 1026 source_id_, internal::kUKMInteractedWithFormEntryName);
1023 builder->AddMetric(internal::kUKMIsForCreditCardMetricName, 1027 builder->AddMetric(internal::kUKMIsForCreditCardMetricName,
1024 is_for_credit_card); 1028 is_for_credit_card);
1025 builder->AddMetric(internal::kUKMLocalRecordTypeCountMetricName, 1029 builder->AddMetric(internal::kUKMLocalRecordTypeCountMetricName,
1026 local_record_type_count); 1030 local_record_type_count);
1027 builder->AddMetric(internal::kUKMServerRecordTypeCountMetricName, 1031 builder->AddMetric(internal::kUKMServerRecordTypeCountMetricName,
1028 server_record_type_count); 1032 server_record_type_count);
1029 } 1033 }
1030 1034
1035 void AutofillMetrics::FormInteractionsUkmLogger::LogPollSuggestions(
1036 const AutofillField& field) {
1037 if (!CanLog())
1038 return;
1039
1040 if (source_id_ == -1)
1041 GetNewSourceID();
1042
1043 std::unique_ptr<ukm::UkmEntryBuilder> builder = ukm_service_->GetEntryBuilder(
1044 source_id_, internal::kUKMPollSuggestionsEntryName);
1045 builder->AddMetric(internal::kUKMMillisecondsSinceFormLoadedMetricName,
1046 MillisecondsSinceFormLoaded());
1047 builder->AddMetric(internal::kUKMHeuristicTypeMetricName,
1048 static_cast<int>(field.heuristic_type()));
1049 builder->AddMetric(internal::kUKMServerTypeMetricName,
1050 static_cast<int>(field.server_type()));
1051 builder->AddMetric(internal::kUKMHtmlFieldTypeMetricName,
1052 static_cast<int>(field.html_type()));
1053 }
1054
1031 void AutofillMetrics::FormInteractionsUkmLogger::LogSuggestionsShown() { 1055 void AutofillMetrics::FormInteractionsUkmLogger::LogSuggestionsShown() {
1032 if (!CanLog()) 1056 if (!CanLog())
1033 return; 1057 return;
1034 1058
1035 if (source_id_ == -1) 1059 if (source_id_ == -1)
1036 GetNewSourceID(); 1060 GetNewSourceID();
1037 1061
1038 std::unique_ptr<ukm::UkmEntryBuilder> builder = ukm_service_->GetEntryBuilder( 1062 std::unique_ptr<ukm::UkmEntryBuilder> builder = ukm_service_->GetEntryBuilder(
1039 source_id_, internal::kUKMSuggestionsShownEntryName); 1063 source_id_, internal::kUKMSuggestionsShownEntryName);
1040 builder->AddMetric(internal::kUKMMillisecondsSinceFormLoadedMetricName, 1064 builder->AddMetric(internal::kUKMMillisecondsSinceFormLoadedMetricName,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 DCHECK(!form_loaded_timestamp_.is_null()); 1152 DCHECK(!form_loaded_timestamp_.is_null());
1129 return (base::TimeTicks::Now() - form_loaded_timestamp_).InMilliseconds(); 1153 return (base::TimeTicks::Now() - form_loaded_timestamp_).InMilliseconds();
1130 } 1154 }
1131 1155
1132 void AutofillMetrics::FormInteractionsUkmLogger::GetNewSourceID() { 1156 void AutofillMetrics::FormInteractionsUkmLogger::GetNewSourceID() {
1133 source_id_ = ukm_service_->GetNewSourceID(); 1157 source_id_ = ukm_service_->GetNewSourceID();
1134 ukm_service_->UpdateSourceURL(source_id_, url_); 1158 ukm_service_->UpdateSourceURL(source_id_, url_);
1135 } 1159 }
1136 1160
1137 } // namespace autofill 1161 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698