diff --git a/services/web/app/src/Features/Subscription/RecurlyEventHandler.js b/services/web/app/src/Features/Subscription/RecurlyEventHandler.js index d97d57ecba..e0d2531239 100644 --- a/services/web/app/src/Features/Subscription/RecurlyEventHandler.js +++ b/services/web/app/src/Features/Subscription/RecurlyEventHandler.js @@ -66,6 +66,7 @@ async function _sendSubscriptionResumedEvent(userId, eventData) { { plan_code: planCode, subscriptionId, + payment_provider: 'recurly', } ) AnalyticsManager.setUserPropertyForUserInBackground( @@ -87,6 +88,7 @@ async function _sendSubscriptionPausedEvent(userId, eventData) { pause_length: pauseLength, plan_code: planCode, subscriptionId, + payment_provider: 'recurly', } ) AnalyticsManager.setUserPropertyForUserInBackground( @@ -108,6 +110,7 @@ async function _sendSubscriptionStartedEvent(userId, eventData) { is_trial: isTrial, has_ai_add_on: hasAiAddOn, subscriptionId, + payment_provider: 'recurly', } ) AnalyticsManager.setUserPropertyForUserInBackground( @@ -154,6 +157,7 @@ async function _sendSubscriptionUpdatedEvent(userId, eventData) { is_trial: isTrial, has_ai_add_on: hasAiAddOn, subscriptionId, + payment_provider: 'recurly', } ) AnalyticsManager.setUserPropertyForUserInBackground( @@ -185,6 +189,7 @@ async function _sendSubscriptionCancelledEvent(userId, eventData) { is_trial: isTrial, has_ai_add_on: hasAiAddOn, subscriptionId, + payment_provider: 'recurly', } ) AnalyticsManager.setUserPropertyForUserInBackground( @@ -211,6 +216,7 @@ async function _sendSubscriptionExpiredEvent(userId, eventData) { is_trial: isTrial, has_ai_add_on: hasAiAddOn, subscriptionId, + payment_provider: 'recurly', } ) AnalyticsManager.setUserPropertyForUserInBackground( @@ -242,6 +248,7 @@ async function _sendSubscriptionRenewedEvent(userId, eventData) { is_trial: isTrial, has_ai_add_on: hasAiAddOn, subscriptionId, + payment_provider: 'recurly', } ) AnalyticsManager.setUserPropertyForUserInBackground( @@ -272,6 +279,7 @@ async function _sendSubscriptionReactivatedEvent(userId, eventData) { quantity, has_ai_add_on: hasAiAddOn, subscriptionId, + payment_provider: 'recurly', } ) AnalyticsManager.setUserPropertyForUserInBackground( @@ -318,6 +326,7 @@ async function _sendInvoicePaidEvent(userId, eventData) { taxInCents, country, collectionMethod, + payment_provider: 'recurly', ...subscriptionIds, } ) diff --git a/services/web/test/unit/src/Subscription/RecurlyEventHandlerTests.js b/services/web/test/unit/src/Subscription/RecurlyEventHandlerTests.js index 4928f81e0d..2528f0a451 100644 --- a/services/web/test/unit/src/Subscription/RecurlyEventHandlerTests.js +++ b/services/web/test/unit/src/Subscription/RecurlyEventHandlerTests.js @@ -62,6 +62,7 @@ describe('RecurlyEventHandler', function () { is_trial: true, has_ai_add_on: false, subscriptionId: this.eventData.subscription.uuid, + payment_provider: 'recurly', } ) sinon.assert.calledWith( @@ -116,6 +117,7 @@ describe('RecurlyEventHandler', function () { is_trial: false, has_ai_add_on: false, subscriptionId: this.eventData.subscription.uuid, + payment_provider: 'recurly', } ) sinon.assert.calledWith( @@ -149,6 +151,7 @@ describe('RecurlyEventHandler', function () { is_trial: true, has_ai_add_on: false, subscriptionId: this.eventData.subscription.uuid, + payment_provider: 'recurly', } ) sinon.assert.calledWith( @@ -187,6 +190,7 @@ describe('RecurlyEventHandler', function () { is_trial: true, has_ai_add_on: false, subscriptionId: this.eventData.subscription.uuid, + payment_provider: 'recurly', } ) sinon.assert.calledWith( @@ -219,6 +223,7 @@ describe('RecurlyEventHandler', function () { is_trial: true, has_ai_add_on: false, subscriptionId: this.eventData.subscription.uuid, + payment_provider: 'recurly', } ) sinon.assert.calledWith( @@ -256,6 +261,7 @@ describe('RecurlyEventHandler', function () { is_trial: true, has_ai_add_on: false, subscriptionId: this.eventData.subscription.uuid, + payment_provider: 'recurly', } ) }) @@ -274,6 +280,7 @@ describe('RecurlyEventHandler', function () { quantity: 1, has_ai_add_on: false, subscriptionId: this.eventData.subscription.uuid, + payment_provider: 'recurly', } ) }) @@ -313,6 +320,7 @@ describe('RecurlyEventHandler', function () { collectionMethod: invoice.collection_method, subscriptionId1: invoice.subscription_ids[0], subscriptionId2: invoice.subscription_ids[1], + payment_provider: 'recurly', } ) }) diff --git a/services/web/types/stripe/webhook-event.ts b/services/web/types/stripe/webhook-event.ts index a53c03f440..c15f53feea 100644 --- a/services/web/types/stripe/webhook-event.ts +++ b/services/web/types/stripe/webhook-event.ts @@ -1,3 +1,5 @@ +import Stripe from 'stripe' + type StripeWebhookEventType = | 'customer.subscription.created' | 'customer.subscription.updated' @@ -6,8 +8,7 @@ type StripeWebhookEventType = export type CustomerSubscriptionWebhookEvent = { type: StripeWebhookEventType data: { - object: { - id: string + object: Stripe.Subscription & { metadata: { adminUserId?: string }