| 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..5c35c0d7ecfa3015fcc4fd653f6d092183858a6d
|
| --- /dev/null
|
| +++ b/components/payments/core/journey_logger.h
|
| @@ -0,0 +1,137 @@
|
| +// 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
|
| + // components/payments/content/android/java/src/org/chromium/components/
|
| + // payments/JourneyLogger.java.
|
| + // The different sections of a Payment Request. Used to record journey
|
| + // stats.
|
| + enum Section {
|
| + 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_USER_ABORTED = 1,
|
| + COMPLETION_STATUS_OTHER_ABORTED = 2,
|
| + 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;
|
| + 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(Section section);
|
| +
|
| + // Increments the number of selection changes for the specified section.
|
| + void IncrementSelectionChanges(Section section);
|
| +
|
| + // Increments the number of selection edits for the specified section.
|
| + void IncrementSelectionEdits(Section section);
|
| +
|
| + // Sets the number of suggestions shown for the specified section.
|
| + void SetNumberOfSuggestionsShown(Section 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(CompletionStatus completion_status);
|
| +
|
| + private:
|
| + static const int NUMBER_OF_SECTIONS = 3;
|
| +
|
| + // Note: These constants should always be in sync with their counterpart in
|
| + // components/payments/content/android/java/src/org/chromium/components/
|
| + // payments/JourneyLogger.java.
|
| + // 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;
|
| +
|
| + 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_;
|
| + bool is_requested_;
|
| + };
|
| +
|
| + // Records the histograms for all the sections that were requested by the
|
| + // merchant.
|
| + void RecordSectionSpecificStats(CompletionStatus completion_status);
|
| +
|
| + // 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_
|
|
|