1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
// Copyright 2025 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_METRICS_PAYMENTS_BNPL_METRICS_H_
#define COMPONENTS_AUTOFILL_CORE_BROWSER_METRICS_PAYMENTS_BNPL_METRICS_H_
#include <string_view>
#include "components/autofill/core/browser/data_model/payments/bnpl_issuer.h"
#include "components/autofill/core/browser/payments/payments_window_manager.h"
namespace autofill::autofill_metrics {
using BnplFlowResult = payments::PaymentsWindowManager::BnplFlowResult;
// The reason why a BNPL suggestion was not shown on the page.
//
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class BnplSuggestionNotShownReason {
// The checkout amount could not be extracted from the page. This value is
// necessary to determine BNPL eligibility for the purchase.
kAmountExtractionFailure = 0,
// The checkout amount extracted from the page is not supported by any of the
// available BNPL issuers.
kCheckoutAmountNotSupported = 1,
kMaxValue = kCheckoutAmountNotSupported,
};
// Enum to track the result of a corresponding BnplTosDialog that was shown.
//
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
//
// LINT.IfChange(BnplTosDialogResult)
enum class BnplTosDialogResult {
kCancelButtonClicked = 0,
kAcceptButtonClicked = 1,
kMaxValue = kAcceptButtonClicked,
};
// LINT.ThenChange(/tools/metrics/histograms/metadata/autofill/enums.xml:BnplTosDialogResult)
// The dialog close reason of select BNPL issuer dialog.
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
//
// LINT.IfChange(SelectBnplIssuerDialogResult)
enum class SelectBnplIssuerDialogResult {
kCancelButtonClicked = 0,
kIssuerSelected = 1,
kMaxValue = kIssuerSelected,
};
// LINT.ThenChange(/tools/metrics/histograms/metadata/autofill/enums.xml:SelectBnplIssuerDialogResult)
// Returns the histogram suffix corresponding to the given issuer_id.
std::string GetHistogramSuffixFromIssuerId(
autofill::BnplIssuer::IssuerId issuer_id);
// Converts a BnplFlowResult enum to its string representation.
std::string ConvertBnplFlowResultToString(BnplFlowResult result);
// LINT.IfChange(BnplFormEvent)
// All BNPL Form Events are logged once per page load.
//
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class BnplFormEvent {
// Payments autofill suggestions were shown on a BNPL-eligible merchant.
kSuggestionsShown = 0,
// The BNPL suggestion was added to the payments autofill dropdown and shown
// to the user.
kBnplSuggestionShown = 1,
// A BNPL suggestion was accepted on the current page.
kBnplSuggestionAccepted = 2,
// A form was filled with an Affirm VCN.
kFormFilledWithAffirm = 3,
// A form was filled with a Zip VCN.
kFormFilledWithZip = 4,
// A form was filled with an Afterpay VCN.
kFormFilledWithAfterpay = 5,
// A form was submitted with an Affirm VCN.
kFormSubmittedWithAffirm = 6,
// A form was submitted with a Zip VCN.
kFormSubmittedWithZip = 7,
// A form was submitted with an Afterpay VCN.
kFormSubmittedWithAfterpay = 8,
kMaxValue = kFormSubmittedWithAfterpay,
};
// LINT.ThenChange(/tools/metrics/histograms/metadata/autofill/enums.xml:BnplFormEvent)
// Logs if the buy-now-pay-later preference is changed by the user through the
// pay-over-time toggle in the payment methods settings page. Records true when
// the user switches on buy-now-pay-later. Records false when the user switches
// off buy-now-pay-later.
void LogBnplPrefToggled(bool enabled);
// Logs the number of BNPL issuers synced at startup.
void LogBnplIssuersSyncedCountAtStartup(int count);
// Logs that the BNPL ToS dialog was shown.
void LogBnplTosDialogShown(autofill::BnplIssuer::IssuerId issuer_id);
// Logs that the BNPL ToS dialog closed reason.
void LogBnplTosDialogResult(BnplTosDialogResult result,
autofill::BnplIssuer::IssuerId issuer_id);
// Logs the select BNPL issuer dialog result.
void LogSelectBnplIssuerDialogResult(SelectBnplIssuerDialogResult result);
// Logs the selection of BNPL issuer from the select BNPL issuer dialog.
void LogBnplIssuerSelection(autofill::BnplIssuer::IssuerId issuer_id);
// Logs that the BNPL suggestion was not shown and the reason why.
void LogBnplSuggestionNotShownReason(BnplSuggestionNotShownReason reason);
// Logs that the BNPL popup window was shown.
void LogBnplPopupWindowShown(autofill::BnplIssuer::IssuerId issuer_id);
// Logs the result of the BNPL popup window.
void LogBnplPopupWindowResult(autofill::BnplIssuer::IssuerId issuer_id,
BnplFlowResult result);
// Logs the duration a user took to go through the BNPL flow inside of the
// pop-up window. Broken down by issuer and result, because each issuer and
// each result should be looked at separately.
void LogBnplPopupWindowLatency(base::TimeDelta duration,
autofill::BnplIssuer::IssuerId issuer_id,
BnplFlowResult result);
// Logs BNPL form events. Please refer to `BnplFormEvent` for the possible
// enumerations that can be logged.
void LogBnplFormEvent(BnplFormEvent event);
// Logs that a form was filled with the BNPL issuer VCN.
void LogFormFilledWithBnplVcn(autofill::BnplIssuer::IssuerId issuer_id);
// Logs that a form was submitted with the BNPL issuer VCN.
void LogFormSubmittedWithBnplVcn(autofill::BnplIssuer::IssuerId issuer_id);
// Logs that the BNPL issuer selection dialog was shown.
void LogBnplSelectionDialogShown();
} // namespace autofill::autofill_metrics
#endif // COMPONENTS_AUTOFILL_CORE_BROWSER_METRICS_PAYMENTS_BNPL_METRICS_H_
|