From 9647ac5deec4c452441dc310faccd16fd087ef9f Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Tue, 2 May 2023 20:08:51 +0100 Subject: [PATCH] Create hubspot expansions and churns as users are added and deleted --- .../src/events/publishers/license.ts | 17 +++++++++-------- .../tests/core/utilities/structures/licenses.ts | 2 +- packages/types/src/sdk/events/license.ts | 9 ++++----- yarn.lock | 12 ++++++------ 4 files changed, 20 insertions(+), 20 deletions(-) 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 { diff --git a/yarn.lock b/yarn.lock index 3b403d6444..423f58780d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1486,15 +1486,15 @@ pouchdb-promise "^6.0.4" through2 "^2.0.0" -"@budibase/pro@2.5.6-alpha.41": - version "2.5.6-alpha.41" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.5.6-alpha.41.tgz#2632b398159211bf64bf6caff9753c877b6fc09d" - integrity sha512-8Zfm+RtcXY77gdXXHti8QT+Vt+1ApuVqYL3KCkxBVbpzgQci/F3mipNXUX8bEy/y+QYAdgn6psDTWAqyr9VALg== +"@budibase/pro@2.5.6-alpha.42": + version "2.5.6-alpha.42" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.5.6-alpha.42.tgz#15ec86d9918b7d58e3236240afda31309f3162ae" + integrity sha512-aes19IVAEGqf0YPLJMnOKHv99AR6LO8jMpPVCbSZcZODS3byxh9kC2+sWH1mAd781zymyN79HnwGrVJNOdV8jw== dependencies: - "@budibase/backend-core" "2.5.6-alpha.41" + "@budibase/backend-core" "2.5.6-alpha.42" "@budibase/shared-core" "2.4.44-alpha.1" "@budibase/string-templates" "2.4.44-alpha.1" - "@budibase/types" "2.5.6-alpha.41" + "@budibase/types" "2.5.6-alpha.42" "@koa/router" "8.0.8" bull "4.10.1" joi "17.6.0"