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

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

Issue 2808513002: [Payments] Add PaymentRequest checkout funnel UKMs. (Closed)
Patch Set: Addressed 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 {
please use gerrit instead 2017/04/10 19:20:03 Put this inside of payments namespace please.
sebsg 2017/04/10 19:49:53 Done.
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 enum Event {
64 EVENT_INITIATED = 0,
65 EVENT_SHOWN = 1 << 0,
66 EVENT_PAY_CLICKED = 1 << 1,
67 EVENT_RECEIVED_INSTRUMENT_DETAILS = 1 << 2,
68 EVENT_MAX = 8,
69 };
70
49 // Used to mesure the impact of the CanMakePayment return value on whether the 71 // Used to mesure the impact of the CanMakePayment return value on whether the
50 // Payment Request is shown to the user. 72 // Payment Request is shown to the user.
51 static const int CMP_SHOW_COULD_NOT_MAKE_PAYMENT_AND_DID_NOT_SHOW = 0; 73 static const int CMP_SHOW_COULD_NOT_MAKE_PAYMENT_AND_DID_NOT_SHOW = 0;
52 static const int CMP_SHOW_DID_SHOW = 1 << 0; 74 static const int CMP_SHOW_DID_SHOW = 1 << 0;
53 static const int CMP_SHOW_COULD_MAKE_PAYMENT = 1 << 1; 75 static const int CMP_SHOW_COULD_MAKE_PAYMENT = 1 << 1;
54 static const int CMP_SHOW_MAX = 4; 76 static const int CMP_SHOW_MAX = 4;
55 77
56 explicit JourneyLogger(bool is_incognito); 78 JourneyLogger(bool is_incognito, GURL url, ukm::UkmService* ukm_service);
please use gerrit instead 2017/04/10 19:20:03 url should be const-ref.
please use gerrit instead 2017/04/10 19:20:03 Add a comment about life time expectations for ukm
sebsg 2017/04/10 19:49:52 Added the comment on the stored pointer, seems lik
sebsg 2017/04/10 19:49:52 Done.
57 ~JourneyLogger(); 79 ~JourneyLogger();
58 80
59 // Increments the number of selection adds for the specified section. 81 // Increments the number of selection adds for the specified section.
60 void IncrementSelectionAdds(Section section); 82 void IncrementSelectionAdds(Section section);
61 83
62 // Increments the number of selection changes for the specified section. 84 // Increments the number of selection changes for the specified section.
63 void IncrementSelectionChanges(Section section); 85 void IncrementSelectionChanges(Section section);
64 86
65 // Increments the number of selection edits for the specified section. 87 // Increments the number of selection edits for the specified section.
66 void IncrementSelectionEdits(Section section); 88 void IncrementSelectionEdits(Section section);
67 89
68 // Sets the number of suggestions shown for the specified section. 90 // Sets the number of suggestions shown for the specified section.
69 void SetNumberOfSuggestionsShown(Section section, int number); 91 void SetNumberOfSuggestionsShown(Section section, int number);
70 92
71 // Records the fact that the merchant called CanMakePayment and records it's 93 // Records the fact that the merchant called CanMakePayment and records it's
72 // return value. 94 // return value.
73 void SetCanMakePaymentValue(bool value); 95 void SetCanMakePaymentValue(bool value);
74 96
75 // Records the fact that the Payment Request was shown to the user. 97 // Records the fact that the Payment Request was shown to the user.
76 void SetShowCalled(); 98 void SetShowCalled();
77 99
100 // Records that an event occurred.
101 void SetEventOccurred(Event event);
102
78 // Records the histograms for all the sections that were requested by the 103 // 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 104 // 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 105 // the transaction. This method should be called when the Payment Request has
81 // either been completed or aborted. 106 // either been completed or aborted.
82 void RecordJourneyStatsHistograms(CompletionStatus completion_status); 107 void RecordJourneyStatsHistograms(CompletionStatus completion_status);
83 108
84 private: 109 private:
85 static const int NUMBER_OF_SECTIONS = 3; 110 static const int NUMBER_OF_SECTIONS = 3;
86 111
87 // Note: These constants should always be in sync with their counterpart in 112 // Note: These constants should always be in sync with their counterpart in
(...skipping 30 matching lines...) Expand all
118 143
119 // Records CanMakePayment's return value effect on whether the Payment Request 144 // Records CanMakePayment's return value effect on whether the Payment Request
120 // was shown or not. 145 // was shown or not.
121 void RecordCanMakePaymentEffectOnShow(); 146 void RecordCanMakePaymentEffectOnShow();
122 147
123 // Records the completion status depending on the the usage and return value 148 // Records the completion status depending on the the usage and return value
124 // of the CanMakePaymentMethod. 149 // of the CanMakePaymentMethod.
125 void RecordCanMakePaymentEffectOnCompletion( 150 void RecordCanMakePaymentEffectOnCompletion(
126 CompletionStatus completion_status); 151 CompletionStatus completion_status);
127 152
153 // Records the Payment Request Url Keyed Metrics.
154 void RecordUrlKeyedMetrics(CompletionStatus completion_status);
155
128 SectionStats sections_[NUMBER_OF_SECTIONS]; 156 SectionStats sections_[NUMBER_OF_SECTIONS];
129 bool was_can_make_payments_used_; 157 bool was_can_make_payments_used_;
130 bool could_make_payment_; 158 bool could_make_payment_;
131 bool was_show_called_; 159 bool was_show_called_;
132 bool is_incognito_; 160 bool is_incognito_;
133 161
162 // Accumulates the many event that have happened during the Payment Request.
Mathieu 2017/04/10 19:03:15 *events
sebsg 2017/04/10 19:49:52 Done.
163 int events_;
164
165 GURL url_;
166 ukm::UkmService* ukm_service_;
167
134 DISALLOW_COPY_AND_ASSIGN(JourneyLogger); 168 DISALLOW_COPY_AND_ASSIGN(JourneyLogger);
135 }; 169 };
136 170
137 } // namespace payments 171 } // namespace payments
138 172
139 #endif // COMPONENTS_PAYMENTS_CORE_JOURNEY_LOGGER_H_ 173 #endif // COMPONENTS_PAYMENTS_CORE_JOURNEY_LOGGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698