| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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() { |
| 729 Log(AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN); | 732 Log(AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN); |
| 730 if (!has_logged_suggestions_shown_) { | 733 if (!has_logged_suggestions_shown_) { |
| 731 has_logged_suggestions_shown_ = true; | 734 has_logged_suggestions_shown_ = true; |
| 732 Log(AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN_ONCE); | 735 Log(AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN_ONCE); |
| 733 } | 736 } |
| 737 |
| 738 if (is_for_credit_card_) { |
| 739 base::RecordAction( |
| 740 base::UserMetricsAction("Autofill_ShowedCreditCardSuggestions")); |
| 741 } else { |
| 742 base::RecordAction( |
| 743 base::UserMetricsAction("Autofill_ShowedProfileSuggestions")); |
| 744 } |
| 734 } | 745 } |
| 735 | 746 |
| 736 void AutofillMetrics::FormEventLogger::OnDidSelectMaskedServerCardSuggestion() { | 747 void AutofillMetrics::FormEventLogger::OnDidSelectMaskedServerCardSuggestion() { |
| 737 DCHECK(is_for_credit_card_); | 748 DCHECK(is_for_credit_card_); |
| 738 Log(AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED); | 749 Log(AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED); |
| 739 if (!has_logged_masked_server_card_suggestion_selected_) { | 750 if (!has_logged_masked_server_card_suggestion_selected_) { |
| 740 has_logged_masked_server_card_suggestion_selected_ = true; | 751 has_logged_masked_server_card_suggestion_selected_ = true; |
| 741 Log(AutofillMetrics | 752 Log(AutofillMetrics |
| 742 ::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED_ONCE); | 753 ::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED_ONCE); |
| 743 } | 754 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 762 credit_card.record_type() == CreditCard::MASKED_SERVER_CARD; | 773 credit_card.record_type() == CreditCard::MASKED_SERVER_CARD; |
| 763 if (credit_card.record_type() == CreditCard::MASKED_SERVER_CARD) { | 774 if (credit_card.record_type() == CreditCard::MASKED_SERVER_CARD) { |
| 764 Log(AutofillMetrics | 775 Log(AutofillMetrics |
| 765 ::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED_ONCE); | 776 ::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED_ONCE); |
| 766 } else if (credit_card.record_type() == CreditCard::FULL_SERVER_CARD) { | 777 } else if (credit_card.record_type() == CreditCard::FULL_SERVER_CARD) { |
| 767 Log(AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_FILLED_ONCE); | 778 Log(AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_FILLED_ONCE); |
| 768 } else { | 779 } else { |
| 769 Log(AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED_ONCE); | 780 Log(AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED_ONCE); |
| 770 } | 781 } |
| 771 } | 782 } |
| 783 |
| 784 base::RecordAction( |
| 785 base::UserMetricsAction("Autofill_FilledCreditCardSuggestion")); |
| 772 } | 786 } |
| 773 | 787 |
| 774 void AutofillMetrics::FormEventLogger::OnDidFillSuggestion( | 788 void AutofillMetrics::FormEventLogger::OnDidFillSuggestion( |
| 775 const AutofillProfile& profile) { | 789 const AutofillProfile& profile) { |
| 776 DCHECK(!is_for_credit_card_); | 790 DCHECK(!is_for_credit_card_); |
| 777 if (profile.record_type() == AutofillProfile::SERVER_PROFILE) | 791 if (profile.record_type() == AutofillProfile::SERVER_PROFILE) |
| 778 Log(AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_FILLED); | 792 Log(AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_FILLED); |
| 779 else | 793 else |
| 780 Log(AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED); | 794 Log(AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED); |
| 781 | 795 |
| 782 if (!has_logged_suggestion_filled_) { | 796 if (!has_logged_suggestion_filled_) { |
| 783 has_logged_suggestion_filled_ = true; | 797 has_logged_suggestion_filled_ = true; |
| 784 logged_suggestion_filled_was_server_data_ = | 798 logged_suggestion_filled_was_server_data_ = |
| 785 profile.record_type() == AutofillProfile::SERVER_PROFILE; | 799 profile.record_type() == AutofillProfile::SERVER_PROFILE; |
| 786 Log(profile.record_type() == AutofillProfile::SERVER_PROFILE | 800 Log(profile.record_type() == AutofillProfile::SERVER_PROFILE |
| 787 ? AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_FILLED_ONCE | 801 ? AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_FILLED_ONCE |
| 788 : AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED_ONCE); | 802 : AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED_ONCE); |
| 789 } | 803 } |
| 804 |
| 805 base::RecordAction( |
| 806 base::UserMetricsAction("Autofill_FilledProfileSuggestion")); |
| 790 } | 807 } |
| 791 | 808 |
| 792 void AutofillMetrics::FormEventLogger::OnWillSubmitForm() { | 809 void AutofillMetrics::FormEventLogger::OnWillSubmitForm() { |
| 793 // Not logging this kind of form if we haven't logged a user interaction. | 810 // Not logging this kind of form if we haven't logged a user interaction. |
| 794 if (!has_logged_interacted_) | 811 if (!has_logged_interacted_) |
| 795 return; | 812 return; |
| 796 | 813 |
| 797 // Not logging twice. | 814 // Not logging twice. |
| 798 if (has_logged_will_submit_) | 815 if (has_logged_will_submit_) |
| 799 return; | 816 return; |
| 800 has_logged_will_submit_ = true; | 817 has_logged_will_submit_ = true; |
| 801 | 818 |
| 802 if (!has_logged_suggestion_filled_) { | 819 if (!has_logged_suggestion_filled_) { |
| 803 Log(AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE); | 820 Log(AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE); |
| 804 } else if (logged_suggestion_filled_was_masked_server_card_) { | 821 } else if (logged_suggestion_filled_was_masked_server_card_) { |
| 805 Log(AutofillMetrics:: | 822 Log(AutofillMetrics:: |
| 806 FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_WILL_SUBMIT_ONCE); | 823 FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_WILL_SUBMIT_ONCE); |
| 807 } else if (logged_suggestion_filled_was_server_data_) { | 824 } else if (logged_suggestion_filled_was_server_data_) { |
| 808 Log(AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE); | 825 Log(AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE); |
| 809 } else { | 826 } else { |
| 810 Log(AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_WILL_SUBMIT_ONCE); | 827 Log(AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_WILL_SUBMIT_ONCE); |
| 811 } | 828 } |
| 829 |
| 830 base::RecordAction(base::UserMetricsAction("Autofill_OnWillSubmitForm")); |
| 812 } | 831 } |
| 813 | 832 |
| 814 void AutofillMetrics::FormEventLogger::OnFormSubmitted() { | 833 void AutofillMetrics::FormEventLogger::OnFormSubmitted() { |
| 815 // Not logging this kind of form if we haven't logged a user interaction. | 834 // Not logging this kind of form if we haven't logged a user interaction. |
| 816 if (!has_logged_interacted_) | 835 if (!has_logged_interacted_) |
| 817 return; | 836 return; |
| 818 | 837 |
| 819 // Not logging twice. | 838 // Not logging twice. |
| 820 if (has_logged_submitted_) | 839 if (has_logged_submitted_) |
| 821 return; | 840 return; |
| 822 has_logged_submitted_ = true; | 841 has_logged_submitted_ = true; |
| 823 | 842 |
| 824 if (!has_logged_suggestion_filled_) { | 843 if (!has_logged_suggestion_filled_) { |
| 825 Log(AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE); | 844 Log(AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE); |
| 826 } else if (logged_suggestion_filled_was_masked_server_card_) { | 845 } else if (logged_suggestion_filled_was_masked_server_card_) { |
| 827 Log(AutofillMetrics | 846 Log(AutofillMetrics |
| 828 ::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SUBMITTED_ONCE); | 847 ::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SUBMITTED_ONCE); |
| 829 } else if (logged_suggestion_filled_was_server_data_) { | 848 } else if (logged_suggestion_filled_was_server_data_) { |
| 830 Log(AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE); | 849 Log(AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE); |
| 831 } else { | 850 } else { |
| 832 Log(AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE); | 851 Log(AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE); |
| 833 } | 852 } |
| 853 |
| 854 base::RecordAction(base::UserMetricsAction("Autofill_FormSubmitted")); |
| 855 } |
| 856 |
| 857 void AutofillMetrics::FormEventLogger::OnDidPollSuggestions() { |
| 858 if (is_for_credit_card_) { |
| 859 base::RecordAction( |
| 860 base::UserMetricsAction("Autofill_PolledCreditCardSuggestions")); |
| 861 } else { |
| 862 base::RecordAction( |
| 863 base::UserMetricsAction("Autofill_PolledProfileSuggestions")); |
| 864 } |
| 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 |