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

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

Issue 2750103005: [Payments] Move journey logger to native. (Closed)
Patch Set: Add the component_jni_registrar files 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
« no previous file with comments | « components/payments/core/BUILD.gn ('k') | components/payments/core/journey_logger.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 // components/payments/content/android/java/src/org/chromium/components/
23 // payments/JourneyLogger.java.
24 // The different sections of a Payment Request. Used to record journey
25 // stats.
26 enum Section {
27 SECTION_CONTACT_INFO = 0,
28 SECTION_CREDIT_CARDS = 1,
29 SECTION_SHIPPING_ADDRESS = 2,
30 SECTION_MAX,
31 };
32
33 // For the CanMakePayment histograms.
34 enum CanMakePaymentUsage {
35 CAN_MAKE_PAYMENT_USED = 0,
36 CAN_MAKE_PAYMENT_NOT_USED = 1,
37 CAN_MAKE_PAYMENT_USE_MAX,
38 };
39
40 // Used to log different parameters' effect on whether the transaction was
41 // completed.
42 enum CompletionStatus {
43 COMPLETION_STATUS_COMPLETED = 0,
44 COMPLETION_STATUS_USER_ABORTED = 1,
45 COMPLETION_STATUS_OTHER_ABORTED = 2,
46 COMPLETION_STATUS_MAX,
47 };
48
49 // Used to mesure the impact of the CanMakePayment return value on whether the
50 // Payment Request is shown to the user.
51 static const int CMP_SHOW_COULD_NOT_MAKE_PAYMENT_AND_DID_NOT_SHOW = 0;
52 static const int CMP_SHOW_DID_SHOW = 1 << 0;
53 static const int CMP_SHOW_COULD_MAKE_PAYMENT_ = 1 << 1;
54 static const int CMP_SHOW_MAX = 4;
55
56 JourneyLogger();
57 ~JourneyLogger();
58
59 // Increments the number of selection adds for the specified section.
60 void IncrementSelectionAdds(Section section);
61
62 // Increments the number of selection changes for the specified section.
63 void IncrementSelectionChanges(Section section);
64
65 // Increments the number of selection edits for the specified section.
66 void IncrementSelectionEdits(Section section);
67
68 // Sets the number of suggestions shown for the specified section.
69 void SetNumberOfSuggestionsShown(Section section, int number);
70
71 // Records the fact that the merchant called CanMakePayment and records it's
72 // return value.
73 void SetCanMakePaymentValue(bool value);
74
75 // Records the fact that the Payment Request was shown to the user.
76 void SetShowCalled();
77
78 // 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
80 // the transaction. This method should be called when the Payment Request has
81 // either been completed or aborted.
82 void RecordJourneyStatsHistograms(CompletionStatus completion_status);
83
84 private:
85 static const int NUMBER_OF_SECTIONS = 3;
86
87 // Note: These constants should always be in sync with their counterpart in
88 // components/payments/content/android/java/src/org/chromium/components/
89 // payments/JourneyLogger.java.
90 // The minimum expected value of CustomCountHistograms is always set to 1. It
91 // is still possible to log the value 0 to that type of histogram.
92 const int MIN_EXPECTED_SAMPLE = 1;
93 const int MAX_EXPECTED_SAMPLE = 49;
94 const int NUMBER_BUCKETS = 50;
95
96 struct SectionStats {
97 SectionStats()
98 : number_selection_adds_(0),
99 number_selection_changes_(0),
100 number_selection_edits_(0),
101 number_suggestions_shown_(0),
102 is_requested_(false) {}
103
104 int number_selection_adds_;
105 int number_selection_changes_;
106 int number_selection_edits_;
107 int number_suggestions_shown_;
108 bool is_requested_;
109 };
110
111 // Records the histograms for all the sections that were requested by the
112 // merchant.
113 void RecordSectionSpecificStats(CompletionStatus completion_status);
114
115 // Records the metrics related the the CanMakePayment method.
116 void RecordCanMakePaymentStats(CompletionStatus completion_status);
117
118 // Records CanMakePayment's return value effect on whether the Payment Request
119 // was shown or not.
120 void RecordCanMakePaymentEffectOnShow();
121
122 // Records the completion status depending on the the usage and return value
123 // of the CanMakePaymentMethod.
124 void RecordCanMakePaymentEffectOnCompletion(
125 CompletionStatus completion_status);
126
127 SectionStats sections_[NUMBER_OF_SECTIONS];
128 bool was_can_make_payments_used_;
129 bool could_make_payment_;
130 bool was_show_called_;
131
132 DISALLOW_COPY_AND_ASSIGN(JourneyLogger);
133 };
134
135 } // namespace payments
136
137 #endif // COMPONENTS_PAYMENTS_CORE_JOURNEY_LOGGER_H_
OLDNEW
« no previous file with comments | « components/payments/core/BUILD.gn ('k') | components/payments/core/journey_logger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698