@@ -17,7 +17,10 @@ import {
1717 type SubPlatCmsMetricsData ,
1818} from './glean.types' ;
1919import { Inject , Injectable } from '@nestjs/common' ;
20- import { PaymentProvidersType } from '@fxa/payments/customer' ;
20+ import {
21+ PaymentProvidersType ,
22+ type SubPlatPaymentMethodType ,
23+ } from '@fxa/payments/customer' ;
2124import { type PaymentsGleanServerEventsLogger } from './glean.provider' ;
2225import { mapSession } from './utils/mapSession' ;
2326import { mapUtm } from './utils/mapUtm' ;
@@ -86,13 +89,16 @@ export class PaymentsGleanManager {
8689 cmsMetricsData : CmsMetricsData ;
8790 experimentationData : ExperimentationData ;
8891 } ,
89- paymentProvider ?: PaymentProvidersType
92+ paymentProvider ?: PaymentProvidersType ,
93+ paymentMethod ?: SubPlatPaymentMethodType
9094 ) {
9195 if ( this . isEnabled ) {
9296 this . paymentsGleanServerEventsLogger . recordPaySetupSubmit ( {
93- ...this . populateCommonMetrics ( metrics ) ,
97+ ...this . populateCommonMetrics ( metrics , paymentProvider , paymentMethod ) ,
9498 subscription_payment_provider :
9599 normalizeGleanFalsyValues ( paymentProvider ) ,
100+ subscription_payment_method :
101+ normalizeGleanFalsyValues ( paymentMethod ) ,
96102 } ) ;
97103 }
98104 }
@@ -104,15 +110,18 @@ export class PaymentsGleanManager {
104110 cmsMetricsData : CmsMetricsData ;
105111 experimentationData : ExperimentationData ;
106112 } ,
107- paymentProvider ?: PaymentProvidersType
113+ paymentProvider ?: PaymentProvidersType ,
114+ paymentMethod ?: SubPlatPaymentMethodType
108115 ) {
109- const commonMetrics = this . populateCommonMetrics ( metrics ) ;
116+ const commonMetrics = this . populateCommonMetrics ( metrics , paymentProvider , paymentMethod ) ;
110117
111118 if ( this . isEnabled ) {
112119 this . paymentsGleanServerEventsLogger . recordPaySetupSuccess ( {
113120 ...commonMetrics ,
114121 subscription_payment_provider :
115122 normalizeGleanFalsyValues ( paymentProvider ) ,
123+ subscription_payment_method :
124+ normalizeGleanFalsyValues ( paymentMethod ) ,
116125 } ) ;
117126 }
118127 }
@@ -144,7 +153,7 @@ export class PaymentsGleanManager {
144153 } ,
145154 paymentProvider ?: PaymentProvidersType
146155 ) {
147- const commonMetrics = this . populateCommonMetrics ( metrics ) ;
156+ const commonMetrics = this . populateCommonMetrics ( metrics , paymentProvider ) ;
148157
149158 if ( this . isEnabled ) {
150159 this . paymentsGleanServerEventsLogger . recordSubscriptionEnded ( {
@@ -243,6 +252,7 @@ export class PaymentsGleanManager {
243252 subscription_interval : cms . interval ?? '' ,
244253 subscription_offering_id : cms . offeringId ?? '' ,
245254 subscription_payment_provider : PLACEHOLDER_FUTURE_USE ,
255+ subscription_payment_method : PLACEHOLDER_FUTURE_USE ,
246256 subscription_plan_id : stripe . priceId ?? '' ,
247257 subscription_product_id : stripe . productId ?? '' ,
248258 subscription_promotion_code : stripe . couponCode ?? '' ,
@@ -266,13 +276,17 @@ export class PaymentsGleanManager {
266276 } ;
267277 }
268278
269- private populateCommonMetrics ( metrics : {
270- commonMetricsData ?: CommonMetrics ;
271- cartMetricsData ?: CartMetrics ;
272- cmsMetricsData ?: CmsMetricsData ;
273- experimentationData ?: ExperimentationData ;
274- subscriptionCancellationData ?: SubscriptionCancellationData ;
275- } ) {
279+ private populateCommonMetrics (
280+ metrics : {
281+ commonMetricsData ?: CommonMetrics ;
282+ cartMetricsData ?: CartMetrics ;
283+ cmsMetricsData ?: CmsMetricsData ;
284+ experimentationData ?: ExperimentationData ;
285+ subscriptionCancellationData ?: SubscriptionCancellationData ;
286+ } ,
287+ paymentProvider ?: PaymentProvidersType ,
288+ paymentMethod ?: SubPlatPaymentMethodType
289+ ) {
276290 const emptyCommonMetricsData : CommonMetrics = {
277291 ipAddress : '' ,
278292 deviceType : '' ,
@@ -325,6 +339,8 @@ export class PaymentsGleanManager {
325339 cartMetricsData,
326340 cmsMetricsData,
327341 subscriptionCancellationData,
342+ paymentProvider,
343+ paymentMethod,
328344 isFreeTrial : commonMetricsData . isFreeTrial ,
329345 } ) ,
330346 ...mapUtm ( commonMetricsData . searchParams ) ,
0 commit comments