| OLD | NEW |
| 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" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 // Request. | 62 // Request. |
| 63 enum Event { | 63 enum Event { |
| 64 EVENT_INITIATED = 0, | 64 EVENT_INITIATED = 0, |
| 65 EVENT_SHOWN = 1 << 0, | 65 EVENT_SHOWN = 1 << 0, |
| 66 EVENT_PAY_CLICKED = 1 << 1, | 66 EVENT_PAY_CLICKED = 1 << 1, |
| 67 EVENT_RECEIVED_INSTRUMENT_DETAILS = 1 << 2, | 67 EVENT_RECEIVED_INSTRUMENT_DETAILS = 1 << 2, |
| 68 EVENT_SKIPPED_SHOW = 1 << 3, | 68 EVENT_SKIPPED_SHOW = 1 << 3, |
| 69 EVENT_ENUM_MAX = 16, | 69 EVENT_ENUM_MAX = 16, |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 enum AbortReason { |
| 73 ABORT_REASON_ABORTED_BY_USER = 0, |
| 74 ABORT_REASON_ABORTED_BY_MERCHANT = 1, |
| 75 ABORT_REASON_INVALID_DATA_FROM_RENDERER = 2, |
| 76 ABORT_REASON_MOJO_CONNECTION_ERROR = 3, |
| 77 ABORT_REASON_MOJO_RENDERER_CLOSING = 4, |
| 78 ABORT_REASON_INSTRUMENT_DETAILS_ERROR = 5, |
| 79 ABORT_REASON_NO_MATCHING_PAYMENT_METHOD = 6, // Deprecated. |
| 80 ABORT_REASON_NO_SUPPORTED_PAYMENT_METHOD = 7, // Deprecated. |
| 81 ABORT_REASON_OTHER = 8, |
| 82 ABORT_REASON_MAX, |
| 83 }; |
| 84 |
| 85 #ifdef OS_ANDROID |
| 86 enum NotShownReason { |
| 87 NOT_SHOWN_NO_MATCHING_PAYMENT_METHOD = 0, |
| 88 NOT_SHOWN_NO_SUPPORTED_PAYMENT_METHOD = 1, |
| 89 NOT_SHOWN_CONCURRENT_REQUESTS = 2, |
| 90 NOT_SHOWN_REASON_OTHER = 3, |
| 91 NOT_SHOWN_REASON_MAX = 4, |
| 92 }; |
| 93 #endif |
| 94 |
| 72 // Used to mesure the impact of the CanMakePayment return value on whether the | 95 // Used to mesure the impact of the CanMakePayment return value on whether the |
| 73 // Payment Request is shown to the user. | 96 // Payment Request is shown to the user. |
| 74 static const int CMP_SHOW_COULD_NOT_MAKE_PAYMENT_AND_DID_NOT_SHOW = 0; | 97 static const int CMP_SHOW_COULD_NOT_MAKE_PAYMENT_AND_DID_NOT_SHOW = 0; |
| 75 static const int CMP_SHOW_DID_SHOW = 1 << 0; | 98 static const int CMP_SHOW_DID_SHOW = 1 << 0; |
| 76 static const int CMP_SHOW_COULD_MAKE_PAYMENT = 1 << 1; | 99 static const int CMP_SHOW_COULD_MAKE_PAYMENT = 1 << 1; |
| 77 static const int CMP_SHOW_MAX = 4; | 100 static const int CMP_SHOW_MAX = 4; |
| 78 | 101 |
| 79 JourneyLogger(bool is_incognito, | 102 JourneyLogger(bool is_incognito, |
| 80 const GURL& url, | 103 const GURL& url, |
| 81 ukm::UkmRecorder* ukm_recorder); | 104 ukm::UkmRecorder* ukm_recorder); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 96 // Records the fact that the merchant called CanMakePayment and records it's | 119 // Records the fact that the merchant called CanMakePayment and records it's |
| 97 // return value. | 120 // return value. |
| 98 void SetCanMakePaymentValue(bool value); | 121 void SetCanMakePaymentValue(bool value); |
| 99 | 122 |
| 100 // Records the fact that the Payment Request was shown to the user. | 123 // Records the fact that the Payment Request was shown to the user. |
| 101 void SetShowCalled(); | 124 void SetShowCalled(); |
| 102 | 125 |
| 103 // Records that an event occurred. | 126 // Records that an event occurred. |
| 104 void SetEventOccurred(Event event); | 127 void SetEventOccurred(Event event); |
| 105 | 128 |
| 106 // Records the histograms for all the sections that were requested by the | 129 // Records that the Payment Request was completed successfully, and starts the |
| 107 // merchant and for the usage of the CanMakePayment method and its effect on | 130 // logging of all the journey metrics. |
| 108 // the transaction. This method should be called when the Payment Request has | 131 void SetCompleted(); |
| 109 // either been completed or aborted. | 132 |
| 110 void RecordJourneyStatsHistograms(CompletionStatus completion_status); | 133 // Records that the Payment Request was aborted along with the reason. Also |
| 134 // starts the logging of all the journey metrics. |
| 135 void SetAborted(AbortReason reason); |
| 136 |
| 137 #ifdef OS_ANDROID |
| 138 // Records that the Payment Request was not shown to the user, along with the |
| 139 // reason. |
| 140 void SetNotShown(NotShownReason reason); |
| 141 #endif |
| 111 | 142 |
| 112 private: | 143 private: |
| 113 static const int NUMBER_OF_SECTIONS = 3; | 144 static const int NUMBER_OF_SECTIONS = 3; |
| 114 | 145 |
| 115 // Note: These constants should always be in sync with their counterpart in | 146 // Note: These constants should always be in sync with their counterpart in |
| 116 // components/payments/content/android/java/src/org/chromium/components/ | 147 // components/payments/content/android/java/src/org/chromium/components/ |
| 117 // payments/JourneyLogger.java. | 148 // payments/JourneyLogger.java. |
| 118 // The minimum expected value of CustomCountHistograms is always set to 1. It | 149 // The minimum expected value of CustomCountHistograms is always set to 1. It |
| 119 // is still possible to log the value 0 to that type of histogram. | 150 // is still possible to log the value 0 to that type of histogram. |
| 120 const int MIN_EXPECTED_SAMPLE = 1; | 151 const int MIN_EXPECTED_SAMPLE = 1; |
| 121 const int MAX_EXPECTED_SAMPLE = 49; | 152 const int MAX_EXPECTED_SAMPLE = 49; |
| 122 const int NUMBER_BUCKETS = 50; | 153 const int NUMBER_BUCKETS = 50; |
| 123 | 154 |
| 124 struct SectionStats { | 155 struct SectionStats { |
| 125 SectionStats() | 156 SectionStats() |
| 126 : number_selection_adds_(0), | 157 : number_selection_adds_(0), |
| 127 number_selection_changes_(0), | 158 number_selection_changes_(0), |
| 128 number_selection_edits_(0), | 159 number_selection_edits_(0), |
| 129 number_suggestions_shown_(0), | 160 number_suggestions_shown_(0), |
| 130 is_requested_(false) {} | 161 is_requested_(false) {} |
| 131 | 162 |
| 132 int number_selection_adds_; | 163 int number_selection_adds_; |
| 133 int number_selection_changes_; | 164 int number_selection_changes_; |
| 134 int number_selection_edits_; | 165 int number_selection_edits_; |
| 135 int number_suggestions_shown_; | 166 int number_suggestions_shown_; |
| 136 bool is_requested_; | 167 bool is_requested_; |
| 137 }; | 168 }; |
| 138 | 169 |
| 170 // Records the histograms for all the sections that were requested by the |
| 171 // merchant and for the usage of the CanMakePayment method and its effect on |
| 172 // the transaction. This method should be called when the Payment Request has |
| 173 // either been completed or aborted. |
| 174 void RecordJourneyStatsHistograms(CompletionStatus completion_status); |
| 175 |
| 139 // Records the histograms for all the steps of a complete checkout flow that | 176 // Records the histograms for all the steps of a complete checkout flow that |
| 140 // were reached. | 177 // were reached. |
| 141 void RecordCheckoutFlowMetrics(); | 178 void RecordCheckoutFlowMetrics(); |
| 142 | 179 |
| 143 // Records the histograms for all the sections that were requested by the | 180 // Records the histograms for all the sections that were requested by the |
| 144 // merchant. | 181 // merchant. |
| 145 void RecordSectionSpecificStats(CompletionStatus completion_status); | 182 void RecordSectionSpecificStats(CompletionStatus completion_status); |
| 146 | 183 |
| 147 // Records the metrics related the the CanMakePayment method unless in | 184 // Records the metrics related the the CanMakePayment method unless in |
| 148 // incognito mode. | 185 // incognito mode. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 174 | 211 |
| 175 // Not owned, will outlive this object. | 212 // Not owned, will outlive this object. |
| 176 ukm::UkmRecorder* ukm_recorder_; | 213 ukm::UkmRecorder* ukm_recorder_; |
| 177 | 214 |
| 178 DISALLOW_COPY_AND_ASSIGN(JourneyLogger); | 215 DISALLOW_COPY_AND_ASSIGN(JourneyLogger); |
| 179 }; | 216 }; |
| 180 | 217 |
| 181 } // namespace payments | 218 } // namespace payments |
| 182 | 219 |
| 183 #endif // COMPONENTS_PAYMENTS_CORE_JOURNEY_LOGGER_H_ | 220 #endif // COMPONENTS_PAYMENTS_CORE_JOURNEY_LOGGER_H_ |
| OLD | NEW |