// Activation nudge (Slice 3): a once-per-user "checking in" email sent T+3 days // after signup when the user still has zero paired screens. Daily sweep at a // fixed UTC hour. Reuses the single Microsoft Graph transport (./email). // // GATING — positive hosted signal, NOT !selfHosted: // This is a daily BULK sweep. A self-hoster who configured Graph but forgot // SELF_HOSTED=true would blast their whole dormant user base with Dan-branded // onboarding mail. So we gate on an explicit HOSTED_INSTANCE=true: if it's not // set, we neither schedule nor send. Hosted prod sets the env var. // // Idempotency: users.activation_nudge_sent_at, stamped after each send; the // query's "IS NULL" guard means a user is nudged at most once. Re-runs are safe. // // Opt-out: users who explicitly turned email alerts off (email_alerts = 0) are // excluded; NULL/unset and on (1) both qualify via COALESCE(...,1)=1. const { db } = require('../db/database'); const { sendEmail } = require('./email'); const NUDGE_HOUR_UTC = 15; // 15:00 UTC daily const LINKS = { player: 'https://screentinker.com/player/', pi: 'https://screentinker.com/guides/raspberry-pi-digital-signage.html', androidTv: 'https://screentinker.com/guides/digital-signage-android-tv.html', selfHosted: 'https://screentinker.com/guides/self-hosted-digital-signage.html', discord: 'https://discord.gg/utTdsrqq4Z', }; function htmlEscape(s) { return String(s).replace(/[&<>"']/g, c => ({ '&':'&','<':'<','>':'>','"':'"',"'":''' }[c])); } // Pure-ASCII plain text (same deliverability rule as the welcome email). function nudgeText(name) { return `Hi ${name}, You signed up for ScreenTinker a few days ago, and I noticed you haven't paired a screen yet. No worries at all. I just wanted to check in and see if anything's getting in the way. If you hit a snag, hit reply and tell me what happened. It comes straight to me and I'll help you sort it. If you just haven't had a chance yet, the fastest way to start is the web player. Turn any browser into a screen in about a minute: -> ${LINKS.player} Or if you're setting up real hardware: - Raspberry Pi: ${LINKS.pi} - Android TV: ${LINKS.androidTv} - Self-hosted: ${LINKS.selfHosted} And the Discord is here if you'd rather ask there: ${LINKS.discord} And if you'd rather I didn't check in, just say the word. - Dan ScreenTinker`; } function nudgeHtml(name) { return `
Hi ${htmlEscape(name)},
You signed up for ScreenTinker a few days ago, and I noticed you haven't paired a screen yet. No worries at all. I just wanted to check in and see if anything's getting in the way.
If you hit a snag, hit reply and tell me what happened. It comes straight to me and I'll help you sort it.
If you just haven't had a chance yet, the fastest way to start is the web player. Turn any browser into a screen in about a minute:
Or if you're setting up real hardware:
And the Discord is here if you'd rather ask there.
And if you'd rather I didn't check in, just say the word.
- Dan
ScreenTinker