Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_PAYMENTS_CORE_JOURNEY_LOGGER_H_ | |
| 6 #define COMPONENTS_PAYMENTS_CORE_JOURNEY_LOGGER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 | |
| 12 namespace payments { | |
| 13 | |
| 14 // A class to keep track of of different stats during a Payment Request journey. | |
|
Mathieu
2017/03/23 21:19:48
nit: of of
Mathieu
2017/03/23 21:19:48
can you mention the usage a little bit? Also, ment
sebsg
2017/03/24 13:35:30
Done.
sebsg
2017/03/24 13:35:30
Done.
| |
| 15 class JourneyLogger { | |
| 16 public: | |
| 17 // The the different sections of a Payment Request. Used to record journey | |
|
Mathieu
2017/03/23 21:19:48
nit: the the
sebsg
2017/03/24 13:35:30
Done.
| |
| 18 // stats. | |
| 19 enum Sections { | |
| 20 SECTION_CONTACT_INFO = 0, | |
| 21 SECTION_CREDIT_CARDS, | |
| 22 SECTION_SHIPPING_ADDRESS, | |
| 23 SECTION_MAX, | |
| 24 }; | |
| 25 | |
| 26 // For the CanMakePayment histograms. | |
| 27 enum CanMakePaymentUsage { | |
| 28 CAN_MAKE_PAYMENT_USED = 0, | |
| 29 CAN_MAKE_PAYMENT_NOT_USED, | |
| 30 CAN_MAKE_PAYMENT_USE_MAX, | |
| 31 }; | |
| 32 | |
| 33 // Used to log different parameters' effect on whether the transaction was | |
| 34 // completed. | |
| 35 static const int COMPLETION_STATUS_COMPLETED = 0; | |
| 36 static const int COMPLETION_STATUS_ABORTED = 1; | |
| 37 static const int COMPLETION_STATUS_MAX = 2; | |
| 38 | |
| 39 // Used to mesure the impact of the CanMakePayment return value on whether the | |
| 40 // Payment Request is shown to the user. | |
| 41 static const int CMP_SHOW_COULD_NOT_MAKE_PAYMENT_AND_DID_NOT_SHOW = 0; | |
| 42 static const int CMP_SHOW_DID_SHOW = 1 << 0; | |
| 43 static const int CMP_SHOW_could_make_payment_ = 1 << 1; | |
|
Mathieu
2017/03/23 21:19:48
fix
sebsg
2017/03/24 13:35:29
Done.
| |
| 44 static const int CMP_SHOW_MAX = 4; | |
| 45 | |
| 46 JourneyLogger(); | |
| 47 ~JourneyLogger(){}; | |
|
Mathieu
2017/03/23 21:19:48
nit: ~JourneyLogger(); and implement in cc
sebsg
2017/03/24 13:35:30
Done.
| |
| 48 | |
| 49 // Increments the number of selection adds for the specified section. | |
| 50 void IncrementSelectionAdds(int section); | |
| 51 | |
| 52 // Increments the number of selection changes for the specified section. | |
| 53 void IncrementSelectionChanges(int section); | |
| 54 | |
| 55 // Increments the number of selection edits for the specified section. | |
| 56 void IncrementSelectionEdits(int section); | |
| 57 | |
| 58 // Sets the number of suggestions shown for the specified section. | |
| 59 void SetNumberOfSuggestionsShown(int section, int number); | |
| 60 | |
| 61 // Records the fact that the merchant called CanMakePayment and records it's | |
| 62 // return value. | |
| 63 void SetCanMakePaymentValue(bool value); | |
| 64 | |
| 65 // Records the fact that the Payment Request was shown to the user. | |
| 66 void SetShowCalled(); | |
| 67 | |
| 68 // Records the histograms for all the sections that were requested by the | |
| 69 // merchant and for the usage of the CanMakePayment method and its effect on | |
| 70 // the transaction. This method should be called when the Payment Request has | |
| 71 // either been completed or aborted. | |
| 72 void RecordJourneyStatsHistograms(const std::string& submission_type); | |
| 73 | |
| 74 private: | |
| 75 static const int NUMBER_OF_SECTIONS = 3; | |
| 76 | |
| 77 // The minimum expected value of CustomCountHistograms is always set to 1. It | |
| 78 // is still possible to log the value 0 to that type of histogram. | |
| 79 const int MIN_EXPECTED_SAMPLE = 1; | |
| 80 const int MAX_EXPECTED_SAMPLE = 49; | |
| 81 const int NUMBER_BUCKETS = 50; | |
| 82 | |
| 83 class SectionStats { | |
|
Mathieu
2017/03/23 21:19:49
struct?
sebsg
2017/03/24 13:35:29
Done.
| |
| 84 public: | |
| 85 SectionStats() | |
| 86 : number_selection_adds_(0), | |
| 87 number_selection_changes_(0), | |
| 88 number_selection_edits_(0), | |
| 89 number_suggestions_shown_(0), | |
| 90 is_requested_(false) {} | |
| 91 | |
| 92 int number_selection_adds_; | |
| 93 int number_selection_changes_; | |
| 94 int number_selection_edits_; | |
| 95 int number_suggestions_shown_; | |
| 96 int is_requested_; | |
| 97 }; | |
| 98 | |
| 99 // Records the histograms for all the sections that were requested by the | |
| 100 // merchant. | |
| 101 void RecordSectionSpecificStats(const std::string& submission_type); | |
| 102 | |
| 103 // Records the metrics related the the CanMakePayment method. | |
| 104 void RecordCanMakePaymentStats(int completion_status); | |
| 105 | |
| 106 // Records CanMakePayment's return value effect on whether the Payment Request | |
| 107 // was shown or not. | |
| 108 void RecordCanMakePaymentEffectOnShow(); | |
| 109 | |
| 110 // Records the completion status depending on the the usage and return value | |
| 111 // of the CanMakePaymentMethod. | |
| 112 void RecordCanMakePaymentEffectOnCompletion(int completion_status); | |
| 113 | |
| 114 SectionStats sections_[NUMBER_OF_SECTIONS]; | |
| 115 bool was_can_make_payments_used_; | |
| 116 bool could_make_payment_; | |
| 117 bool was_show_called_; | |
| 118 | |
| 119 DISALLOW_COPY_AND_ASSIGN(JourneyLogger); | |
| 120 }; | |
| 121 | |
| 122 } // namespace payments | |
| 123 | |
| 124 #endif // COMPONENTS_PAYMENTS_CORE_JOURNEY_LOGGER_H_ | |
| OLD | NEW |