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

Unified Diff: components/payments/core/journey_logger.cc

Issue 2808513002: [Payments] Add PaymentRequest checkout funnel UKMs. (Closed)
Patch Set: Rebase Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/payments/core/journey_logger.h ('k') | components/payments/core/journey_logger_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/payments/core/journey_logger.cc
diff --git a/components/payments/core/journey_logger.cc b/components/payments/core/journey_logger.cc
index d8731c053ff7c1f2bb6bc300ac731deef71cf744..dc25cf6f1bf460dd3d7f797e7100f60d914ffbb8 100644
--- a/components/payments/core/journey_logger.cc
+++ b/components/payments/core/journey_logger.cc
@@ -8,9 +8,19 @@
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
+#include "components/autofill/core/browser/autofill_experiments.h"
+#include "components/ukm/ukm_entry_builder.h"
+#include "components/ukm/ukm_service.h"
namespace payments {
+namespace internal {
+extern const char kUKMCheckoutEventsEntryName[] =
+ "PaymentRequest.CheckoutEvents";
+extern const char kUKMCompletionStatusMetricName[] = "CompletionStatus";
+extern const char kUKMEventsMetricName[] = "Events";
+} // namespace internal
+
namespace {
// Returns the JourneyLogger histograms name suffix based on the |section| and
@@ -54,11 +64,16 @@ std::string GetHistogramNameSuffix(
} // namespace
-JourneyLogger::JourneyLogger(bool is_incognito)
+JourneyLogger::JourneyLogger(bool is_incognito,
+ const GURL& url,
+ ukm::UkmService* ukm_service)
: was_can_make_payments_used_(false),
could_make_payment_(false),
was_show_called_(false),
- is_incognito_(is_incognito) {}
+ is_incognito_(is_incognito),
+ events_(EVENT_INITIATED),
+ url_(url),
+ ukm_service_(ukm_service) {}
JourneyLogger::~JourneyLogger() {}
@@ -92,6 +107,10 @@ void JourneyLogger::SetShowCalled() {
was_show_called_ = true;
}
+void JourneyLogger::SetEventOccurred(Event event) {
+ events_ |= event;
+}
+
void JourneyLogger::RecordJourneyStatsHistograms(
CompletionStatus completion_status) {
RecordSectionSpecificStats(completion_status);
@@ -99,6 +118,8 @@ void JourneyLogger::RecordJourneyStatsHistograms(
// Record the CanMakePayment metrics based on whether the transaction was
// completed or aborted by the user (UserAborted) or otherwise (OtherAborted).
RecordCanMakePaymentStats(completion_status);
+
+ RecordUrlKeyedMetrics(completion_status);
}
void JourneyLogger::RecordSectionSpecificStats(
@@ -199,4 +220,18 @@ void JourneyLogger::RecordCanMakePaymentEffectOnCompletion(
COMPLETION_STATUS_MAX);
}
+void JourneyLogger::RecordUrlKeyedMetrics(CompletionStatus completion_status) {
+ if (!autofill::IsUkmLoggingEnabled() || !ukm_service_ || !url_.is_valid())
+ return;
+
+ // Record the Checkout Funnel UKM.
+ int32_t source_id = ukm_service_->GetNewSourceID();
+ ukm_service_->UpdateSourceURL(source_id, url_);
+ std::unique_ptr<ukm::UkmEntryBuilder> builder = ukm_service_->GetEntryBuilder(
+ source_id, internal::kUKMCheckoutEventsEntryName);
+ builder->AddMetric(internal::kUKMCompletionStatusMetricName,
+ completion_status);
+ builder->AddMetric(internal::kUKMEventsMetricName, events_);
+}
+
} // namespace payments
« no previous file with comments | « components/payments/core/journey_logger.h ('k') | components/payments/core/journey_logger_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698