| 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 #include "components/payments/core/journey_logger.h" | 5 #include "components/payments/core/journey_logger.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/metrics/histogram_functions.h" | 9 #include "base/metrics/histogram_functions.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 // Record that that Payment Request was initiated here, because nothing else | 130 // Record that that Payment Request was initiated here, because nothing else |
| 131 // will be recorded for a Payment Request that was not shown to the user. | 131 // will be recorded for a Payment Request that was not shown to the user. |
| 132 UMA_HISTOGRAM_BOOLEAN("PaymentRequest.CheckoutFunnel.Initiated", true); | 132 UMA_HISTOGRAM_BOOLEAN("PaymentRequest.CheckoutFunnel.Initiated", true); |
| 133 } | 133 } |
| 134 #endif | 134 #endif |
| 135 | 135 |
| 136 void JourneyLogger::SetEventOccurred(Event event) { | 136 void JourneyLogger::SetEventOccurred(Event event) { |
| 137 events_ |= event; | 137 events_ |= event; |
| 138 } | 138 } |
| 139 | 139 |
| 140 void JourneyLogger::SetSelectedPaymentMethod( |
| 141 SelectedPaymentMethod payment_method) { |
| 142 payment_method_ = payment_method; |
| 143 } |
| 144 |
| 140 void JourneyLogger::RecordJourneyStatsHistograms( | 145 void JourneyLogger::RecordJourneyStatsHistograms( |
| 141 CompletionStatus completion_status) { | 146 CompletionStatus completion_status) { |
| 142 DCHECK(!has_recorded_); | 147 DCHECK(!has_recorded_); |
| 143 has_recorded_ = true; | 148 has_recorded_ = true; |
| 144 | 149 |
| 145 RecordCheckoutFlowMetrics(); | 150 RecordCheckoutFlowMetrics(); |
| 146 | 151 |
| 152 RecordPaymentMethodMetric(); |
| 153 |
| 147 RecordSectionSpecificStats(completion_status); | 154 RecordSectionSpecificStats(completion_status); |
| 148 | 155 |
| 149 // Record the CanMakePayment metrics based on whether the transaction was | 156 // Record the CanMakePayment metrics based on whether the transaction was |
| 150 // completed or aborted by the user (UserAborted) or otherwise (OtherAborted). | 157 // completed or aborted by the user (UserAborted) or otherwise (OtherAborted). |
| 151 RecordCanMakePaymentStats(completion_status); | 158 RecordCanMakePaymentStats(completion_status); |
| 152 | 159 |
| 153 RecordUrlKeyedMetrics(completion_status); | 160 RecordUrlKeyedMetrics(completion_status); |
| 154 } | 161 } |
| 155 | 162 |
| 156 void JourneyLogger::RecordCheckoutFlowMetrics() { | 163 void JourneyLogger::RecordCheckoutFlowMetrics() { |
| 157 UMA_HISTOGRAM_BOOLEAN("PaymentRequest.CheckoutFunnel.Initiated", true); | 164 UMA_HISTOGRAM_BOOLEAN("PaymentRequest.CheckoutFunnel.Initiated", true); |
| 158 | 165 |
| 159 if (events_ & EVENT_SHOWN) | 166 if (events_ & EVENT_SHOWN) |
| 160 UMA_HISTOGRAM_BOOLEAN("PaymentRequest.CheckoutFunnel.Shown", true); | 167 UMA_HISTOGRAM_BOOLEAN("PaymentRequest.CheckoutFunnel.Shown", true); |
| 161 | 168 |
| 162 if (events_ & EVENT_PAY_CLICKED) | 169 if (events_ & EVENT_PAY_CLICKED) |
| 163 UMA_HISTOGRAM_BOOLEAN("PaymentRequest.CheckoutFunnel.PayClicked", true); | 170 UMA_HISTOGRAM_BOOLEAN("PaymentRequest.CheckoutFunnel.PayClicked", true); |
| 164 | 171 |
| 165 if (events_ & EVENT_RECEIVED_INSTRUMENT_DETAILS) | 172 if (events_ & EVENT_RECEIVED_INSTRUMENT_DETAILS) |
| 166 UMA_HISTOGRAM_BOOLEAN( | 173 UMA_HISTOGRAM_BOOLEAN( |
| 167 "PaymentRequest.CheckoutFunnel.ReceivedInstrumentDetails", true); | 174 "PaymentRequest.CheckoutFunnel.ReceivedInstrumentDetails", true); |
| 168 | 175 |
| 169 if (events_ & EVENT_SKIPPED_SHOW) | 176 if (events_ & EVENT_SKIPPED_SHOW) |
| 170 UMA_HISTOGRAM_BOOLEAN("PaymentRequest.CheckoutFunnel.SkippedShow", true); | 177 UMA_HISTOGRAM_BOOLEAN("PaymentRequest.CheckoutFunnel.SkippedShow", true); |
| 171 } | 178 } |
| 172 | 179 |
| 180 void JourneyLogger::RecordPaymentMethodMetric() { |
| 181 base::UmaHistogramEnumeration("PaymentRequest.SelectedPaymentMethod", |
| 182 payment_method_, SELECTED_PAYMENT_METHOD_MAX); |
| 183 } |
| 184 |
| 173 void JourneyLogger::RecordSectionSpecificStats( | 185 void JourneyLogger::RecordSectionSpecificStats( |
| 174 CompletionStatus completion_status) { | 186 CompletionStatus completion_status) { |
| 175 // Record whether the user had suggestions for each requested information. | 187 // Record whether the user had suggestions for each requested information. |
| 176 bool user_had_all_requested_information = true; | 188 bool user_had_all_requested_information = true; |
| 177 | 189 |
| 178 for (int i = 0; i < NUMBER_OF_SECTIONS; ++i) { | 190 for (int i = 0; i < NUMBER_OF_SECTIONS; ++i) { |
| 179 std::string name_suffix = GetHistogramNameSuffix(i, completion_status); | 191 std::string name_suffix = GetHistogramNameSuffix(i, completion_status); |
| 180 | 192 |
| 181 // Only log the metrics for a section if it was requested by the merchant. | 193 // Only log the metrics for a section if it was requested by the merchant. |
| 182 if (sections_[i].is_requested_) { | 194 if (sections_[i].is_requested_) { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 ukm_recorder_->UpdateSourceURL(source_id, url_); | 289 ukm_recorder_->UpdateSourceURL(source_id, url_); |
| 278 std::unique_ptr<ukm::UkmEntryBuilder> builder = | 290 std::unique_ptr<ukm::UkmEntryBuilder> builder = |
| 279 ukm_recorder_->GetEntryBuilder(source_id, | 291 ukm_recorder_->GetEntryBuilder(source_id, |
| 280 internal::kUKMCheckoutEventsEntryName); | 292 internal::kUKMCheckoutEventsEntryName); |
| 281 builder->AddMetric(internal::kUKMCompletionStatusMetricName, | 293 builder->AddMetric(internal::kUKMCompletionStatusMetricName, |
| 282 completion_status); | 294 completion_status); |
| 283 builder->AddMetric(internal::kUKMEventsMetricName, events_); | 295 builder->AddMetric(internal::kUKMEventsMetricName, events_); |
| 284 } | 296 } |
| 285 | 297 |
| 286 } // namespace payments | 298 } // namespace payments |
| OLD | NEW |