Skip to content

Commit e060d50

Browse files
committed
fix(email): prevent double email for free users at 80%, fix subject line
1 parent b48d754 commit e060d50

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

apps/sim/components/emails/subjects.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export function getEmailSubject(type: EmailSubjectType): string {
5151
case 'usage-threshold':
5252
return `You're nearing your monthly budget on ${brandName}`
5353
case 'free-tier-upgrade':
54-
return `You're at 90% of your free credits on ${brandName}`
54+
return `You're at 80% of your free credits on ${brandName}`
5555
case 'plan-welcome-pro':
5656
return `Your Pro plan is now active on ${brandName}`
5757
case 'plan-welcome-team':

apps/sim/lib/billing/core/usage.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -715,18 +715,16 @@ export async function maybeSendUsageThresholdEmail(params: {
715715
const baseUrl = getBaseUrl()
716716
const isFreeUser = params.planName === 'Free'
717717

718-
// Check for 80% threshold (all users)
718+
// Check for 80% threshold (paid users only — free users get a more specific email below)
719719
const crosses80 = params.percentBefore < 80 && params.percentAfter >= 80
720-
// Check for 80% threshold (free users only)
721-
const crosses80Free = params.percentBefore < 80 && params.percentAfter >= 80
722720
// Check for 100% threshold (free users only — credits exhausted)
723721
const crosses100 = params.percentBefore < 100 && params.percentAfter >= 100
724722

725723
// Skip if no thresholds crossed
726-
if (!crosses80 && !crosses80Free && !crosses100) return
724+
if (!crosses80 && !crosses100) return
727725

728-
// For 80% threshold email (all users)
729-
if (crosses80) {
726+
// For 80% threshold email (paid users only)
727+
if (crosses80 && !isFreeUser) {
730728
const ctaLink = `${baseUrl}/workspace?billing=usage`
731729
const sendTo = async (email: string, name?: string) => {
732730
const prefs = await getEmailPreferences(email)
@@ -781,7 +779,7 @@ export async function maybeSendUsageThresholdEmail(params: {
781779
}
782780

783781
// For 80% threshold email (free users only)
784-
if (crosses80Free && isFreeUser) {
782+
if (crosses80 && isFreeUser) {
785783
const upgradeLink = `${baseUrl}/workspace?billing=upgrade`
786784
const sendFreeTierEmail = async (email: string, name?: string) => {
787785
const prefs = await getEmailPreferences(email)

0 commit comments

Comments
 (0)