Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: components/payments/core/journey_logger.h

Issue 2808513002: [Payments] Add PaymentRequest checkout funnel UKMs. (Closed)
Patch Set: Addressed Mathp's comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 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 #ifndef COMPONENTS_PAYMENTS_CORE_JOURNEY_LOGGER_H_ 5 #ifndef COMPONENTS_PAYMENTS_CORE_JOURNEY_LOGGER_H_
6 #define COMPONENTS_PAYMENTS_CORE_JOURNEY_LOGGER_H_ 6 #define COMPONENTS_PAYMENTS_CORE_JOURNEY_LOGGER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "url/gurl.h"
12
13 namespace ukm {
14 class UkmService;
15 }
16
17 namespace internal {
18 // Name constants are exposed here so they can be referenced from tests.
19 extern const char kUKMCheckoutFunnelEntryName[];
20 extern const char kUKMCompletionStatusMetricName[];
21 extern const char kUKMLastStepMetricName[];
22 } // namespace internal
11 23
12 namespace payments { 24 namespace payments {
13 25
14 // A class to keep track of different stats during a Payment Request journey. It 26 // 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 27 // 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 28 // number of credit cards that the user added or edited. The metrics will be
17 // logged when RecordJourneyStatsHistograms is called with the completion status 29 // logged when RecordJourneyStatsHistograms is called with the completion status
18 // of the Payment Request. 30 // of the Payment Request.
19 class JourneyLogger { 31 class JourneyLogger {
20 public: 32 public:
(...skipping 18 matching lines...) Expand all
39 51
40 // Used to log different parameters' effect on whether the transaction was 52 // Used to log different parameters' effect on whether the transaction was
41 // completed. 53 // completed.
42 enum CompletionStatus { 54 enum CompletionStatus {
43 COMPLETION_STATUS_COMPLETED = 0, 55 COMPLETION_STATUS_COMPLETED = 0,
44 COMPLETION_STATUS_USER_ABORTED = 1, 56 COMPLETION_STATUS_USER_ABORTED = 1,
45 COMPLETION_STATUS_OTHER_ABORTED = 2, 57 COMPLETION_STATUS_OTHER_ABORTED = 2,
46 COMPLETION_STATUS_MAX, 58 COMPLETION_STATUS_MAX,
47 }; 59 };
48 60
61 // Used to record the different events that happened during the Payment
62 // Request.
63 static const int EVENT_NOT_SHOWN = 0;
Mathieu 2017/04/10 15:56:18 I liked the enum!
sebsg 2017/04/10 17:27:56 Done.
64 static const int EVENT_SHOWN = 1 << 0;
Mathieu 2017/04/10 15:56:18 same comment about alignment: https://cs.chromium.
sebsg 2017/04/10 17:27:56 Same as above.
65 static const int EVENT_PAY_CLICKED = 1 << 1;
66 static const int EVENT_RECEIVED_INSTRUMENT_DETAILS = 1 << 2;
67 static const int EVENT_MAX = 8;
68
49 // Used to mesure the impact of the CanMakePayment return value on whether the 69 // Used to mesure the impact of the CanMakePayment return value on whether the
50 // Payment Request is shown to the user. 70 // Payment Request is shown to the user.
51 static const int CMP_SHOW_COULD_NOT_MAKE_PAYMENT_AND_DID_NOT_SHOW = 0; 71 static const int CMP_SHOW_COULD_NOT_MAKE_PAYMENT_AND_DID_NOT_SHOW = 0;
52 static const int CMP_SHOW_DID_SHOW = 1 << 0; 72 static const int CMP_SHOW_DID_SHOW = 1 << 0;
53 static const int CMP_SHOW_COULD_MAKE_PAYMENT = 1 << 1; 73 static const int CMP_SHOW_COULD_MAKE_PAYMENT = 1 << 1;
54 static const int CMP_SHOW_MAX = 4; 74 static const int CMP_SHOW_MAX = 4;
55 75
56 explicit JourneyLogger(bool is_incognito); 76 JourneyLogger(bool is_incognito, GURL url, ukm::UkmService* ukm_service);
57 ~JourneyLogger(); 77 ~JourneyLogger();
58 78
59 // Increments the number of selection adds for the specified section. 79 // Increments the number of selection adds for the specified section.
60 void IncrementSelectionAdds(Section section); 80 void IncrementSelectionAdds(Section section);
61 81
62 // Increments the number of selection changes for the specified section. 82 // Increments the number of selection changes for the specified section.
63 void IncrementSelectionChanges(Section section); 83 void IncrementSelectionChanges(Section section);
64 84
65 // Increments the number of selection edits for the specified section. 85 // Increments the number of selection edits for the specified section.
66 void IncrementSelectionEdits(Section section); 86 void IncrementSelectionEdits(Section section);
67 87
68 // Sets the number of suggestions shown for the specified section. 88 // Sets the number of suggestions shown for the specified section.
69 void SetNumberOfSuggestionsShown(Section section, int number); 89 void SetNumberOfSuggestionsShown(Section section, int number);
70 90
71 // Records the fact that the merchant called CanMakePayment and records it's 91 // Records the fact that the merchant called CanMakePayment and records it's
72 // return value. 92 // return value.
73 void SetCanMakePaymentValue(bool value); 93 void SetCanMakePaymentValue(bool value);
74 94
75 // Records the fact that the Payment Request was shown to the user. 95 // Records the fact that the Payment Request was shown to the user.
76 void SetShowCalled(); 96 void SetShowCalled();
77 97
98 // Records that an event occured.
99 void SetEventOccured(int event);
100
78 // Records the histograms for all the sections that were requested by the 101 // Records the histograms for all the sections that were requested by the
79 // merchant and for the usage of the CanMakePayment method and its effect on 102 // merchant and for the usage of the CanMakePayment method and its effect on
80 // the transaction. This method should be called when the Payment Request has 103 // the transaction. This method should be called when the Payment Request has
81 // either been completed or aborted. 104 // either been completed or aborted.
82 void RecordJourneyStatsHistograms(CompletionStatus completion_status); 105 void RecordJourneyStatsHistograms(CompletionStatus completion_status);
83 106
84 private: 107 private:
85 static const int NUMBER_OF_SECTIONS = 3; 108 static const int NUMBER_OF_SECTIONS = 3;
86 109
87 // Note: These constants should always be in sync with their counterpart in 110 // Note: These constants should always be in sync with their counterpart in
(...skipping 30 matching lines...) Expand all
118 141
119 // Records CanMakePayment's return value effect on whether the Payment Request 142 // Records CanMakePayment's return value effect on whether the Payment Request
120 // was shown or not. 143 // was shown or not.
121 void RecordCanMakePaymentEffectOnShow(); 144 void RecordCanMakePaymentEffectOnShow();
122 145
123 // Records the completion status depending on the the usage and return value 146 // Records the completion status depending on the the usage and return value
124 // of the CanMakePaymentMethod. 147 // of the CanMakePaymentMethod.
125 void RecordCanMakePaymentEffectOnCompletion( 148 void RecordCanMakePaymentEffectOnCompletion(
126 CompletionStatus completion_status); 149 CompletionStatus completion_status);
127 150
151 // Records the Payment Request Url Keyed Metrics.
152 void RecordUrlKeyedMetrics(CompletionStatus completion_status);
153
128 SectionStats sections_[NUMBER_OF_SECTIONS]; 154 SectionStats sections_[NUMBER_OF_SECTIONS];
129 bool was_can_make_payments_used_; 155 bool was_can_make_payments_used_;
130 bool could_make_payment_; 156 bool could_make_payment_;
131 bool was_show_called_; 157 bool was_show_called_;
132 bool is_incognito_; 158 bool is_incognito_;
133 159
160 int events_;
Mathieu 2017/04/10 15:56:18 Add a comment talking about what it's doing and wh
sebsg 2017/04/10 17:27:56 Done.
161
162 GURL url_;
163 ukm::UkmService* ukm_service_;
164
134 DISALLOW_COPY_AND_ASSIGN(JourneyLogger); 165 DISALLOW_COPY_AND_ASSIGN(JourneyLogger);
135 }; 166 };
136 167
137 } // namespace payments 168 } // namespace payments
138 169
139 #endif // COMPONENTS_PAYMENTS_CORE_JOURNEY_LOGGER_H_ 170 #endif // COMPONENTS_PAYMENTS_CORE_JOURNEY_LOGGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698