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

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

Issue 2750103005: [Payments] Move journey logger to native. (Closed)
Patch Set: Nits Created 3 years, 9 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
Index: components/payments/core/journey_logger.h
diff --git a/components/payments/core/journey_logger.h b/components/payments/core/journey_logger.h
new file mode 100644
index 0000000000000000000000000000000000000000..90db73f57e880a2511ee5dfad9dab4024fb3d85c
--- /dev/null
+++ b/components/payments/core/journey_logger.h
@@ -0,0 +1,132 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_PAYMENTS_CORE_JOURNEY_LOGGER_H_
+#define COMPONENTS_PAYMENTS_CORE_JOURNEY_LOGGER_H_
+
+#include <string>
+
+#include "base/macros.h"
+
+namespace payments {
+
+// A class to keep track of different stats during a Payment Request journey. It
+// collects different metrics during the course of the checkout flow, like the
+// number of credit cards that the user added or edited. The metrics will be
+// logged when RecordJourneyStatsHistograms is called with the completion status
+// of the Payment Request.
+class JourneyLogger {
+ public:
+ // Note: These constants should always be in sync with their counterpart in
+ // JourneyLogger.java.
please use gerrit instead 2017/03/24 16:31:47 Add a mirror comment in JourneyLogger.java. Use th
sebsg 2017/03/24 18:37:47 Done.
+ // The different sections of a Payment Request. Used to record journey
+ // stats.
+ enum Sections {
please use gerrit instead 2017/03/24 16:31:47 Please use "enum class". Let's use singular "Secti
sebsg 2017/03/24 18:37:47 Unfortunately they have to be implicitly convertib
+ SECTION_CONTACT_INFO = 0,
+ SECTION_CREDIT_CARDS = 1,
+ SECTION_SHIPPING_ADDRESS = 2,
+ SECTION_MAX,
+ };
+
+ // For the CanMakePayment histograms.
+ enum CanMakePaymentUsage {
+ CAN_MAKE_PAYMENT_USED = 0,
+ CAN_MAKE_PAYMENT_NOT_USED = 1,
+ CAN_MAKE_PAYMENT_USE_MAX,
+ };
+
+ // Used to log different parameters' effect on whether the transaction was
+ // completed.
+ enum CompletionStatus {
+ COMPLETION_STATUS_COMPLETED = 0,
+ COMPLETION_STATUS_ABORTED = 1,
+ COMPLETION_STATUS_MAX,
+ };
+
+ // Used to mesure the impact of the CanMakePayment return value on whether the
+ // Payment Request is shown to the user.
+ static const int CMP_SHOW_COULD_NOT_MAKE_PAYMENT_AND_DID_NOT_SHOW = 0;
please use gerrit instead 2017/03/24 16:31:47 Let's use "enum class" here as well.
sebsg 2017/03/24 18:37:47 I thought it was more clear this way. It allows st
+ static const int CMP_SHOW_DID_SHOW = 1 << 0;
+ static const int CMP_SHOW_COULD_MAKE_PAYMENT_ = 1 << 1;
+ static const int CMP_SHOW_MAX = 4;
+
+ JourneyLogger();
+ ~JourneyLogger();
+
+ // Increments the number of selection adds for the specified section.
+ void IncrementSelectionAdds(int section);
please use gerrit instead 2017/03/24 16:31:47 Use the enum type instead of int. Same below.
sebsg 2017/03/24 18:37:47 Done.
+
+ // Increments the number of selection changes for the specified section.
+ void IncrementSelectionChanges(int section);
+
+ // Increments the number of selection edits for the specified section.
+ void IncrementSelectionEdits(int section);
+
+ // Sets the number of suggestions shown for the specified section.
+ void SetNumberOfSuggestionsShown(int section, int number);
+
+ // Records the fact that the merchant called CanMakePayment and records it's
+ // return value.
+ void SetCanMakePaymentValue(bool value);
+
+ // Records the fact that the Payment Request was shown to the user.
+ void SetShowCalled();
+
+ // Records the histograms for all the sections that were requested by the
+ // merchant and for the usage of the CanMakePayment method and its effect on
+ // the transaction. This method should be called when the Payment Request has
+ // either been completed or aborted.
+ void RecordJourneyStatsHistograms(const std::string& submission_type);
please use gerrit instead 2017/03/24 16:31:47 Why not use an enum here as well?
sebsg 2017/03/24 18:37:47 Done.
+
+ private:
+ static const int NUMBER_OF_SECTIONS = 3;
+
+ // The minimum expected value of CustomCountHistograms is always set to 1. It
+ // is still possible to log the value 0 to that type of histogram.
please use gerrit instead 2017/03/24 16:31:47 Note about keeping this in sync with JourneyLogger
sebsg 2017/03/24 18:37:47 Done.
+ const int MIN_EXPECTED_SAMPLE = 1;
+ const int MAX_EXPECTED_SAMPLE = 49;
+ const int NUMBER_BUCKETS = 50;
+
+ struct SectionStats {
+ SectionStats()
+ : number_selection_adds_(0),
+ number_selection_changes_(0),
+ number_selection_edits_(0),
+ number_suggestions_shown_(0),
+ is_requested_(false) {}
+
+ int number_selection_adds_;
+ int number_selection_changes_;
+ int number_selection_edits_;
+ int number_suggestions_shown_;
+ int is_requested_;
please use gerrit instead 2017/03/24 16:31:47 bool
sebsg 2017/03/24 18:37:47 Done.
+ };
+
+ // Records the histograms for all the sections that were requested by the
+ // merchant.
+ void RecordSectionSpecificStats(const std::string& submission_type);
+
+ // Records the metrics related the the CanMakePayment method.
+ void RecordCanMakePaymentStats(CompletionStatus completion_status);
+
+ // Records CanMakePayment's return value effect on whether the Payment Request
+ // was shown or not.
+ void RecordCanMakePaymentEffectOnShow();
+
+ // Records the completion status depending on the the usage and return value
+ // of the CanMakePaymentMethod.
+ void RecordCanMakePaymentEffectOnCompletion(
+ CompletionStatus completion_status);
+
+ SectionStats sections_[NUMBER_OF_SECTIONS];
+ bool was_can_make_payments_used_;
+ bool could_make_payment_;
+ bool was_show_called_;
+
+ DISALLOW_COPY_AND_ASSIGN(JourneyLogger);
+};
+
+} // namespace payments
+
+#endif // COMPONENTS_PAYMENTS_CORE_JOURNEY_LOGGER_H_

Powered by Google App Engine
This is Rietveld 408576698