Skip to content

feat(leads): notify founder on a genuinely external lead#33

Merged
asafamos merged 1 commit into
mainfrom
feat/lead-notifications
Jun 5, 2026
Merged

feat(leads): notify founder on a genuinely external lead#33
asafamos merged 1 commit into
mainfrom
feat/lead-notifications

Conversation

@asafamos

@asafamos asafamos commented Jun 5, 2026

Copy link
Copy Markdown
Owner

Why

The first real external lead (info@ourlivesapp.com, 2 Jun) sat undiscovered for 3 days — surfaced only on a manual /admin refresh. There was no notification path. This closes that gap.

What

  • lib/internal.ts (new) — shared internal-traffic detection, extracted from app/api/admin/summary/route.ts (the only copy). Both the dashboard and the lead routes now use it, so the "internal vs external" rule can't drift between them. Net -59 lines in the summary route.
  • sendLeadNotificationEmail() in lib/billing/email.ts — best-effort founder ping via the existing Resend client. Never throws — a notification failure can't break a lead capture. Recipient defaults to asaf@amoss.co.il (override via LEAD_NOTIFY_TO). No-ops if Resend isn't configured.
  • Wired both lead-write paths (/api/lead, /api/free-scan) — notify only when the lead is brand-new (not an idempotent re-subscribe) and external (not a self-test / health probe).

Notes

  • Zero new prod env required — Resend already powers the welcome emails; LEAD_NOTIFY_TO is optional.
  • Re-subscribe detection is fail-closed: a KV lookup error is treated as not-new, so a transient blip can't spam you.

Verification

  • tsc --noEmit → exit 0
  • eslint (all changed files) → exit 0
  • Gating logic unit-checked against the real dashboard leads: NOTIFY for info@ourlivesapp.com + generic strangers; SKIP for test+verify-*@gmail.com, *@axle-test.local, asaf@*, and empty.

🤖 Generated with Claude Code

The first real external lead (info@ourlivesapp.com) sat undiscovered for 3 days
— surfaced only on a manual /admin refresh. There was no notification path.

- New lib/internal.ts: shared internal-traffic detection (extracted from the
  admin summary route, which was the only copy — now reused, can't drift).
- New sendLeadNotificationEmail() in lib/billing/email.ts: best-effort founder
  ping via the existing Resend client. Never throws — a notification failure
  can't break a lead capture. Recipient defaults to asaf@amoss.co.il, override
  with LEAD_NOTIFY_TO. No-ops if Resend isn't configured.
- Wire both lead-write paths (/api/lead, /api/free-scan): notify only for a
  brand-new (not re-subscribe) AND external (not self-test/probe) email.

Needs no new prod env — Resend already powers welcome emails. Verified: tsc +
eslint clean, and the gating logic correctly NOTIFYs for strangers and SKIPs
every founder/test/probe address.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
axle Ready Ready Preview, Comment Jun 5, 2026 7:05pm

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown

✅ No accessibility violations detected

Scanned http://localhost:3000 at 2026-06-05T19:04:57.481Z

axe-core automated checks catch roughly 57% of WCAG issues. Manual review still recommended.

Powered by axle · Remediation assistance, not compliance certification.

@asafamos asafamos merged commit e94dced into main Jun 5, 2026
4 checks passed
@asafamos asafamos deleted the feat/lead-notifications branch June 5, 2026 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant