Skip to content

The open alternative to Salesforce, designed for AI.

fix: bill all events in BillingUsageService.billUsage() instead of only the first one (#16650)

Félix Malfait6682d4eb02c6
diff --git a/packages/twenty-server/src/engine/core-modules/billing/services/billing-usage.service.ts b/packages/twenty-server/src/engine/core-modules/billing/services/billing-usage.service.ts
index ffd79cea6f0..4b78de2a152 100644
--- a/packages/twenty-server/src/engine/core-modules/billing/services/billing-usage.service.ts
+++ b/packages/twenty-server/src/engine/core-modules/billing/services/billing-usage.service.ts
@@ -67,12 +67,16 @@ export class BillingUsageService {
}
try {
- await this.stripeBillingMeterEventService.sendBillingMeterEvent({
- eventName: billingEvents[0].eventName,
- value: billingEvents[0].value,
- stripeCustomerId: workspaceStripeCustomer.stripeCustomerId,
- dimensions: billingEvents[0].dimensions,
- });
+ await Promise.all(
+ billingEvents.map((event) =>
+ this.stripeBillingMeterEventService.sendBillingMeterEvent({
+ eventName: event.eventName,
+ value: event.value,
+ stripeCustomerId: workspaceStripeCustomer.stripeCustomerId,
+ dimensions: event.dimensions,
+ }),
+ ),
+ );
} catch (error) {
throw new BillingException(
`Failed to send billing meter events to Stripe: ${error}`,