Skip to content

Commit d915407

Browse files
committed
chore(billing): only log a limit email as sent when a recipient actually received it
1 parent 9981a20 commit d915407

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

apps/sim/lib/billing/core/limit-notifications.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ export async function maybeSendLimitThresholdEmail(params: {
228228
const percentUsed = Math.min(100, Math.round(percent))
229229
const upgradeLink = `${getBaseUrl()}${buildUpgradeHref(params.workspaceId, category)}`
230230

231+
let sent = 0
231232
for (const r of recipients) {
232233
// Isolate per-recipient failures so one bad send doesn't skip the rest.
233234
try {
@@ -247,6 +248,7 @@ export async function maybeSendLimitThresholdEmail(params: {
247248
html,
248249
emailType: 'notifications',
249250
})
251+
sent++
250252
} catch (sendError) {
251253
logger.error('Failed to send limit email', {
252254
category,
@@ -256,12 +258,9 @@ export async function maybeSendLimitThresholdEmail(params: {
256258
}
257259
}
258260

259-
logger.info('Sent usage-limit threshold email', {
260-
category,
261-
scope,
262-
kind,
263-
percentUsed,
264-
})
261+
if (sent > 0) {
262+
logger.info('Sent usage-limit threshold email', { category, scope, kind, percentUsed, sent })
263+
}
265264
} catch (error) {
266265
logger.error('Failed to send usage-limit threshold email', {
267266
category: params.category,

0 commit comments

Comments
 (0)