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 |
| 731 void AutofillMetrics::FormEventLogger::OnDidPollSuggestions() { |
| 732 if (is_for_credit_card_) { |
| 733 base::RecordAction( |
| 734 base::UserMetricsAction("Autofill_PolledCreditCardSuggestions")); |
| 735 } else { |
| 736 base::RecordAction( |
| 737 base::UserMetricsAction("Autofill_PolledProfileSuggestions")); |
| 738 } |
| 739 } |
| 740 |
728 void AutofillMetrics::FormEventLogger::OnDidShowSuggestions() { | 741 void AutofillMetrics::FormEventLogger::OnDidShowSuggestions() { |
729 Log(AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN); | 742 Log(AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN); |
730 if (!has_logged_suggestions_shown_) { | 743 if (!has_logged_suggestions_shown_) { |
731 has_logged_suggestions_shown_ = true; | 744 has_logged_suggestions_shown_ = true; |
732 Log(AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN_ONCE); | 745 Log(AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN_ONCE); |
733 } | 746 } |
| 747 |
| 748 if (is_for_credit_card_) { |
| 749 base::RecordAction( |
| 750 base::UserMetricsAction("Autofill_ShowedCreditCardSuggestions")); |
| 751 } else { |
| 752 base::RecordAction( |
| 753 base::UserMetricsAction("Autofill_ShowedProfileSuggestions")); |
| 754 } |
734 } | 755 } |
735 | 756 |
736 void AutofillMetrics::FormEventLogger::OnDidSelectMaskedServerCardSuggestion() { | 757 void AutofillMetrics::FormEventLogger::OnDidSelectMaskedServerCardSuggestion() { |
737 DCHECK(is_for_credit_card_); | 758 DCHECK(is_for_credit_card_); |
738 Log(AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED); | 759 Log(AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED); |
739 if (!has_logged_masked_server_card_suggestion_selected_) { | 760 if (!has_logged_masked_server_card_suggestion_selected_) { |
740 has_logged_masked_server_card_suggestion_selected_ = true; | 761 has_logged_masked_server_card_suggestion_selected_ = true; |
741 Log(AutofillMetrics | 762 Log(AutofillMetrics |
742 ::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED_ONCE); | 763 ::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED_ONCE); |
743 } | 764 } |
(...skipping 18 matching lines...) Expand all Loading... |
762 credit_card.record_type() == CreditCard::MASKED_SERVER_CARD; | 783 credit_card.record_type() == CreditCard::MASKED_SERVER_CARD; |
763 if (credit_card.record_type() == CreditCard::MASKED_SERVER_CARD) { | 784 if (credit_card.record_type() == CreditCard::MASKED_SERVER_CARD) { |
764 Log(AutofillMetrics | 785 Log(AutofillMetrics |
765 ::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED_ONCE); | 786 ::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED_ONCE); |
766 } else if (credit_card.record_type() == CreditCard::FULL_SERVER_CARD) { | 787 } else if (credit_card.record_type() == CreditCard::FULL_SERVER_CARD) { |
767 Log(AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_FILLED_ONCE); | 788 Log(AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_FILLED_ONCE); |
768 } else { | 789 } else { |
769 Log(AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED_ONCE); | 790 Log(AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED_ONCE); |
770 } | 791 } |
771 } | 792 } |
| 793 |
| 794 base::RecordAction( |
| 795 base::UserMetricsAction("Autofill_FilledCreditCardSuggestion")); |
772 } | 796 } |
773 | 797 |
774 void AutofillMetrics::FormEventLogger::OnDidFillSuggestion( | 798 void AutofillMetrics::FormEventLogger::OnDidFillSuggestion( |
775 const AutofillProfile& profile) { | 799 const AutofillProfile& profile) { |
776 DCHECK(!is_for_credit_card_); | 800 DCHECK(!is_for_credit_card_); |
777 if (profile.record_type() == AutofillProfile::SERVER_PROFILE) | 801 if (profile.record_type() == AutofillProfile::SERVER_PROFILE) |
778 Log(AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_FILLED); | 802 Log(AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_FILLED); |
779 else | 803 else |
780 Log(AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED); | 804 Log(AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED); |
781 | 805 |
782 if (!has_logged_suggestion_filled_) { | 806 if (!has_logged_suggestion_filled_) { |
783 has_logged_suggestion_filled_ = true; | 807 has_logged_suggestion_filled_ = true; |
784 logged_suggestion_filled_was_server_data_ = | 808 logged_suggestion_filled_was_server_data_ = |
785 profile.record_type() == AutofillProfile::SERVER_PROFILE; | 809 profile.record_type() == AutofillProfile::SERVER_PROFILE; |
786 Log(profile.record_type() == AutofillProfile::SERVER_PROFILE | 810 Log(profile.record_type() == AutofillProfile::SERVER_PROFILE |
787 ? AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_FILLED_ONCE | 811 ? AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_FILLED_ONCE |
788 : AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED_ONCE); | 812 : AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED_ONCE); |
789 } | 813 } |
| 814 |
| 815 base::RecordAction( |
| 816 base::UserMetricsAction("Autofill_FilledProfileSuggestion")); |
790 } | 817 } |
791 | 818 |
792 void AutofillMetrics::FormEventLogger::OnWillSubmitForm() { | 819 void AutofillMetrics::FormEventLogger::OnWillSubmitForm() { |
793 // Not logging this kind of form if we haven't logged a user interaction. | 820 // Not logging this kind of form if we haven't logged a user interaction. |
794 if (!has_logged_interacted_) | 821 if (!has_logged_interacted_) |
795 return; | 822 return; |
796 | 823 |
797 // Not logging twice. | 824 // Not logging twice. |
798 if (has_logged_will_submit_) | 825 if (has_logged_will_submit_) |
799 return; | 826 return; |
800 has_logged_will_submit_ = true; | 827 has_logged_will_submit_ = true; |
801 | 828 |
802 if (!has_logged_suggestion_filled_) { | 829 if (!has_logged_suggestion_filled_) { |
803 Log(AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE); | 830 Log(AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE); |
804 } else if (logged_suggestion_filled_was_masked_server_card_) { | 831 } else if (logged_suggestion_filled_was_masked_server_card_) { |
805 Log(AutofillMetrics:: | 832 Log(AutofillMetrics:: |
806 FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_WILL_SUBMIT_ONCE); | 833 FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_WILL_SUBMIT_ONCE); |
807 } else if (logged_suggestion_filled_was_server_data_) { | 834 } else if (logged_suggestion_filled_was_server_data_) { |
808 Log(AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE); | 835 Log(AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE); |
809 } else { | 836 } else { |
810 Log(AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_WILL_SUBMIT_ONCE); | 837 Log(AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_WILL_SUBMIT_ONCE); |
811 } | 838 } |
| 839 |
| 840 base::RecordAction(base::UserMetricsAction("Autofill_OnWillSubmitForm")); |
812 } | 841 } |
813 | 842 |
814 void AutofillMetrics::FormEventLogger::OnFormSubmitted() { | 843 void AutofillMetrics::FormEventLogger::OnFormSubmitted() { |
815 // Not logging this kind of form if we haven't logged a user interaction. | 844 // Not logging this kind of form if we haven't logged a user interaction. |
816 if (!has_logged_interacted_) | 845 if (!has_logged_interacted_) |
817 return; | 846 return; |
818 | 847 |
819 // Not logging twice. | 848 // Not logging twice. |
820 if (has_logged_submitted_) | 849 if (has_logged_submitted_) |
821 return; | 850 return; |
822 has_logged_submitted_ = true; | 851 has_logged_submitted_ = true; |
823 | 852 |
824 if (!has_logged_suggestion_filled_) { | 853 if (!has_logged_suggestion_filled_) { |
825 Log(AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE); | 854 Log(AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE); |
826 } else if (logged_suggestion_filled_was_masked_server_card_) { | 855 } else if (logged_suggestion_filled_was_masked_server_card_) { |
827 Log(AutofillMetrics | 856 Log(AutofillMetrics |
828 ::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SUBMITTED_ONCE); | 857 ::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SUBMITTED_ONCE); |
829 } else if (logged_suggestion_filled_was_server_data_) { | 858 } else if (logged_suggestion_filled_was_server_data_) { |
830 Log(AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE); | 859 Log(AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE); |
831 } else { | 860 } else { |
832 Log(AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE); | 861 Log(AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE); |
833 } | 862 } |
| 863 |
| 864 base::RecordAction(base::UserMetricsAction("Autofill_FormSubmitted")); |
834 } | 865 } |
835 | 866 |
836 void AutofillMetrics::FormEventLogger::Log(FormEvent event) const { | 867 void AutofillMetrics::FormEventLogger::Log(FormEvent event) const { |
837 DCHECK_LT(event, NUM_FORM_EVENTS); | 868 DCHECK_LT(event, NUM_FORM_EVENTS); |
838 std::string name("Autofill.FormEvents."); | 869 std::string name("Autofill.FormEvents."); |
839 if (is_for_credit_card_) | 870 if (is_for_credit_card_) |
840 name += "CreditCard"; | 871 name += "CreditCard"; |
841 else | 872 else |
842 name += "Address"; | 873 name += "Address"; |
843 LogUMAHistogramEnumeration(name, event, NUM_FORM_EVENTS); | 874 LogUMAHistogramEnumeration(name, event, NUM_FORM_EVENTS); |
844 | 875 |
845 // Logging again in a different histogram for segmentation purposes. | 876 // Logging again in a different histogram for segmentation purposes. |
846 // TODO(waltercacau): Re-evaluate if we still need such fine grained | 877 // TODO(waltercacau): Re-evaluate if we still need such fine grained |
847 // segmentation. http://crbug.com/454018 | 878 // segmentation. http://crbug.com/454018 |
848 if (!is_server_data_available_ && !is_local_data_available_) | 879 if (!is_server_data_available_ && !is_local_data_available_) |
849 name += ".WithNoData"; | 880 name += ".WithNoData"; |
850 else if (is_server_data_available_ && !is_local_data_available_) | 881 else if (is_server_data_available_ && !is_local_data_available_) |
851 name += ".WithOnlyServerData"; | 882 name += ".WithOnlyServerData"; |
852 else if (!is_server_data_available_ && is_local_data_available_) | 883 else if (!is_server_data_available_ && is_local_data_available_) |
853 name += ".WithOnlyLocalData"; | 884 name += ".WithOnlyLocalData"; |
854 else | 885 else |
855 name += ".WithBothServerAndLocalData"; | 886 name += ".WithBothServerAndLocalData"; |
856 LogUMAHistogramEnumeration(name, event, NUM_FORM_EVENTS); | 887 LogUMAHistogramEnumeration(name, event, NUM_FORM_EVENTS); |
857 } | 888 } |
858 | 889 |
859 } // namespace autofill | 890 } // namespace autofill |
OLD | NEW |