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
This commit is contained in:
Rebeka Dekany
2026-01-07 13:33:49 +01:00
committed by Copybot
parent 16b83b128b
commit 5c61ea53d5

View File

@@ -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'