MCPcopy Index your code
hub / github.com/simstudioai/sim / sendLifecycleEmail

Function sendLifecycleEmail

apps/sim/background/lifecycle-email.ts:20–57  ·  view source on GitHub ↗
({ userId, type }: LifecycleEmailParams)

Source from the content-addressed store, hash-verified

18}
19
20async function sendLifecycleEmail({ userId, type }: LifecycleEmailParams): Promise<void> {
21 const [userData] = await db.select().from(user).where(eq(user.id, userId)).limit(1)
22
23 if (!userData?.email) {
24 logger.warn('[lifecycle-email] User not found or has no email', { userId, type })
25 return
26 }
27
28 const subscription = await getHighestPrioritySubscription(userId)
29 if (checkEnterprisePlan(subscription)) {
30 logger.info('[lifecycle-email] Skipping lifecycle email for enterprise user', { userId, type })
31 return
32 }
33
34 const { from, replyTo } = getPersonalEmailFrom()
35
36 let html: string
37
38 switch (type) {
39 case 'onboarding-followup':
40 html = await renderOnboardingFollowupEmail(userData.name || undefined)
41 break
42 default:
43 logger.warn('[lifecycle-email] Unknown lifecycle email type', { type })
44 return
45 }
46
47 await sendEmail({
48 to: userData.email,
49 subject: getEmailSubject(type),
50 html,
51 from,
52 replyTo,
53 emailType: 'notifications',
54 })
55
56 logger.info('[lifecycle-email] Sent lifecycle email', { userId, type })
57}
58
59export const lifecycleEmailTask = task({
60 id: LIFECYCLE_EMAIL_TASK_ID,

Callers 1

lifecycle-email.tsFile · 0.85

Calls 9

checkEnterprisePlanFunction · 0.90
getPersonalEmailFromFunction · 0.90
sendEmailFunction · 0.90
getEmailSubjectFunction · 0.90
infoMethod · 0.80
warnMethod · 0.65
eqFunction · 0.50

Tested by

no test coverage detected