Commit 26884382 authored by Sahel Sharify's avatar Sahel Sharify Committed by Commit Bot

Payments journey logger records EVENT_SELECTED_GOOGLE on Desktop

This cl moves setting EVENT_SELECTED_... bits from PaymentRequest::Pay
to PaymentRequest::OnPaymentResponseAvailable. This is because on Desktop
the payment_method name is not available before the payment response.
EVENT_SELECTED_GOOGLE bit is set when the method_name indicates that user
has chosen a Google related payment method.

Bug: 959801
Change-Id: I7c277b62925551c01929ebed4b44495a77fffb05
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1596829Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Commit-Queue: Sahel Sharify <sahel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#657285}
parent 8db4a7b7
......@@ -38,6 +38,11 @@ namespace {
using ::payments::mojom::CanMakePaymentQueryResult;
using ::payments::mojom::HasEnrolledInstrumentQueryResult;
bool IsGooglePaymentMethodInstrumentSelected(const std::string& method_name) {
return method_name == kGooglePayMethodName ||
method_name == kAndroidPayMethodName;
}
mojom::PaymentMethodChangeResponsePtr ConvertToPaymentMethodChangeResponse(
const mojom::PaymentDetailsPtr& details,
const PaymentInstrument& invoked_app) {
......@@ -551,6 +556,28 @@ void PaymentRequest::OnPaymentResponseAvailable(
return;
}
// Log the correct "selected instrument" metric according to its type and
// the method name in response.
DCHECK(state_->selected_instrument());
JourneyLogger::Event selected_event =
JourneyLogger::Event::EVENT_SELECTED_OTHER;
switch (state_->selected_instrument()->type()) {
case PaymentInstrument::Type::AUTOFILL:
selected_event = JourneyLogger::Event::EVENT_SELECTED_CREDIT_CARD;
break;
case PaymentInstrument::Type::SERVICE_WORKER_APP: {
selected_event =
IsGooglePaymentMethodInstrumentSelected(response->method_name)
? JourneyLogger::Event::EVENT_SELECTED_GOOGLE
: JourneyLogger::Event::EVENT_SELECTED_OTHER;
break;
}
case PaymentInstrument::Type::NATIVE_MOBILE_APP:
NOTREACHED();
break;
}
journey_logger_.SetEventOccurred(selected_event);
// If currently interactive, show the processing spinner. Autofill payment
// instruments request a CVC, so they are always interactive at this point. A
// payment handler may elect to be non-interactive by not showing a
......@@ -621,25 +648,11 @@ void PaymentRequest::OnConnectionTerminated() {
void PaymentRequest::Pay() {
journey_logger_.SetEventOccurred(JourneyLogger::EVENT_PAY_CLICKED);
// Log the correct "selected instrument" metric according to type.
DCHECK(state_->selected_instrument());
JourneyLogger::Event selected_event =
JourneyLogger::Event::EVENT_SELECTED_OTHER;
switch (state_->selected_instrument()->type()) {
case PaymentInstrument::Type::AUTOFILL:
selected_event = JourneyLogger::Event::EVENT_SELECTED_CREDIT_CARD;
break;
case PaymentInstrument::Type::SERVICE_WORKER_APP:
selected_event = JourneyLogger::Event::EVENT_SELECTED_OTHER;
if (state_->selected_instrument()->type() ==
PaymentInstrument::Type::SERVICE_WORKER_APP) {
BindPaymentHandlerHost();
break;
case PaymentInstrument::Type::NATIVE_MOBILE_APP:
NOTREACHED();
break;
}
journey_logger_.SetEventOccurred(selected_event);
state_->GeneratePaymentResponse();
}
......
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