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 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
11 #include "base/metrics/sparse_histogram.h" | 11 #include "base/metrics/sparse_histogram.h" |
12 #include "base/metrics/user_metrics.h" | |
12 #include "base/time/time.h" | 13 #include "base/time/time.h" |
13 #include "components/autofill/core/browser/autofill_type.h" | 14 #include "components/autofill/core/browser/autofill_type.h" |
14 #include "components/autofill/core/browser/form_structure.h" | 15 #include "components/autofill/core/browser/form_structure.h" |
15 #include "components/autofill/core/common/form_data.h" | 16 #include "components/autofill/core/common/form_data.h" |
16 | 17 |
17 namespace autofill { | 18 namespace autofill { |
18 | 19 |
19 namespace { | 20 namespace { |
20 | 21 |
21 enum FieldTypeGroupForMetrics { | 22 enum FieldTypeGroupForMetrics { |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
643 // static | 644 // static |
644 void AutofillMetrics::LogAddressSuggestionsCount(size_t num_suggestions) { | 645 void AutofillMetrics::LogAddressSuggestionsCount(size_t num_suggestions) { |
645 UMA_HISTOGRAM_COUNTS("Autofill.AddressSuggestionsCount", num_suggestions); | 646 UMA_HISTOGRAM_COUNTS("Autofill.AddressSuggestionsCount", num_suggestions); |
646 } | 647 } |
647 | 648 |
648 // static | 649 // static |
649 void AutofillMetrics::LogAutofillSuggestionAcceptedIndex(int index) { | 650 void AutofillMetrics::LogAutofillSuggestionAcceptedIndex(int index) { |
650 // A maximum of 50 is enforced to minimize the number of buckets generated. | 651 // A maximum of 50 is enforced to minimize the number of buckets generated. |
651 UMA_HISTOGRAM_SPARSE_SLOWLY("Autofill.SuggestionAcceptedIndex", | 652 UMA_HISTOGRAM_SPARSE_SLOWLY("Autofill.SuggestionAcceptedIndex", |
652 std::min(index, 50)); | 653 std::min(index, 50)); |
654 | |
655 base::RecordAction(base::UserMetricsAction("Autofill_SelectedSuggestion")); | |
653 } | 656 } |
654 | 657 |
655 // static | 658 // static |
656 void AutofillMetrics::LogAutocompleteSuggestionAcceptedIndex(int index) { | 659 void AutofillMetrics::LogAutocompleteSuggestionAcceptedIndex(int index) { |
657 // A maximum of 50 is enforced to minimize the number of buckets generated. | 660 // A maximum of 50 is enforced to minimize the number of buckets generated. |
658 UMA_HISTOGRAM_SPARSE_SLOWLY("Autofill.SuggestionAcceptedIndex.Autocomplete", | 661 UMA_HISTOGRAM_SPARSE_SLOWLY("Autofill.SuggestionAcceptedIndex.Autocomplete", |
659 std::min(index, 50)); | 662 std::min(index, 50)); |
660 } | 663 } |
661 | 664 |
662 // static | 665 // static |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
718 logged_suggestion_filled_was_masked_server_card_(false) { | 721 logged_suggestion_filled_was_masked_server_card_(false) { |
719 } | 722 } |
720 | 723 |
721 void AutofillMetrics::FormEventLogger::OnDidInteractWithAutofillableForm() { | 724 void AutofillMetrics::FormEventLogger::OnDidInteractWithAutofillableForm() { |
722 if (!has_logged_interacted_) { | 725 if (!has_logged_interacted_) { |
723 has_logged_interacted_ = true; | 726 has_logged_interacted_ = true; |
724 Log(AutofillMetrics::FORM_EVENT_INTERACTED_ONCE); | 727 Log(AutofillMetrics::FORM_EVENT_INTERACTED_ONCE); |
725 } | 728 } |
726 } | 729 } |
727 | 730 |
728 void AutofillMetrics::FormEventLogger::OnDidShowSuggestions() { | 731 void AutofillMetrics::FormEventLogger::OnDidShowSuggestions( |
732 bool is_credit_card) { | |
729 Log(AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN); | 733 Log(AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN); |
730 if (!has_logged_suggestions_shown_) { | 734 if (!has_logged_suggestions_shown_) { |
Mathieu
2016/04/11 16:45:45
I'm wondering if the action log should be put in t
sebsg
2016/04/12 14:40:59
Done.
| |
731 has_logged_suggestions_shown_ = true; | 735 has_logged_suggestions_shown_ = true; |
732 Log(AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN_ONCE); | 736 Log(AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN_ONCE); |
737 | |
738 if (is_credit_card) { | |
739 base::RecordAction( | |
740 base::UserMetricsAction("Autofill_ShowedCreditCardSuggestions")); | |
741 } else { | |
742 base::RecordAction( | |
743 base::UserMetricsAction("Autofill_ShowedProfileSuggestions")); | |
744 } | |
733 } | 745 } |
734 } | 746 } |
735 | 747 |
736 void AutofillMetrics::FormEventLogger::OnDidSelectMaskedServerCardSuggestion() { | 748 void AutofillMetrics::FormEventLogger::OnDidSelectMaskedServerCardSuggestion() { |
737 DCHECK(is_for_credit_card_); | 749 DCHECK(is_for_credit_card_); |
738 Log(AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED); | 750 Log(AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED); |
739 if (!has_logged_masked_server_card_suggestion_selected_) { | 751 if (!has_logged_masked_server_card_suggestion_selected_) { |
740 has_logged_masked_server_card_suggestion_selected_ = true; | 752 has_logged_masked_server_card_suggestion_selected_ = true; |
741 Log(AutofillMetrics | 753 Log(AutofillMetrics |
742 ::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED_ONCE); | 754 ::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED_ONCE); |
(...skipping 19 matching lines...) Expand all Loading... | |
762 credit_card.record_type() == CreditCard::MASKED_SERVER_CARD; | 774 credit_card.record_type() == CreditCard::MASKED_SERVER_CARD; |
763 if (credit_card.record_type() == CreditCard::MASKED_SERVER_CARD) { | 775 if (credit_card.record_type() == CreditCard::MASKED_SERVER_CARD) { |
764 Log(AutofillMetrics | 776 Log(AutofillMetrics |
765 ::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED_ONCE); | 777 ::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED_ONCE); |
766 } else if (credit_card.record_type() == CreditCard::FULL_SERVER_CARD) { | 778 } else if (credit_card.record_type() == CreditCard::FULL_SERVER_CARD) { |
767 Log(AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_FILLED_ONCE); | 779 Log(AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_FILLED_ONCE); |
768 } else { | 780 } else { |
769 Log(AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED_ONCE); | 781 Log(AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED_ONCE); |
770 } | 782 } |
771 } | 783 } |
784 | |
785 base::RecordAction( | |
786 base::UserMetricsAction("Autofill_FilledCreditCardSuggestion")); | |
772 } | 787 } |
773 | 788 |
774 void AutofillMetrics::FormEventLogger::OnDidFillSuggestion( | 789 void AutofillMetrics::FormEventLogger::OnDidFillSuggestion( |
775 const AutofillProfile& profile) { | 790 const AutofillProfile& profile) { |
776 DCHECK(!is_for_credit_card_); | 791 DCHECK(!is_for_credit_card_); |
777 if (profile.record_type() == AutofillProfile::SERVER_PROFILE) | 792 if (profile.record_type() == AutofillProfile::SERVER_PROFILE) |
778 Log(AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_FILLED); | 793 Log(AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_FILLED); |
779 else | 794 else |
780 Log(AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED); | 795 Log(AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED); |
781 | 796 |
782 if (!has_logged_suggestion_filled_) { | 797 if (!has_logged_suggestion_filled_) { |
783 has_logged_suggestion_filled_ = true; | 798 has_logged_suggestion_filled_ = true; |
784 logged_suggestion_filled_was_server_data_ = | 799 logged_suggestion_filled_was_server_data_ = |
785 profile.record_type() == AutofillProfile::SERVER_PROFILE; | 800 profile.record_type() == AutofillProfile::SERVER_PROFILE; |
786 Log(profile.record_type() == AutofillProfile::SERVER_PROFILE | 801 Log(profile.record_type() == AutofillProfile::SERVER_PROFILE |
787 ? AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_FILLED_ONCE | 802 ? AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_FILLED_ONCE |
788 : AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED_ONCE); | 803 : AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED_ONCE); |
789 } | 804 } |
805 | |
806 base::RecordAction( | |
807 base::UserMetricsAction("Autofill_FilledProfileSuggestion")); | |
790 } | 808 } |
791 | 809 |
792 void AutofillMetrics::FormEventLogger::OnWillSubmitForm() { | 810 void AutofillMetrics::FormEventLogger::OnWillSubmitForm() { |
793 // Not logging this kind of form if we haven't logged a user interaction. | 811 // Not logging this kind of form if we haven't logged a user interaction. |
794 if (!has_logged_interacted_) | 812 if (!has_logged_interacted_) |
795 return; | 813 return; |
796 | 814 |
797 // Not logging twice. | 815 // Not logging twice. |
798 if (has_logged_will_submit_) | 816 if (has_logged_will_submit_) |
799 return; | 817 return; |
800 has_logged_will_submit_ = true; | 818 has_logged_will_submit_ = true; |
801 | 819 |
802 if (!has_logged_suggestion_filled_) { | 820 if (!has_logged_suggestion_filled_) { |
803 Log(AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE); | 821 Log(AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE); |
804 } else if (logged_suggestion_filled_was_masked_server_card_) { | 822 } else if (logged_suggestion_filled_was_masked_server_card_) { |
805 Log(AutofillMetrics:: | 823 Log(AutofillMetrics:: |
806 FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_WILL_SUBMIT_ONCE); | 824 FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_WILL_SUBMIT_ONCE); |
807 } else if (logged_suggestion_filled_was_server_data_) { | 825 } else if (logged_suggestion_filled_was_server_data_) { |
808 Log(AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE); | 826 Log(AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE); |
809 } else { | 827 } else { |
810 Log(AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_WILL_SUBMIT_ONCE); | 828 Log(AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_WILL_SUBMIT_ONCE); |
811 } | 829 } |
Mathieu
2016/04/11 16:45:46
Can you add OnWillSubmitForm action too? Not all f
sebsg
2016/04/12 14:40:59
Done.
| |
812 } | 830 } |
813 | 831 |
814 void AutofillMetrics::FormEventLogger::OnFormSubmitted() { | 832 void AutofillMetrics::FormEventLogger::OnFormSubmitted() { |
815 // Not logging this kind of form if we haven't logged a user interaction. | 833 // Not logging this kind of form if we haven't logged a user interaction. |
816 if (!has_logged_interacted_) | 834 if (!has_logged_interacted_) |
817 return; | 835 return; |
818 | 836 |
819 // Not logging twice. | 837 // Not logging twice. |
820 if (has_logged_submitted_) | 838 if (has_logged_submitted_) |
821 return; | 839 return; |
822 has_logged_submitted_ = true; | 840 has_logged_submitted_ = true; |
823 | 841 |
824 if (!has_logged_suggestion_filled_) { | 842 if (!has_logged_suggestion_filled_) { |
825 Log(AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE); | 843 Log(AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE); |
826 } else if (logged_suggestion_filled_was_masked_server_card_) { | 844 } else if (logged_suggestion_filled_was_masked_server_card_) { |
827 Log(AutofillMetrics | 845 Log(AutofillMetrics |
828 ::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SUBMITTED_ONCE); | 846 ::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SUBMITTED_ONCE); |
829 } else if (logged_suggestion_filled_was_server_data_) { | 847 } else if (logged_suggestion_filled_was_server_data_) { |
830 Log(AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE); | 848 Log(AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE); |
831 } else { | 849 } else { |
832 Log(AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE); | 850 Log(AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE); |
833 } | 851 } |
852 | |
853 base::RecordAction(base::UserMetricsAction("Autofill_FormSubmitted")); | |
834 } | 854 } |
835 | 855 |
836 void AutofillMetrics::FormEventLogger::Log(FormEvent event) const { | 856 void AutofillMetrics::FormEventLogger::Log(FormEvent event) const { |
837 DCHECK_LT(event, NUM_FORM_EVENTS); | 857 DCHECK_LT(event, NUM_FORM_EVENTS); |
838 std::string name("Autofill.FormEvents."); | 858 std::string name("Autofill.FormEvents."); |
839 if (is_for_credit_card_) | 859 if (is_for_credit_card_) |
840 name += "CreditCard"; | 860 name += "CreditCard"; |
841 else | 861 else |
842 name += "Address"; | 862 name += "Address"; |
843 LogUMAHistogramEnumeration(name, event, NUM_FORM_EVENTS); | 863 LogUMAHistogramEnumeration(name, event, NUM_FORM_EVENTS); |
844 | 864 |
845 // Logging again in a different histogram for segmentation purposes. | 865 // Logging again in a different histogram for segmentation purposes. |
846 // TODO(waltercacau): Re-evaluate if we still need such fine grained | 866 // TODO(waltercacau): Re-evaluate if we still need such fine grained |
847 // segmentation. http://crbug.com/454018 | 867 // segmentation. http://crbug.com/454018 |
848 if (!is_server_data_available_ && !is_local_data_available_) | 868 if (!is_server_data_available_ && !is_local_data_available_) |
849 name += ".WithNoData"; | 869 name += ".WithNoData"; |
850 else if (is_server_data_available_ && !is_local_data_available_) | 870 else if (is_server_data_available_ && !is_local_data_available_) |
851 name += ".WithOnlyServerData"; | 871 name += ".WithOnlyServerData"; |
852 else if (!is_server_data_available_ && is_local_data_available_) | 872 else if (!is_server_data_available_ && is_local_data_available_) |
853 name += ".WithOnlyLocalData"; | 873 name += ".WithOnlyLocalData"; |
854 else | 874 else |
855 name += ".WithBothServerAndLocalData"; | 875 name += ".WithBothServerAndLocalData"; |
856 LogUMAHistogramEnumeration(name, event, NUM_FORM_EVENTS); | 876 LogUMAHistogramEnumeration(name, event, NUM_FORM_EVENTS); |
857 } | 877 } |
858 | 878 |
859 } // namespace autofill | 879 } // namespace autofill |
OLD | NEW |