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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestMetrics.java

Issue 2220713002: [Payments] Add Payment Request metrics for selected payment method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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: chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestMetrics.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestMetrics.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestMetrics.java
index 6aa7e3f88dd99a52ed7e60d6df12e26967ac814f..8a1ed847ca96eb5e736cb65dcc0849a6ad69d0cb 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestMetrics.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestMetrics.java
@@ -46,9 +46,39 @@ public final class PaymentRequestMetrics {
@VisibleForTesting
public static final int ABORT_REASON_MAX = 9;
+ // PaymentRequestPaymentMethods defined in tools/metrics/histograms/histograms.xml.
+ @VisibleForTesting
+ public static final int SELECTED_METHOD_CREDIT_CARD = 0;
+ @VisibleForTesting
+ public static final int SELECTED_METHOD_ANDROID_PAY = 1;
+ @VisibleForTesting
+ public static final int SELECTED_METHOD_OTHER_PAYMENT_APP = 2;
+ @VisibleForTesting
+ public static final int SELECTED_METHOD_MAX = 3;
+
+ // The method name associated with an Android Pay transaction.
+ private static String sAndroidPaymentMethodName = "https://android.com/pay";
+
// There should be no instance of PaymentRequestMetrics created.
private PaymentRequestMetrics() {}
+ /**
+ * Returns the method name corresponding to an Android Pay transaction in Payment Request.
+ *
+ * @return The method name corresponding to an Android Pay transaction.
+ */
+ public static String getAndroidPayMethodName() {
+ return sAndroidPaymentMethodName;
+ }
+
+ /**
+ * Sets the method name associated with an Android Pay transaction to the value used in tests.
+ */
+ @VisibleForTesting
+ public static void setAndroidPayMethodNameForTest() {
+ sAndroidPaymentMethodName = "https://bobpay.com";
+ }
please use gerrit instead 2016/08/05 22:08:26 I'm not a fan of global modifiable state, if I can
sebsg 2016/08/08 16:16:50 Done.
+
/*
* Records the metric that keeps track of what user information are requested by merchants to
* complete a payment request.
@@ -66,4 +96,16 @@ public final class PaymentRequestMetrics {
RecordHistogram.recordEnumeratedHistogram("PaymentRequest.RequestedInformation",
requestInformation, REQUESTED_INFORMATION_MAX);
}
+
+ /*
+ * Records the metric that keeps track of what payment method was used to complete a Payment
+ * Request transaction.
+ *
+ * @param paymentMethod The payment method that was used to complete the current transaction.
+ */
+ public static void recordSelectedPaymentMethodHistogram(int paymentMethod) {
+ assert paymentMethod < SELECTED_METHOD_MAX;
+ RecordHistogram.recordEnumeratedHistogram("PaymentRequest.SelectedPaymentMethod",
+ paymentMethod, SELECTED_METHOD_MAX);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698