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

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

Issue 2808513002: [Payments] Add PaymentRequest checkout funnel UKMs. (Closed)
Patch Set: 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 // The steps of a successful Payment Request.
62 enum CompletionStep {
Mathieu 2017/04/10 01:03:02 Completion is misleading, let's find a better term
sebsg 2017/04/10 15:30:28 Done.
63 STEP_INITIATED = 0,
Mathieu 2017/04/10 01:03:02 had an idea, let me know what you think. if each
sebsg 2017/04/10 15:30:29 Excellent idea! I was thinking that we should add
64 STEP_SHOWN = 1,
65 STEP_PAY_CLICKED = 2,
66 STEP_RECEIVED_INSTRUMENT_DETAILS = 3,
Mathieu 2017/04/10 01:03:02 I would recommend removing the STEP_ prefix from a
sebsg 2017/04/10 15:30:28 Acknowledged.
67 STEP_MAX,
68 };
69
49 // Used to mesure the impact of the CanMakePayment return value on whether the 70 // Used to mesure the impact of the CanMakePayment return value on whether the
50 // Payment Request is shown to the user. 71 // Payment Request is shown to the user.
51 static const int CMP_SHOW_COULD_NOT_MAKE_PAYMENT_AND_DID_NOT_SHOW = 0; 72 static const int CMP_SHOW_COULD_NOT_MAKE_PAYMENT_AND_DID_NOT_SHOW = 0;
52 static const int CMP_SHOW_DID_SHOW = 1 << 0; 73 static const int CMP_SHOW_DID_SHOW = 1 << 0;
53 static const int CMP_SHOW_COULD_MAKE_PAYMENT = 1 << 1; 74 static const int CMP_SHOW_COULD_MAKE_PAYMENT = 1 << 1;
54 static const int CMP_SHOW_MAX = 4; 75 static const int CMP_SHOW_MAX = 4;
55 76
56 explicit JourneyLogger(bool is_incognito); 77 explicit JourneyLogger(bool is_incognito,
Mathieu 2017/04/10 01:03:02 no explicit
sebsg 2017/04/10 15:30:28 Done.
sebsg 2017/04/10 15:30:29 Done.
78 GURL url,
79 ukm::UkmService* ukm_service);
57 ~JourneyLogger(); 80 ~JourneyLogger();
58 81
59 // Increments the number of selection adds for the specified section. 82 // Increments the number of selection adds for the specified section.
60 void IncrementSelectionAdds(Section section); 83 void IncrementSelectionAdds(Section section);
61 84
62 // Increments the number of selection changes for the specified section. 85 // Increments the number of selection changes for the specified section.
63 void IncrementSelectionChanges(Section section); 86 void IncrementSelectionChanges(Section section);
64 87
65 // Increments the number of selection edits for the specified section. 88 // Increments the number of selection edits for the specified section.
66 void IncrementSelectionEdits(Section section); 89 void IncrementSelectionEdits(Section section);
67 90
68 // Sets the number of suggestions shown for the specified section. 91 // Sets the number of suggestions shown for the specified section.
69 void SetNumberOfSuggestionsShown(Section section, int number); 92 void SetNumberOfSuggestionsShown(Section section, int number);
70 93
71 // Records the fact that the merchant called CanMakePayment and records it's 94 // Records the fact that the merchant called CanMakePayment and records it's
72 // return value. 95 // return value.
73 void SetCanMakePaymentValue(bool value); 96 void SetCanMakePaymentValue(bool value);
74 97
75 // Records the fact that the Payment Request was shown to the user. 98 // Records the fact that the Payment Request was shown to the user.
76 void SetShowCalled(); 99 void SetShowCalled();
77 100
101 // Records the steps as they are done.
102 void SetCurrentStep(CompletionStep step);
103
78 // Records the histograms for all the sections that were requested by the 104 // 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 105 // 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 106 // the transaction. This method should be called when the Payment Request has
81 // either been completed or aborted. 107 // either been completed or aborted.
82 void RecordJourneyStatsHistograms(CompletionStatus completion_status); 108 void RecordJourneyStatsHistograms(CompletionStatus completion_status);
83 109
84 private: 110 private:
85 static const int NUMBER_OF_SECTIONS = 3; 111 static const int NUMBER_OF_SECTIONS = 3;
86 112
87 // Note: These constants should always be in sync with their counterpart in 113 // Note: These constants should always be in sync with their counterpart in
(...skipping 30 matching lines...) Expand all
118 144
119 // Records CanMakePayment's return value effect on whether the Payment Request 145 // Records CanMakePayment's return value effect on whether the Payment Request
120 // was shown or not. 146 // was shown or not.
121 void RecordCanMakePaymentEffectOnShow(); 147 void RecordCanMakePaymentEffectOnShow();
122 148
123 // Records the completion status depending on the the usage and return value 149 // Records the completion status depending on the the usage and return value
124 // of the CanMakePaymentMethod. 150 // of the CanMakePaymentMethod.
125 void RecordCanMakePaymentEffectOnCompletion( 151 void RecordCanMakePaymentEffectOnCompletion(
126 CompletionStatus completion_status); 152 CompletionStatus completion_status);
127 153
154 // Records the Payment Request Url Keyed Metrics.
155 void RecordUkms(CompletionStatus completion_status);
Mathieu 2017/04/10 01:03:02 RecordUrlKeyedMetrics is nice and descriptive
sebsg 2017/04/10 15:30:29 Done.
156
128 SectionStats sections_[NUMBER_OF_SECTIONS]; 157 SectionStats sections_[NUMBER_OF_SECTIONS];
129 bool was_can_make_payments_used_; 158 bool was_can_make_payments_used_;
130 bool could_make_payment_; 159 bool could_make_payment_;
131 bool was_show_called_; 160 bool was_show_called_;
132 bool is_incognito_; 161 bool is_incognito_;
133 162
163 CompletionStep current_step_;
164
165 // For the UKMs.
Mathieu 2017/04/10 01:03:02 nit: I don't think we need this line
sebsg 2017/04/10 15:30:28 Done.
sebsg 2017/04/10 15:30:29 Done.
166 GURL url_;
167 ukm::UkmService* ukm_service_;
168
134 DISALLOW_COPY_AND_ASSIGN(JourneyLogger); 169 DISALLOW_COPY_AND_ASSIGN(JourneyLogger);
135 }; 170 };
136 171
137 } // namespace payments 172 } // namespace payments
138 173
139 #endif // COMPONENTS_PAYMENTS_CORE_JOURNEY_LOGGER_H_ 174 #endif // COMPONENTS_PAYMENTS_CORE_JOURNEY_LOGGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698