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 different stats during a Payment Request journey. It | |
15 // collects different metrics during the course of the checkout flow, like the | |
16 // number of credit cards that the user added or edited. The metrics will be | |
17 // logged when RecordJourneyStatsHistograms is called with the completion status | |
18 // of the Payment Request. | |
19 class JourneyLogger { | |
20 public: | |
21 // Note: These constants should always be in sync with their counterpart in | |
22 // JourneyLogger.java. | |
please use gerrit instead
2017/03/24 16:31:47
Add a mirror comment in JourneyLogger.java. Use th
sebsg
2017/03/24 18:37:47
Done.
| |
23 // The different sections of a Payment Request. Used to record journey | |
24 // stats. | |
25 enum Sections { | |
please use gerrit instead
2017/03/24 16:31:47
Please use "enum class". Let's use singular "Secti
sebsg
2017/03/24 18:37:47
Unfortunately they have to be implicitly convertib
| |
26 SECTION_CONTACT_INFO = 0, | |
27 SECTION_CREDIT_CARDS = 1, | |
28 SECTION_SHIPPING_ADDRESS = 2, | |
29 SECTION_MAX, | |
30 }; | |
31 | |
32 // For the CanMakePayment histograms. | |
33 enum CanMakePaymentUsage { | |
34 CAN_MAKE_PAYMENT_USED = 0, | |
35 CAN_MAKE_PAYMENT_NOT_USED = 1, | |
36 CAN_MAKE_PAYMENT_USE_MAX, | |
37 }; | |
38 | |
39 // Used to log different parameters' effect on whether the transaction was | |
40 // completed. | |
41 enum CompletionStatus { | |
42 COMPLETION_STATUS_COMPLETED = 0, | |
43 COMPLETION_STATUS_ABORTED = 1, | |
44 COMPLETION_STATUS_MAX, | |
45 }; | |
46 | |
47 // Used to mesure the impact of the CanMakePayment return value on whether the | |
48 // Payment Request is shown to the user. | |
49 static const int CMP_SHOW_COULD_NOT_MAKE_PAYMENT_AND_DID_NOT_SHOW = 0; | |
please use gerrit instead
2017/03/24 16:31:47
Let's use "enum class" here as well.
sebsg
2017/03/24 18:37:47
I thought it was more clear this way. It allows st
| |
50 static const int CMP_SHOW_DID_SHOW = 1 << 0; | |
51 static const int CMP_SHOW_COULD_MAKE_PAYMENT_ = 1 << 1; | |
52 static const int CMP_SHOW_MAX = 4; | |
53 | |
54 JourneyLogger(); | |
55 ~JourneyLogger(); | |
56 | |
57 // Increments the number of selection adds for the specified section. | |
58 void IncrementSelectionAdds(int section); | |
please use gerrit instead
2017/03/24 16:31:47
Use the enum type instead of int. Same below.
sebsg
2017/03/24 18:37:47
Done.
| |
59 | |
60 // Increments the number of selection changes for the specified section. | |
61 void IncrementSelectionChanges(int section); | |
62 | |
63 // Increments the number of selection edits for the specified section. | |
64 void IncrementSelectionEdits(int section); | |
65 | |
66 // Sets the number of suggestions shown for the specified section. | |
67 void SetNumberOfSuggestionsShown(int section, int number); | |
68 | |
69 // Records the fact that the merchant called CanMakePayment and records it's | |
70 // return value. | |
71 void SetCanMakePaymentValue(bool value); | |
72 | |
73 // Records the fact that the Payment Request was shown to the user. | |
74 void SetShowCalled(); | |
75 | |
76 // Records the histograms for all the sections that were requested by the | |
77 // merchant and for the usage of the CanMakePayment method and its effect on | |
78 // the transaction. This method should be called when the Payment Request has | |
79 // either been completed or aborted. | |
80 void RecordJourneyStatsHistograms(const std::string& submission_type); | |
please use gerrit instead
2017/03/24 16:31:47
Why not use an enum here as well?
sebsg
2017/03/24 18:37:47
Done.
| |
81 | |
82 private: | |
83 static const int NUMBER_OF_SECTIONS = 3; | |
84 | |
85 // The minimum expected value of CustomCountHistograms is always set to 1. It | |
86 // is still possible to log the value 0 to that type of histogram. | |
please use gerrit instead
2017/03/24 16:31:47
Note about keeping this in sync with JourneyLogger
sebsg
2017/03/24 18:37:47
Done.
| |
87 const int MIN_EXPECTED_SAMPLE = 1; | |
88 const int MAX_EXPECTED_SAMPLE = 49; | |
89 const int NUMBER_BUCKETS = 50; | |
90 | |
91 struct SectionStats { | |
92 SectionStats() | |
93 : number_selection_adds_(0), | |
94 number_selection_changes_(0), | |
95 number_selection_edits_(0), | |
96 number_suggestions_shown_(0), | |
97 is_requested_(false) {} | |
98 | |
99 int number_selection_adds_; | |
100 int number_selection_changes_; | |
101 int number_selection_edits_; | |
102 int number_suggestions_shown_; | |
103 int is_requested_; | |
please use gerrit instead
2017/03/24 16:31:47
bool
sebsg
2017/03/24 18:37:47
Done.
| |
104 }; | |
105 | |
106 // Records the histograms for all the sections that were requested by the | |
107 // merchant. | |
108 void RecordSectionSpecificStats(const std::string& submission_type); | |
109 | |
110 // Records the metrics related the the CanMakePayment method. | |
111 void RecordCanMakePaymentStats(CompletionStatus completion_status); | |
112 | |
113 // Records CanMakePayment's return value effect on whether the Payment Request | |
114 // was shown or not. | |
115 void RecordCanMakePaymentEffectOnShow(); | |
116 | |
117 // Records the completion status depending on the the usage and return value | |
118 // of the CanMakePaymentMethod. | |
119 void RecordCanMakePaymentEffectOnCompletion( | |
120 CompletionStatus completion_status); | |
121 | |
122 SectionStats sections_[NUMBER_OF_SECTIONS]; | |
123 bool was_can_make_payments_used_; | |
124 bool could_make_payment_; | |
125 bool was_show_called_; | |
126 | |
127 DISALLOW_COPY_AND_ASSIGN(JourneyLogger); | |
128 }; | |
129 | |
130 } // namespace payments | |
131 | |
132 #endif // COMPONENTS_PAYMENTS_CORE_JOURNEY_LOGGER_H_ | |
OLD | NEW |