Commit cef3357d authored by Tanisha Mandre's avatar Tanisha Mandre Committed by Commit Bot

Add credit card scanner feature related metrics

- MobileAddCreditCard.CreditCardAdded: When a valid credit card is saved.
- MobileAddCreditCard.AddPaymentMethodButton: When the 'Add Payment method' button is tapped.
- MobileAddCreditCard.UseCameraButton: When a user tries to scan a credit card by tapping the 'Use Camera' button.
- obileCreditCardScanner.ScannedCardNumberModified: When a user scans a credit card using the Credit Card Scanner but corrects the scanned number.
- MobileCreditCardScanner.ScannedExpiryMonthModified: When a user scans a credit card using the Credit Card Scanner but corrects the scanned expiry month.
- MobileCreditCardScanner.ScannedExpiryYearModified: When a user scans a credit card using the Credit Card Scanner but corrects the scanned expiry year.

Bug: 989432

Change-Id: I0b0500dbced496eb47deee1d448a2fcb6790dc67
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1784615
Commit-Queue: Tanisha Mandre <tanishamandre@google.com>
Reviewed-by: default avatarJavier Ernesto Flores Robles <javierrobles@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarAlexei Svitkine <asvitkine@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697580}
parent bad8cb95
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
self.personalDataManager->UpdateCreditCard(savedCreditCardCopy); self.personalDataManager->UpdateCreditCard(savedCreditCardCopy);
} else { } else {
base::RecordAction( base::RecordAction(
base::UserMetricsAction("MobileAddCreditCard.CardSaved")); base::UserMetricsAction("MobileAddCreditCard.CreditCardAdded"));
self.personalDataManager->AddCreditCard(creditCard); self.personalDataManager->AddCreditCard(creditCard);
} }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/feature_list.h" #include "base/feature_list.h"
#include "base/mac/foundation_util.h" #include "base/mac/foundation_util.h"
#include "base/metrics/user_metrics.h"
#import "ios/chrome/browser/ui/autofill/cells/autofill_edit_item.h" #import "ios/chrome/browser/ui/autofill/cells/autofill_edit_item.h"
#import "ios/chrome/browser/ui/settings/autofill/autofill_add_credit_card_view_controller_delegate.h" #import "ios/chrome/browser/ui/settings/autofill/autofill_add_credit_card_view_controller_delegate.h"
#import "ios/chrome/browser/ui/settings/autofill/features.h" #import "ios/chrome/browser/ui/settings/autofill/features.h"
...@@ -66,6 +67,15 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -66,6 +67,15 @@ typedef NS_ENUM(NSInteger, ItemType) {
// the UI. // the UI.
@property(nonatomic, strong) NSString* expirationYear; @property(nonatomic, strong) NSString* expirationYear;
// The card number scanned using the credit card scanner.
@property(nonatomic, strong) NSString* scannedCardNumber;
// The expiration month scanned using the credit card scanner.
@property(nonatomic, strong) NSString* scannedExpirationMonth;
// The expiration year scanned using the credit card scanner.
@property(nonatomic, strong) NSString* scannedExpirationYear;
@end @end
@implementation AutofillAddCreditCardViewController @implementation AutofillAddCreditCardViewController
...@@ -252,18 +262,21 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -252,18 +262,21 @@ typedef NS_ENUM(NSInteger, ItemType) {
expirationMonth:(NSString*)expirationMonth expirationMonth:(NSString*)expirationMonth
expirationYear:(NSString*)expirationYear { expirationYear:(NSString*)expirationYear {
if (cardNumber) { if (cardNumber) {
self.scannedCardNumber = cardNumber;
[self updateCellForItemType:ItemTypeCardNumber [self updateCellForItemType:ItemTypeCardNumber
inSectionIdentifier:SectionIdentifierCreditCardDetails inSectionIdentifier:SectionIdentifierCreditCardDetails
withText:cardNumber]; withText:cardNumber];
} }
if (expirationMonth) { if (expirationMonth) {
self.scannedExpirationMonth = expirationMonth;
[self updateCellForItemType:ItemTypeExpirationMonth [self updateCellForItemType:ItemTypeExpirationMonth
inSectionIdentifier:SectionIdentifierCreditCardDetails inSectionIdentifier:SectionIdentifierCreditCardDetails
withText:expirationMonth]; withText:expirationMonth];
} }
if (expirationYear) { if (expirationYear) {
self.scannedExpirationYear = expirationYear;
[self updateCellForItemType:ItemTypeExpirationYear [self updateCellForItemType:ItemTypeExpirationYear
inSectionIdentifier:SectionIdentifierCreditCardDetails inSectionIdentifier:SectionIdentifierCreditCardDetails
withText:expirationYear]; withText:expirationYear];
...@@ -276,6 +289,23 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -276,6 +289,23 @@ typedef NS_ENUM(NSInteger, ItemType) {
- (void)didTapAddButton:(id)sender { - (void)didTapAddButton:(id)sender {
[self updateCreditCardData]; [self updateCreditCardData];
// Metrics logged if the data scanned using the credit card scanner is
// modified by the user.
if (self.scannedCardNumber && self.cardNumber != self.scannedCardNumber) {
base::RecordAction(base::UserMetricsAction(
"MobileCreditCardScannerScannedCardNumberModified"));
}
if (self.scannedExpirationMonth &&
self.expirationMonth != self.scannedExpirationMonth) {
base::RecordAction(base::UserMetricsAction(
"MobileCreditCardScannerScannedExpiryMonthModified"));
}
if (self.scannedExpirationYear &&
self.expirationYear != self.scannedExpirationYear) {
base::RecordAction(base::UserMetricsAction(
"MobileCreditCardScannerScannedExpiryYearModified"));
}
[self.delegate addCreditCardViewController:self [self.delegate addCreditCardViewController:self
addCreditCardWithHolderName:self.cardHolderName addCreditCardWithHolderName:self.cardHolderName
cardNumber:self.cardNumber cardNumber:self.cardNumber
...@@ -360,6 +390,8 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -360,6 +390,8 @@ typedef NS_ENUM(NSInteger, ItemType) {
// Presents the credit card scanner camera screen. // Presents the credit card scanner camera screen.
- (void)handleCameraButton { - (void)handleCameraButton {
base::RecordAction(
base::UserMetricsAction("MobileAddCreditCard.UseCameraButton"));
[self.delegate addCreditCardViewControllerDidUseCamera:self]; [self.delegate addCreditCardViewControllerDidUseCamera:self];
} }
......
...@@ -11550,16 +11550,23 @@ should be able to be added at any place in this file. ...@@ -11550,16 +11550,23 @@ should be able to be added at any place in this file.
<action name="MobileAddCreditCard.AddPaymentMethodButton"> <action name="MobileAddCreditCard.AddPaymentMethodButton">
<owner>gambard@chromium.org</owner> <owner>gambard@chromium.org</owner>
<description> <description>
The user tapped on &quot;Add Payment Method...&quot; in the Settings, User tapped on &quot;Add Payment Method&quot; using the settings payment
Payment Methods menu. methods screen.
</description> </description>
</action> </action>
<action name="MobileAddCreditCard.CardSaved"> <action name="MobileAddCreditCard.CreditCardAdded">
<owner>gambard@chromium.org</owner> <owner>gambard@chromium.org</owner>
<description> <description>
The user saved a new credit card by tapping on &quot;Add&quot; in the User adds a valid credit card using the add credit card screen.
Settings, Add Payment Methods menu. </description>
</action>
<action name="MobileAddCreditCard.UseCameraButton">
<owner>gambard@chromium.org</owner>
<description>
User tapped on &quot;Use Camera&quot; from the settings add credit card
screen.
</description> </description>
</action> </action>
...@@ -11981,27 +11988,51 @@ should be able to be added at any place in this file. ...@@ -11981,27 +11988,51 @@ should be able to be added at any place in this file.
<description>Please enter the description of this user action.</description> <description>Please enter the description of this user action.</description>
</action> </action>
<action name="MobileCreditCardScannerClose"> <action name="MobileCreditCardScanner.Close">
<owner>gambard@chromium.org</owner> <owner>gambard@chromium.org</owner>
<description> <description>
User closed the Credit Card Scanner without scanning a credit card. User closed the Credit Card Scanner without scanning a credit card.
</description> </description>
</action> </action>
<action name="MobileCreditCardScannerError"> <action name="MobileCreditCardScanner.Error">
<owner>gambard@chromium.org</owner> <owner>gambard@chromium.org</owner>
<description> <description>
User closed the Credit Card Scanner from an error dialog. User closed the Credit Card Scanner from an error dialog.
</description> </description>
</action> </action>
<action name="MobileCreditCardScannerScannedCard"> <action name="MobileCreditCardScanner.ScannedCard">
<owner>gambard@chromium.org</owner> <owner>gambard@chromium.org</owner>
<description> <description>
User scanned a credit card using the Credit Card Scanner. User scanned a credit card using the Credit Card Scanner.
</description> </description>
</action> </action>
<action name="MobileCreditCardScanner.ScannedCardNumberModified">
<owner>gambard@chromium.org</owner>
<description>
User scanned a credit card using the Credit Card Scanner and scanned card
number was modified.
</description>
</action>
<action name="MobileCreditCardScanner.ScannedExpiryMonthModified">
<owner>gambard@chromium.org</owner>
<description>
User scanned a credit card using the Credit Card Scanner and scanned card
expiry month was modified.
</description>
</action>
<action name="MobileCreditCardScanner.ScannedExpiryYearModified">
<owner>gambard@chromium.org</owner>
<description>
User scanned a credit card using the Credit Card Scanner and scanned card
expiry year was modified.
</description>
</action>
<action name="MobileCustomFeedback"> <action name="MobileCustomFeedback">
<obsolete> <obsolete>
Deprecated 12/2018. CustomFeedback never shipped to 100% and is no longer Deprecated 12/2018. CustomFeedback never shipped to 100% and is no longer
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment