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

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

Issue 2851893002: [Payments] Record CanMakePayment metrics on Desktop. (Closed)
Patch Set: Created 3 years, 7 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
OLDNEW
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 : was_can_make_payments_used_(false),
71 could_make_payment_(false), 71 could_make_payment_(false),
72 was_show_called_(false), 72 was_show_called_(false),
73 is_incognito_(is_incognito), 73 is_incognito_(is_incognito),
74 events_(EVENT_INITIATED), 74 events_(EVENT_INITIATED),
75 url_(url), 75 url_(url),
76 ukm_service_(ukm_service) {} 76 ukm_service_(ukm_service),
77 has_recorded_(false) {}
77 78
78 JourneyLogger::~JourneyLogger() {} 79 JourneyLogger::~JourneyLogger() {}
79 80
80 void JourneyLogger::IncrementSelectionAdds(Section section) { 81 void JourneyLogger::IncrementSelectionAdds(Section section) {
81 DCHECK_LT(section, SECTION_MAX); 82 DCHECK_LT(section, SECTION_MAX);
82 sections_[section].number_selection_adds_++; 83 sections_[section].number_selection_adds_++;
83 } 84 }
84 85
85 void JourneyLogger::IncrementSelectionChanges(Section section) { 86 void JourneyLogger::IncrementSelectionChanges(Section section) {
86 DCHECK_LT(section, SECTION_MAX); 87 DCHECK_LT(section, SECTION_MAX);
(...skipping 19 matching lines...) Expand all
106 void JourneyLogger::SetShowCalled() { 107 void JourneyLogger::SetShowCalled() {
107 was_show_called_ = true; 108 was_show_called_ = true;
108 } 109 }
109 110
110 void JourneyLogger::SetEventOccurred(Event event) { 111 void JourneyLogger::SetEventOccurred(Event event) {
111 events_ |= event; 112 events_ |= event;
112 } 113 }
113 114
114 void JourneyLogger::RecordJourneyStatsHistograms( 115 void JourneyLogger::RecordJourneyStatsHistograms(
115 CompletionStatus completion_status) { 116 CompletionStatus completion_status) {
117 // TODO: This should be a DCHECK once we make sure it's not called twice.
Mathieu 2017/05/02 20:56:47 Making it a DCHECK now seems reasonable?
sebsg 2017/05/02 22:15:08 It's not fixed at the moment, so the DCHECK would
118 if (has_recorded_)
119 return;
120
121 has_recorded_ = true;
122
116 RecordSectionSpecificStats(completion_status); 123 RecordSectionSpecificStats(completion_status);
117 124
118 // Record the CanMakePayment metrics based on whether the transaction was 125 // Record the CanMakePayment metrics based on whether the transaction was
119 // completed or aborted by the user (UserAborted) or otherwise (OtherAborted). 126 // completed or aborted by the user (UserAborted) or otherwise (OtherAborted).
120 RecordCanMakePaymentStats(completion_status); 127 RecordCanMakePaymentStats(completion_status);
121 128
122 RecordUrlKeyedMetrics(completion_status); 129 RecordUrlKeyedMetrics(completion_status);
123 } 130 }
124 131
125 void JourneyLogger::RecordSectionSpecificStats( 132 void JourneyLogger::RecordSectionSpecificStats(
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 int32_t source_id = ukm_service_->GetNewSourceID(); 235 int32_t source_id = ukm_service_->GetNewSourceID();
229 ukm_service_->UpdateSourceURL(source_id, url_); 236 ukm_service_->UpdateSourceURL(source_id, url_);
230 std::unique_ptr<ukm::UkmEntryBuilder> builder = ukm_service_->GetEntryBuilder( 237 std::unique_ptr<ukm::UkmEntryBuilder> builder = ukm_service_->GetEntryBuilder(
231 source_id, internal::kUKMCheckoutEventsEntryName); 238 source_id, internal::kUKMCheckoutEventsEntryName);
232 builder->AddMetric(internal::kUKMCompletionStatusMetricName, 239 builder->AddMetric(internal::kUKMCompletionStatusMetricName,
233 completion_status); 240 completion_status);
234 builder->AddMetric(internal::kUKMEventsMetricName, events_); 241 builder->AddMetric(internal::kUKMEventsMetricName, events_);
235 } 242 }
236 243
237 } // namespace payments 244 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698