Commit fa35085a authored by Jared Saul's avatar Jared Saul Committed by Commit Bot

[Autofill] Log metrics on Autofill StrikeDatabase usage

Records two new metrics situations (local and server for both):
1) How many strikes a card had when it was successfully saved
2) When save is not offered due to being a 3-striked card

Bug: 884817
Change-Id: I225994e6ad210cc6f0d768f209ff17a5cea23532
Reviewed-on: https://chromium-review.googlesource.com/c/1275026
Commit-Queue: Jared Saul <jsaul@google.com>
Commit-Queue: Sebastien Seguin-Gagnon <sebsg@chromium.org>
Reviewed-by: default avatarSebastien Seguin-Gagnon <sebsg@chromium.org>
Reviewed-by: default avatarAlexei Svitkine <asvitkine@chromium.org>
Cr-Commit-Position: refs/heads/master@{#598925}
parent 54a1c93c
......@@ -660,6 +660,14 @@ void AutofillMetrics::LogSubmittedServerCardExpirationStatusMetric(
NUM_SUBMITTED_SERVER_CARD_EXPIRATION_STATUS_METRICS);
}
// static
void AutofillMetrics::LogCreditCardSaveNotOfferedDueToMaxStrikesMetric(
SaveTypeMetric metric) {
UMA_HISTOGRAM_ENUMERATION(
"Autofill.StrikeDatabase.CreditCardSaveNotOfferedDueToMaxStrikes",
metric);
}
// static
void AutofillMetrics::LogUploadDisallowedForNetworkMetric(
const std::string& network) {
......
......@@ -166,6 +166,14 @@ class AutofillMetrics {
NUM_SUBMITTED_SERVER_CARD_EXPIRATION_STATUS_METRICS,
};
// Metric to distinguish between local credit card saves and upload credit
// card saves.
enum class SaveTypeMetric {
LOCAL = 0,
SERVER = 1,
kMaxValue = SERVER,
};
// Metric to measure volume of cards that are disallowed for upload by their
// network, most likely due to their network being blocked by Google Payments.
enum UploadDisallowedForNetworkMetric {
......@@ -857,6 +865,11 @@ class AutofillMetrics {
static void LogSubmittedServerCardExpirationStatusMetric(
SubmittedServerCardExpirationStatusMetric metric);
// When credit card save is not offered (either at all on mobile or by simply
// not showing the bubble on desktop), logs the occurrence.
static void LogCreditCardSaveNotOfferedDueToMaxStrikesMetric(
SaveTypeMetric metric);
// When credit card upload is disallowed for a particular network, logs which
// network was blocked.
static void LogUploadDisallowedForNetworkMetric(const std::string& network);
......
......@@ -16,6 +16,7 @@
#include "base/bind.h"
#include "base/feature_list.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/string16.h"
#include "base/strings/string_piece.h"
......@@ -271,8 +272,16 @@ void CreditCardSaveManager::OnDidUploadCard(
}
if (base::FeatureList::IsEnabled(
features::kAutofillSaveCreditCardUsesStrikeSystem)) {
// Clear all strikes for this card, in case it is later removed.
StrikeDatabase* strike_database = client_->GetStrikeDatabase();
// Log how many strikes the card had when it was saved.
strike_database->GetStrikes(
strike_database->GetKeyForCreditCardSave(
base::UTF16ToUTF8(upload_request_.card.LastFourDigits())),
base::BindRepeating(
&CreditCardSaveManager::LogStrikesPresentWhenCardSaved,
weak_ptr_factory_.GetWeakPtr(),
/*is_local=*/false));
// Clear all strikes for this card, in case it is later removed.
strike_database->ClearAllStrikesForKey(
strike_database->GetKeyForCreditCardSave(
base::UTF16ToUTF8(upload_request_.card.LastFourDigits())),
......@@ -370,6 +379,10 @@ void CreditCardSaveManager::OfferCardLocalSave() {
AutofillMetrics::LogSaveCardWithFirstAndLastNameOffered(
/*is_local=*/true);
}
if (!show_save_prompt_.value()) {
AutofillMetrics::LogCreditCardSaveNotOfferedDueToMaxStrikesMetric(
AutofillMetrics::SaveTypeMetric::LOCAL);
}
}
void CreditCardSaveManager::OfferCardUploadSave() {
......@@ -410,6 +423,10 @@ void CreditCardSaveManager::OfferCardUploadSave() {
AutofillMetrics::UPLOAD_NOT_OFFERED_MAX_STRIKES_ON_MOBILE;
}
LogCardUploadDecisions(upload_decision_metrics_);
if (!show_save_prompt_.value()) {
AutofillMetrics::LogCreditCardSaveNotOfferedDueToMaxStrikesMetric(
AutofillMetrics::SaveTypeMetric::SERVER);
}
}
void CreditCardSaveManager::OnUserDidAcceptLocalSave() {
......@@ -418,8 +435,16 @@ void CreditCardSaveManager::OnUserDidAcceptLocalSave() {
if (base::FeatureList::IsEnabled(
features::kAutofillSaveCreditCardUsesStrikeSystem)) {
// Clear all strikes for this card, in case it is later removed.
StrikeDatabase* strike_database = client_->GetStrikeDatabase();
// Log how many strikes the card had when it was saved.
strike_database->GetStrikes(
strike_database->GetKeyForCreditCardSave(
base::UTF16ToUTF8(local_card_save_candidate_.LastFourDigits())),
base::BindRepeating(
&CreditCardSaveManager::LogStrikesPresentWhenCardSaved,
weak_ptr_factory_.GetWeakPtr(),
/*is_local=*/true));
// Clear all strikes for this card, in case it is later removed.
strike_database->ClearAllStrikesForKey(
strike_database->GetKeyForCreditCardSave(
base::UTF16ToUTF8(local_card_save_candidate_.LastFourDigits())),
......@@ -430,6 +455,15 @@ void CreditCardSaveManager::OnUserDidAcceptLocalSave() {
local_card_save_candidate_);
}
void CreditCardSaveManager::LogStrikesPresentWhenCardSaved(
bool is_local,
const int num_strikes) {
std::string suffix = is_local ? "StrikesPresentWhenLocalCardSaved"
: "StrikesPresentWhenServerCardSaved";
base::UmaHistogramCounts1000("Autofill.StrikeDatabase." + suffix,
num_strikes);
}
void CreditCardSaveManager::SetProfilesForCreditCardUpload(
const CreditCard& card,
payments::PaymentsClient::UploadRequestDetails* upload_request) {
......
......@@ -135,6 +135,9 @@ class CreditCardSaveManager {
const base::string16& context_token,
std::unique_ptr<base::DictionaryValue> legal_message);
// Logs the number of strikes that a card had when save succeeded.
void LogStrikesPresentWhenCardSaved(bool is_local, const int num_strikes);
// Examines |card| and the stored profiles and if a candidate set of profiles
// is found that matches the client-side validation rules, assigns the values
// to |upload_request.profiles|. If any problems are found when determining
......
......@@ -2989,6 +2989,11 @@ uploading your change for review. These are checked by presubmit scripts.
label="CVC fix flow dismissed, user clicked a legal message link"/>
</enum>
<enum name="AutofillSaveType">
<int value="0" label="Local"/>
<int value="1" label="Server"/>
</enum>
<enum name="AutofillScanCreditCardPrompt">
<int value="0" label="Scan card shown"/>
<int value="1" label="Scan card selected"/>
......@@ -7590,6 +7590,18 @@ uploading your change for review.
</summary>
</histogram>
<histogram
name="Autofill.StrikeDatabase.CreditCardSaveNotOfferedDueToMaxStrikes"
enum="AutofillSaveType" expires_after="2019-03-18">
<owner>jsaul@google.com</owner>
<owner>annelim@google.com</owner>
<summary>
Records when credit card save is not offered (either at all on mobile or by
simply not showing the bubble on desktop) due to the candidate card having
too many strikes.
</summary>
</histogram>
<histogram name="Autofill.StrikeDatabase.NthStrikeAdded.CreditCardSave"
units="strikes" expires_after="2019-03-18">
<owner>jsaul@google.com</owner>
......@@ -7601,6 +7613,26 @@ uploading your change for review.
</summary>
</histogram>
<histogram name="Autofill.StrikeDatabase.StrikesPresentWhenLocalCardSaved"
units="strikes" expires_after="2019-03-18">
<owner>jsaul@google.com</owner>
<owner>annelim@google.com</owner>
<summary>
Records the number of &quot;strikes&quot; a given card had when a user opted
to save the card to Chrome.
</summary>
</histogram>
<histogram name="Autofill.StrikeDatabase.StrikesPresentWhenServerCardSaved"
units="strikes" expires_after="2019-03-18">
<owner>jsaul@google.com</owner>
<owner>annelim@google.com</owner>
<summary>
Records the number of &quot;strikes&quot; a given card had when a user
successfully uploaded the card to Google Payments.
</summary>
</histogram>
<histogram name="Autofill.SubmittedCardState" enum="AutofillSubmittedCardState">
<owner>dlkumar@google.com</owner>
<summary>
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