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

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

Issue 2199813003: [Payments] Add metrics for Payment Request aborts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@metrics
Patch Set: Rebase 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
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestMetrics.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java
index f96699e84d68d09bbddcb2875c47b7598572c584..653f20b90c4aca3229ce8bd8f88e471b424def1e 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java
@@ -157,6 +157,7 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
private boolean mPaymentAppRunning;
private boolean mMerchantSupportsAutofillPaymentInstruments;
private ContactEditor mContactEditor;
+ private boolean mHasRecordedAbortReason;
/**
* Builds the PaymentRequest service implementation.
@@ -222,12 +223,16 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
if (mMethodData != null) {
disconnectFromClientWithDebugMessage("PaymentRequest.show() called more than once.");
+ recordAbortReasonHistogram(
+ PaymentRequestMetrics.ABORT_REASON_INVALID_DATA_FROM_RENDERER);
return;
}
mMethodData = getValidatedMethodData(methodData, mCardEditor);
if (mMethodData == null) {
disconnectFromClientWithDebugMessage("Invalid payment methods or data");
+ recordAbortReasonHistogram(
+ PaymentRequestMetrics.ABORT_REASON_INVALID_DATA_FROM_RENDERER);
return;
}
@@ -237,6 +242,8 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
disconnectFromClientWithDebugMessage("Requested payment methods are not supported",
PaymentErrorReason.NOT_SUPPORTED);
if (sObserverForTest != null) sObserverForTest.onPaymentRequestServiceShowFailed();
+ recordAbortReasonHistogram(
+ PaymentRequestMetrics.ABORT_REASON_NO_SUPPORTED_PAYMENT_METHOD);
return;
}
@@ -427,6 +434,8 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
if (mUI == null) {
disconnectFromClientWithDebugMessage(
"PaymentRequestUpdateEvent.updateWith() called without PaymentRequest.show()");
+ recordAbortReasonHistogram(
+ PaymentRequestMetrics.ABORT_REASON_INVALID_DATA_FROM_RENDERER);
return;
}
@@ -437,6 +446,7 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
if (mUiShippingOptions.isEmpty() && !mMerchantNeedsShippingAddress) {
disconnectFromClientWithDebugMessage("Merchant indicates inability to ship although "
+ "originally indicated that can ship anywhere");
+ recordAbortReasonHistogram(PaymentRequestMetrics.ABORT_REASON_OTHER);
return;
}
@@ -465,11 +475,15 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
private boolean parseAndValidateDetailsOrDisconnectFromClient(PaymentDetails details) {
if (details == null) {
disconnectFromClientWithDebugMessage("Payment details required");
+ recordAbortReasonHistogram(
+ PaymentRequestMetrics.ABORT_REASON_INVALID_DATA_FROM_RENDERER);
return false;
}
if (!hasAllPaymentItemFields(details.total)) {
disconnectFromClientWithDebugMessage("Invalid total");
+ recordAbortReasonHistogram(
+ PaymentRequestMetrics.ABORT_REASON_INVALID_DATA_FROM_RENDERER);
return false;
}
@@ -479,12 +493,16 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
if (!formatter.isValidAmountCurrencyCode(details.total.amount.currency)) {
disconnectFromClientWithDebugMessage("Invalid total amount currency");
+ recordAbortReasonHistogram(
+ PaymentRequestMetrics.ABORT_REASON_INVALID_DATA_FROM_RENDERER);
return false;
}
if (!formatter.isValidAmountValue(details.total.amount.value)
|| details.total.amount.value.startsWith("-")) {
disconnectFromClientWithDebugMessage("Invalid total amount value");
+ recordAbortReasonHistogram(
+ PaymentRequestMetrics.ABORT_REASON_INVALID_DATA_FROM_RENDERER);
return false;
}
@@ -495,6 +513,8 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
formatter);
if (uiLineItems == null) {
disconnectFromClientWithDebugMessage("Invalid line items");
+ recordAbortReasonHistogram(
+ PaymentRequestMetrics.ABORT_REASON_INVALID_DATA_FROM_RENDERER);
return false;
}
@@ -506,6 +526,8 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
formatter);
if (mUiShippingOptions == null) {
disconnectFromClientWithDebugMessage("Invalid shipping options");
+ recordAbortReasonHistogram(
+ PaymentRequestMetrics.ABORT_REASON_INVALID_DATA_FROM_RENDERER);
return false;
}
@@ -811,6 +833,8 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
@Override
public void onDismiss() {
disconnectFromClientWithDebugMessage("Dialog dismissed");
+ closeUI(false);
+ recordAbortReasonHistogram(PaymentRequestMetrics.ABORT_REASON_ABORTED_BY_USER);
}
private void disconnectFromClientWithDebugMessage(String debugMessage) {
@@ -841,6 +865,7 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
} else {
closeClient();
closeUI(false);
+ recordAbortReasonHistogram(PaymentRequestMetrics.ABORT_REASON_ABORTED_BY_MERCHANT);
}
}
@@ -862,6 +887,7 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
if (mClient == null) return;
closeClient();
closeUI(false);
+ recordAbortReasonHistogram(PaymentRequestMetrics.ABORT_REASON_MOJO_RENDERER_CLOSING);
}
/**
@@ -872,6 +898,7 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
if (mClient == null) return;
closeClient();
closeUI(false);
+ recordAbortReasonHistogram(PaymentRequestMetrics.ABORT_REASON_MOJO_CONNECTION_ERROR);
}
/**
@@ -905,6 +932,8 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
disconnectFromClientWithDebugMessage("Requested payment methods have no instruments",
PaymentErrorReason.NOT_SUPPORTED);
if (sObserverForTest != null) sObserverForTest.onPaymentRequestServiceShowFailed();
+ recordAbortReasonHistogram(
+ PaymentRequestMetrics.ABORT_REASON_NO_MATCHING_PAYMENT_METHOD);
return;
}
@@ -1067,4 +1096,19 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
private void recordSuccessFunnelHistograms(String funnelPart) {
RecordHistogram.recordBooleanHistogram("PaymentRequest.CheckoutFunnel." + funnelPart, true);
}
+
+ /**
+ * Adds an entry to the aborted Payment Request histogram in the bucket corresponding to the
+ * reason for aborting. Only records the initial reason for aborting, as some closing code calls
+ * other closing code that can log too.
+ */
+ private void recordAbortReasonHistogram(int abortReason) {
+ assert abortReason < PaymentRequestMetrics.ABORT_REASON_MAX;
+ if (mHasRecordedAbortReason) return;
+
+ mHasRecordedAbortReason = true;
+ RecordHistogram.recordEnumeratedHistogram(
+ "PaymentRequest.CheckoutFunnel.Aborted", abortReason,
+ PaymentRequestMetrics.ABORT_REASON_MAX);
+ }
}
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestMetrics.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698