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

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

Issue 2692853005: [Merge-57] Only record abort metrics if the Payment Request was shown. (Closed)
Patch Set: Created 3 years, 10 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.payments; 5 package org.chromium.chrome.browser.payments;
6 6
7 import android.app.Activity; 7 import android.app.Activity;
8 import android.content.Intent; 8 import android.content.Intent;
9 import android.graphics.Bitmap; 9 import android.graphics.Bitmap;
10 import android.os.Handler; 10 import android.os.Handler;
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 private SectionInformation mPaymentMethodsSection; 261 private SectionInformation mPaymentMethodsSection;
262 private PaymentRequestUI mUI; 262 private PaymentRequestUI mUI;
263 private Callback<PaymentInformation> mPaymentInformationCallback; 263 private Callback<PaymentInformation> mPaymentInformationCallback;
264 private boolean mPaymentAppRunning; 264 private boolean mPaymentAppRunning;
265 private boolean mMerchantSupportsAutofillPaymentInstruments; 265 private boolean mMerchantSupportsAutofillPaymentInstruments;
266 private ContactEditor mContactEditor; 266 private ContactEditor mContactEditor;
267 private boolean mHasRecordedAbortReason; 267 private boolean mHasRecordedAbortReason;
268 private boolean mQueriedCanMakePayment; 268 private boolean mQueriedCanMakePayment;
269 private CurrencyFormatter mCurrencyFormatter; 269 private CurrencyFormatter mCurrencyFormatter;
270 270
271 /** Aborts should only be recorded if the Payment Request was shown to the u ser. */
272 private boolean mShouldRecordAbortReason;
273
271 /** True if any of the requested payment methods are supported. */ 274 /** True if any of the requested payment methods are supported. */
272 private boolean mArePaymentMethodsSupported; 275 private boolean mArePaymentMethodsSupported;
273 276
274 /** 277 /**
275 * True after at least one usable payment instrument has been found. Should be read only after 278 * True after at least one usable payment instrument has been found. Should be read only after
276 * all payment apps have been queried. 279 * all payment apps have been queried.
277 */ 280 */
278 private boolean mCanMakePayment; 281 private boolean mCanMakePayment;
279 282
280 /** The helper to create and fill the response to send to the merchant. */ 283 /** The helper to create and fill the response to send to the merchant. */
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 474
472 setIsShowing(true); 475 setIsShowing(true);
473 if (disconnectIfNoPaymentMethodsSupported()) return; 476 if (disconnectIfNoPaymentMethodsSupported()) return;
474 477
475 // Catch any time the user switches tabs. Because the dialog is modal, a user shouldn't be 478 // Catch any time the user switches tabs. Because the dialog is modal, a user shouldn't be
476 // allowed to switch tabs, which can happen if the user receives an exte rnal Intent. 479 // allowed to switch tabs, which can happen if the user receives an exte rnal Intent.
477 mContext.getTabModelSelector().addObserver(mSelectorObserver); 480 mContext.getTabModelSelector().addObserver(mSelectorObserver);
478 mContext.getCurrentTabModel().addObserver(mTabModelObserver); 481 mContext.getCurrentTabModel().addObserver(mTabModelObserver);
479 482
480 mUI.show(); 483 mUI.show();
481 recordSuccessFunnelHistograms("Shown");
482 mJourneyLogger.setShowCalled();
483 } 484 }
484 485
485 private static Map<String, PaymentMethodData> getValidatedMethodData( 486 private static Map<String, PaymentMethodData> getValidatedMethodData(
486 PaymentMethodData[] methodData, CardEditor paymentMethodsCollector) { 487 PaymentMethodData[] methodData, CardEditor paymentMethodsCollector) {
487 // Payment methodData are required. 488 // Payment methodData are required.
488 if (methodData == null || methodData.length == 0) return null; 489 if (methodData == null || methodData.length == 0) return null;
489 Map<String, PaymentMethodData> result = new ArrayMap<>(); 490 Map<String, PaymentMethodData> result = new ArrayMap<>();
490 for (int i = 0; i < methodData.length; i++) { 491 for (int i = 0; i < methodData.length; i++) {
491 String[] methods = methodData[i].supportedMethods; 492 String[] methods = methodData[i].supportedMethods;
492 493
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 providePaymentInformation(); 744 providePaymentInformation();
744 } 745 }
745 }); 746 });
746 } 747 }
747 748
748 private void providePaymentInformation() { 749 private void providePaymentInformation() {
749 mPaymentInformationCallback.onResult( 750 mPaymentInformationCallback.onResult(
750 new PaymentInformation(mUiShoppingCart, mShippingAddressesSectio n, 751 new PaymentInformation(mUiShoppingCart, mShippingAddressesSectio n,
751 mUiShippingOptions, mContactSection, mPaymentMethodsSect ion)); 752 mUiShippingOptions, mContactSection, mPaymentMethodsSect ion));
752 mPaymentInformationCallback = null; 753 mPaymentInformationCallback = null;
754
755 recordSuccessFunnelHistograms("Shown");
756 mShouldRecordAbortReason = true;
757 mJourneyLogger.setShowCalled();
753 } 758 }
754 759
755 @Override 760 @Override
756 public void getShoppingCart(final Callback<ShoppingCart> callback) { 761 public void getShoppingCart(final Callback<ShoppingCart> callback) {
757 mHandler.post(new Runnable() { 762 mHandler.post(new Runnable() {
758 @Override 763 @Override
759 public void run() { 764 public void run() {
760 callback.onResult(mUiShoppingCart); 765 callback.onResult(mUiShoppingCart);
761 } 766 }
762 }); 767 });
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 boolean userCanAddCreditCard = mMerchantSupportsAutofillPaymentInstrumen ts 1294 boolean userCanAddCreditCard = mMerchantSupportsAutofillPaymentInstrumen ts
1290 && !ChromeFeatureList.isEnabled(ChromeFeatureList.NO_CREDIT_CARD _ABORT); 1295 && !ChromeFeatureList.isEnabled(ChromeFeatureList.NO_CREDIT_CARD _ABORT);
1291 1296
1292 if (!mArePaymentMethodsSupported 1297 if (!mArePaymentMethodsSupported
1293 || (getIsShowing() && !foundPaymentMethods && !userCanAddCreditC ard)) { 1298 || (getIsShowing() && !foundPaymentMethods && !userCanAddCreditC ard)) {
1294 // All payment apps have responded, but none of them have instrument s. It's possible to 1299 // All payment apps have responded, but none of them have instrument s. It's possible to
1295 // add credit cards, but the merchant does not support them either. The payment request 1300 // add credit cards, but the merchant does not support them either. The payment request
1296 // must be rejected. 1301 // must be rejected.
1297 disconnectFromClientWithDebugMessage("Requested payment methods have no instruments", 1302 disconnectFromClientWithDebugMessage("Requested payment methods have no instruments",
1298 PaymentErrorReason.NOT_SUPPORTED); 1303 PaymentErrorReason.NOT_SUPPORTED);
1299 recordAbortReasonHistogram(mArePaymentMethodsSupported 1304 recordNoShowReasonHistogram(mArePaymentMethodsSupported
1300 ? PaymentRequestMetrics.ABORT_REASON_NO_MATCHING_PAYMENT_MET HOD 1305 ? PaymentRequestMetrics.NO_SHOW_NO_MATCHING_PAYMENT_ METHOD
1301 : PaymentRequestMetrics.ABORT_REASON_NO_SUPPORTED_PAYMENT_ME THOD); 1306 : PaymentRequestMetrics.NO_SHOW_NO_SUPPORTED_PAYMENT _METHOD);
1302 if (sObserverForTest != null) sObserverForTest.onPaymentRequestServi ceShowFailed(); 1307 if (sObserverForTest != null) sObserverForTest.onPaymentRequestServi ceShowFailed();
1303 return true; 1308 return true;
1304 } 1309 }
1305 1310
1306 return false; 1311 return false;
1307 } 1312 }
1308 1313
1309 /** @return True after payment apps have been queried. */ 1314 /** @return True after payment apps have been queried. */
1310 private boolean isFinishedQueryingPaymentApps() { 1315 private boolean isFinishedQueryingPaymentApps() {
1311 return mPendingApps != null && mPendingApps.isEmpty() && mPendingInstrum ents.isEmpty(); 1316 return mPendingApps != null && mPendingApps.isEmpty() && mPendingInstrum ents.isEmpty();
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 } 1463 }
1459 } 1464 }
1460 1465
1461 /** 1466 /**
1462 * Adds an entry to the aborted Payment Request histogram in the bucket corr esponding to the 1467 * Adds an entry to the aborted Payment Request histogram in the bucket corr esponding to the
1463 * reason for aborting. Only records the initial reason for aborting, as som e closing code calls 1468 * reason for aborting. Only records the initial reason for aborting, as som e closing code calls
1464 * other closing code that can log too. 1469 * other closing code that can log too.
1465 */ 1470 */
1466 private void recordAbortReasonHistogram(int abortReason) { 1471 private void recordAbortReasonHistogram(int abortReason) {
1467 assert abortReason < PaymentRequestMetrics.ABORT_REASON_MAX; 1472 assert abortReason < PaymentRequestMetrics.ABORT_REASON_MAX;
1468 if (mHasRecordedAbortReason) return; 1473 if (mHasRecordedAbortReason || !mShouldRecordAbortReason) return;
1469 1474
1470 mHasRecordedAbortReason = true; 1475 mHasRecordedAbortReason = true;
1471 RecordHistogram.recordEnumeratedHistogram( 1476 RecordHistogram.recordEnumeratedHistogram(
1472 "PaymentRequest.CheckoutFunnel.Aborted", abortReason, 1477 "PaymentRequest.CheckoutFunnel.Aborted", abortReason,
1473 PaymentRequestMetrics.ABORT_REASON_MAX); 1478 PaymentRequestMetrics.ABORT_REASON_MAX);
1474 1479
1475 if (abortReason == PaymentRequestMetrics.ABORT_REASON_ABORTED_BY_USER) { 1480 if (abortReason == PaymentRequestMetrics.ABORT_REASON_ABORTED_BY_USER) {
1476 mJourneyLogger.recordJourneyStatsHistograms("UserAborted"); 1481 mJourneyLogger.recordJourneyStatsHistograms("UserAborted");
1477 } else { 1482 } else {
1478 mJourneyLogger.recordJourneyStatsHistograms("OtherAborted"); 1483 mJourneyLogger.recordJourneyStatsHistograms("OtherAborted");
1479 } 1484 }
1480 } 1485 }
1486
1487 /**
1488 * Adds an entry to the NoShow Payment Request histogram in the bucket corre sponding to the
1489 * reason for not showing the Payment Request.
1490 */
1491 private void recordNoShowReasonHistogram(int reason) {
1492 assert reason < PaymentRequestMetrics.NO_SHOW_REASON_MAX;
1493
1494 RecordHistogram.recordEnumeratedHistogram("PaymentRequest.CheckoutFunnel .NoShow", reason,
1495 PaymentRequestMetrics.NO_SHOW_REASON_MAX);
1496 }
1481 } 1497 }
OLDNEW
« 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