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..9593097009b2cb32f52dfe0a058536a80c49b185 |
--- /dev/null |
+++ b/components/payments/core/journey_logger.h |
@@ -0,0 +1,124 @@ |
+// 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 of different stats during a Payment Request journey. |
Mathieu
2017/03/23 21:19:48
nit: of of
Mathieu
2017/03/23 21:19:48
can you mention the usage a little bit? Also, ment
sebsg
2017/03/24 13:35:30
Done.
sebsg
2017/03/24 13:35:30
Done.
|
+class JourneyLogger { |
+ public: |
+ // The the different sections of a Payment Request. Used to record journey |
Mathieu
2017/03/23 21:19:48
nit: the the
sebsg
2017/03/24 13:35:30
Done.
|
+ // stats. |
+ enum Sections { |
+ SECTION_CONTACT_INFO = 0, |
+ SECTION_CREDIT_CARDS, |
+ SECTION_SHIPPING_ADDRESS, |
+ SECTION_MAX, |
+ }; |
+ |
+ // For the CanMakePayment histograms. |
+ enum CanMakePaymentUsage { |
+ CAN_MAKE_PAYMENT_USED = 0, |
+ CAN_MAKE_PAYMENT_NOT_USED, |
+ CAN_MAKE_PAYMENT_USE_MAX, |
+ }; |
+ |
+ // Used to log different parameters' effect on whether the transaction was |
+ // completed. |
+ static const int COMPLETION_STATUS_COMPLETED = 0; |
+ static const int COMPLETION_STATUS_ABORTED = 1; |
+ static const int COMPLETION_STATUS_MAX = 2; |
+ |
+ // 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; |
+ static const int CMP_SHOW_DID_SHOW = 1 << 0; |
+ static const int CMP_SHOW_could_make_payment_ = 1 << 1; |
Mathieu
2017/03/23 21:19:48
fix
sebsg
2017/03/24 13:35:29
Done.
|
+ static const int CMP_SHOW_MAX = 4; |
+ |
+ JourneyLogger(); |
+ ~JourneyLogger(){}; |
Mathieu
2017/03/23 21:19:48
nit: ~JourneyLogger(); and implement in cc
sebsg
2017/03/24 13:35:30
Done.
|
+ |
+ // Increments the number of selection adds for the specified section. |
+ void IncrementSelectionAdds(int section); |
+ |
+ // 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); |
+ |
+ 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. |
+ const int MIN_EXPECTED_SAMPLE = 1; |
+ const int MAX_EXPECTED_SAMPLE = 49; |
+ const int NUMBER_BUCKETS = 50; |
+ |
+ class SectionStats { |
Mathieu
2017/03/23 21:19:49
struct?
sebsg
2017/03/24 13:35:29
Done.
|
+ public: |
+ 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_; |
+ }; |
+ |
+ // 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(int 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(int 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_ |