| 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" |
| 11 #include "components/autofill/core/browser/autofill_experiments.h" | 11 #include "components/autofill/core/browser/autofill_experiments.h" |
| 12 #include "components/ukm/ukm_entry_builder.h" | 12 #include "components/ukm/public/ukm_entry_builder.h" |
| 13 #include "components/ukm/ukm_service.h" | 13 #include "components/ukm/public/ukm_recorder.h" |
| 14 | 14 |
| 15 namespace payments { | 15 namespace payments { |
| 16 | 16 |
| 17 namespace internal { | 17 namespace internal { |
| 18 extern const char kUKMCheckoutEventsEntryName[] = | 18 extern const char kUKMCheckoutEventsEntryName[] = |
| 19 "PaymentRequest.CheckoutEvents"; | 19 "PaymentRequest.CheckoutEvents"; |
| 20 extern const char kUKMCompletionStatusMetricName[] = "CompletionStatus"; | 20 extern const char kUKMCompletionStatusMetricName[] = "CompletionStatus"; |
| 21 extern const char kUKMEventsMetricName[] = "Events"; | 21 extern const char kUKMEventsMetricName[] = "Events"; |
| 22 } // namespace internal | 22 } // namespace internal |
| 23 | 23 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } | 59 } |
| 60 | 60 |
| 61 DCHECK(!name_suffix.empty()); | 61 DCHECK(!name_suffix.empty()); |
| 62 return name_suffix; | 62 return name_suffix; |
| 63 } | 63 } |
| 64 | 64 |
| 65 } // namespace | 65 } // namespace |
| 66 | 66 |
| 67 JourneyLogger::JourneyLogger(bool is_incognito, | 67 JourneyLogger::JourneyLogger(bool is_incognito, |
| 68 const GURL& url, | 68 const GURL& url, |
| 69 ukm::UkmService* ukm_service) | 69 ukm::UkmRecorder* ukm_recorder) |
| 70 : is_incognito_(is_incognito), | 70 : is_incognito_(is_incognito), |
| 71 events_(EVENT_INITIATED), | 71 events_(EVENT_INITIATED), |
| 72 url_(url), | 72 url_(url), |
| 73 ukm_service_(ukm_service) {} | 73 ukm_recorder_(ukm_recorder) {} |
| 74 | 74 |
| 75 JourneyLogger::~JourneyLogger() { | 75 JourneyLogger::~JourneyLogger() { |
| 76 if (was_show_called_) | 76 if (was_show_called_) |
| 77 DCHECK(has_recorded_); | 77 DCHECK(has_recorded_); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void JourneyLogger::IncrementSelectionAdds(Section section) { | 80 void JourneyLogger::IncrementSelectionAdds(Section section) { |
| 81 DCHECK_LT(section, SECTION_MAX); | 81 DCHECK_LT(section, SECTION_MAX); |
| 82 sections_[section].number_selection_adds_++; | 82 sections_[section].number_selection_adds_++; |
| 83 } | 83 } |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 histogram_name += "Used.TrueWithShowEffectOnCompletion"; | 217 histogram_name += "Used.TrueWithShowEffectOnCompletion"; |
| 218 } else { | 218 } else { |
| 219 histogram_name += "Used.FalseWithShowEffectOnCompletion"; | 219 histogram_name += "Used.FalseWithShowEffectOnCompletion"; |
| 220 } | 220 } |
| 221 | 221 |
| 222 base::UmaHistogramEnumeration(histogram_name, completion_status, | 222 base::UmaHistogramEnumeration(histogram_name, completion_status, |
| 223 COMPLETION_STATUS_MAX); | 223 COMPLETION_STATUS_MAX); |
| 224 } | 224 } |
| 225 | 225 |
| 226 void JourneyLogger::RecordUrlKeyedMetrics(CompletionStatus completion_status) { | 226 void JourneyLogger::RecordUrlKeyedMetrics(CompletionStatus completion_status) { |
| 227 if (!autofill::IsUkmLoggingEnabled() || !ukm_service_ || !url_.is_valid()) | 227 if (!autofill::IsUkmLoggingEnabled() || !ukm_recorder_ || !url_.is_valid()) |
| 228 return; | 228 return; |
| 229 | 229 |
| 230 // Record the Checkout Funnel UKM. | 230 // Record the Checkout Funnel UKM. |
| 231 int32_t source_id = ukm_service_->GetNewSourceID(); | 231 ukm::SourceId source_id = ukm_recorder_->GetNewSourceID(); |
| 232 ukm_service_->UpdateSourceURL(source_id, url_); | 232 ukm_recorder_->UpdateSourceURL(source_id, url_); |
| 233 std::unique_ptr<ukm::UkmEntryBuilder> builder = ukm_service_->GetEntryBuilder( | 233 std::unique_ptr<ukm::UkmEntryBuilder> builder = |
| 234 source_id, internal::kUKMCheckoutEventsEntryName); | 234 ukm_recorder_->GetEntryBuilder(source_id, |
| 235 internal::kUKMCheckoutEventsEntryName); |
| 235 builder->AddMetric(internal::kUKMCompletionStatusMetricName, | 236 builder->AddMetric(internal::kUKMCompletionStatusMetricName, |
| 236 completion_status); | 237 completion_status); |
| 237 builder->AddMetric(internal::kUKMEventsMetricName, events_); | 238 builder->AddMetric(internal::kUKMEventsMetricName, events_); |
| 238 } | 239 } |
| 239 | 240 |
| 240 } // namespace payments | 241 } // namespace payments |
| OLD | NEW |