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

Function scheduleLifecycleEmail

apps/sim/lib/messaging/lifecycle.ts:24–50  ·  view source on GitHub ↗
({
  userId,
  type,
  delayDays,
}: ScheduleLifecycleEmailOptions)

Source from the content-addressed store, hash-verified

22 * Uses Trigger.dev's built-in delay scheduling — no polling or cron needed.
23 */
24export async function scheduleLifecycleEmail({
25 userId,
26 type,
27 delayDays,
28}: ScheduleLifecycleEmailOptions): Promise<void> {
29 if (!isTriggerDevEnabled || !env.TRIGGER_SECRET_KEY) {
30 logger.info('[lifecycle] Trigger.dev not configured, skipping lifecycle email', {
31 userId,
32 type,
33 })
34 return
35 }
36
37 const delayUntil = new Date(Date.now() + delayDays * 24 * 60 * 60 * 1000)
38
39 await tasks.trigger(
40 LIFECYCLE_EMAIL_TASK_ID,
41 { userId, type },
42 {
43 delay: delayUntil,
44 idempotencyKey: `lifecycle-${type}-${userId}`,
45 region: await resolveTriggerRegion(),
46 }
47 )
48
49 logger.info('[lifecycle] Scheduled lifecycle email', { userId, type, delayDays })
50}

Callers 1

auth.tsFile · 0.90

Calls 2

resolveTriggerRegionFunction · 0.90
infoMethod · 0.80

Tested by

no test coverage detected