diff --git a/packages/backend-core/src/events/publishers/license.ts b/packages/backend-core/src/events/publishers/license.ts index d1ff4d7609..094cf7fac1 100644 --- a/packages/backend-core/src/events/publishers/license.ts +++ b/packages/backend-core/src/events/publishers/license.ts @@ -15,17 +15,18 @@ import { async function planChanged( account: Account, - from: PlanType, - to: PlanType, - quantity: number | undefined, - duration: PriceDuration | undefined + opts: { + from: PlanType + to: PlanType + fromQuantity: number | undefined + toQuantity: number | undefined + fromDuration: PriceDuration | undefined + toDuration: PriceDuration | undefined + } ) { const properties: LicensePlanChangedEvent = { accountId: account.accountId, - to, - from, - quantity, - duration, + ...opts, } await publishEvent(Event.LICENSE_PLAN_CHANGED, properties) } diff --git a/packages/backend-core/tests/core/utilities/structures/licenses.ts b/packages/backend-core/tests/core/utilities/structures/licenses.ts index 810f31cf4f..22e73f2871 100644 --- a/packages/backend-core/tests/core/utilities/structures/licenses.ts +++ b/packages/backend-core/tests/core/utilities/structures/licenses.ts @@ -29,7 +29,7 @@ export const plan = (type: PlanType = PlanType.FREE): PurchasedPlan => { type, usesInvoicing: false, model: PlanModel.PER_USER, - price: price(), + price: type !== PlanType.FREE ? price() : undefined, } } diff --git a/packages/types/src/sdk/events/license.ts b/packages/types/src/sdk/events/license.ts index b92c556cc8..12bdd92184 100644 --- a/packages/types/src/sdk/events/license.ts +++ b/packages/types/src/sdk/events/license.ts @@ -5,11 +5,10 @@ export interface LicensePlanChangedEvent { from: PlanType to: PlanType // may not be on historical events - // free plans won't have a duration - duration: PriceDuration | undefined - // may not be on historical events - // free plans won't have a quantity - quantity: number | undefined + fromDuration: PriceDuration | undefined + toDuration: PriceDuration | undefined + fromQuantity: number | undefined + toQuantity: number | undefined } export interface LicenseActivatedEvent {