Jelajahi Sumber

Include Stripe couponCode and promotionCode in analytics events (#29873)

* Include valid couponCode and promotionCode in `payment-page-view` and `payment-page-form-submit` analytics events

* Update payment event types

* Remove obsolete comment

* fix: only send validated coupon and promotion codes in analytics event

* Add coupon name for the analytics events

* Update test to include the coupon name for analytics

* Remove coupon code from analytics

* Simplify promotion code validation using coupon.code

* Remove undefined

* Allow access to promotion code

* Remove `lastValidatedPromotionCode` and compare against coupon code from the preview response

* Fix test setup to initialize coupon code

* Keep the submit button enabled only when the coupon code is either empty or successfully validated by the backend

* Update test coupon code value to TEST_COUPON

GitOrigin-RevId: b12fa147d91fd3b90b59bc77868a0786ddb633b7
Rebeka Dekany 7 bulan lalu
induk
melakukan
5c61ea53d5
1 mengubah file dengan 3 tambahan dan 1 penghapusan
  1. 3 1
      services/web/types/subscription/analytics-event.ts

+ 3 - 1
services/web/types/subscription/analytics-event.ts

@@ -8,7 +8,6 @@ import { RecurlyPlanCode } from './plan'
 type PaymentPageFormSubmitEventBaseSegmentation = {
   currencyCode: CurrencyCode
   plan_code?: string
-  coupon_code: string
   isPaypal: boolean
   upgradeType: 'standalone'
   referrer?: string
@@ -16,6 +15,8 @@ type PaymentPageFormSubmitEventBaseSegmentation = {
 
 type PaymentPageFormSubmitEventStripeSegmentation =
   PaymentPageFormSubmitEventBaseSegmentation & {
+    couponName?: string
+    promotionCode?: string
     payment_provider: StripePaymentProviderService
     stripe_price_id: string
     stripe_price_lookup_key: string
@@ -23,6 +24,7 @@ type PaymentPageFormSubmitEventStripeSegmentation =
 
 type PaymentPageFormSubmitEventRecurlySegmentation =
   PaymentPageFormSubmitEventBaseSegmentation & {
+    coupon_code?: string
     payment_provider: Exclude<
       PaymentProvider['service'],
       'stripe-us' | 'stripe-uk'