| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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::UkmService* ukm_service) |
| 70 : was_can_make_payments_used_(false), | 70 : is_incognito_(is_incognito), |
| 71 could_make_payment_(false), | |
| 72 was_show_called_(false), | |
| 73 is_incognito_(is_incognito), | |
| 74 events_(EVENT_INITIATED), | 71 events_(EVENT_INITIATED), |
| 75 url_(url), | 72 url_(url), |
| 76 ukm_service_(ukm_service) {} | 73 ukm_service_(ukm_service) {} |
| 77 | 74 |
| 78 JourneyLogger::~JourneyLogger() {} | 75 JourneyLogger::~JourneyLogger() {} |
| 79 | 76 |
| 80 void JourneyLogger::IncrementSelectionAdds(Section section) { | 77 void JourneyLogger::IncrementSelectionAdds(Section section) { |
| 81 DCHECK_LT(section, SECTION_MAX); | 78 DCHECK_LT(section, SECTION_MAX); |
| 82 sections_[section].number_selection_adds_++; | 79 sections_[section].number_selection_adds_++; |
| 83 } | 80 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 106 void JourneyLogger::SetShowCalled() { | 103 void JourneyLogger::SetShowCalled() { |
| 107 was_show_called_ = true; | 104 was_show_called_ = true; |
| 108 } | 105 } |
| 109 | 106 |
| 110 void JourneyLogger::SetEventOccurred(Event event) { | 107 void JourneyLogger::SetEventOccurred(Event event) { |
| 111 events_ |= event; | 108 events_ |= event; |
| 112 } | 109 } |
| 113 | 110 |
| 114 void JourneyLogger::RecordJourneyStatsHistograms( | 111 void JourneyLogger::RecordJourneyStatsHistograms( |
| 115 CompletionStatus completion_status) { | 112 CompletionStatus completion_status) { |
| 113 // TODO(crbug.com/717741): Replace if by DCHECK once we make sure it's not |
| 114 // called more than once. |
| 115 if (has_recorded_) |
| 116 return; |
| 117 |
| 118 has_recorded_ = true; |
| 119 |
| 116 RecordSectionSpecificStats(completion_status); | 120 RecordSectionSpecificStats(completion_status); |
| 117 | 121 |
| 118 // Record the CanMakePayment metrics based on whether the transaction was | 122 // Record the CanMakePayment metrics based on whether the transaction was |
| 119 // completed or aborted by the user (UserAborted) or otherwise (OtherAborted). | 123 // completed or aborted by the user (UserAborted) or otherwise (OtherAborted). |
| 120 RecordCanMakePaymentStats(completion_status); | 124 RecordCanMakePaymentStats(completion_status); |
| 121 | 125 |
| 122 RecordUrlKeyedMetrics(completion_status); | 126 RecordUrlKeyedMetrics(completion_status); |
| 123 } | 127 } |
| 124 | 128 |
| 125 void JourneyLogger::RecordSectionSpecificStats( | 129 void JourneyLogger::RecordSectionSpecificStats( |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 int32_t source_id = ukm_service_->GetNewSourceID(); | 232 int32_t source_id = ukm_service_->GetNewSourceID(); |
| 229 ukm_service_->UpdateSourceURL(source_id, url_); | 233 ukm_service_->UpdateSourceURL(source_id, url_); |
| 230 std::unique_ptr<ukm::UkmEntryBuilder> builder = ukm_service_->GetEntryBuilder( | 234 std::unique_ptr<ukm::UkmEntryBuilder> builder = ukm_service_->GetEntryBuilder( |
| 231 source_id, internal::kUKMCheckoutEventsEntryName); | 235 source_id, internal::kUKMCheckoutEventsEntryName); |
| 232 builder->AddMetric(internal::kUKMCompletionStatusMetricName, | 236 builder->AddMetric(internal::kUKMCompletionStatusMetricName, |
| 233 completion_status); | 237 completion_status); |
| 234 builder->AddMetric(internal::kUKMEventsMetricName, events_); | 238 builder->AddMetric(internal::kUKMEventsMetricName, events_); |
| 235 } | 239 } |
| 236 | 240 |
| 237 } // namespace payments | 241 } // namespace payments |
| OLD | NEW |