Skip to content

Admin Alerting Setup (onset-web)

This config evaluates Supabase admin metrics and routes alerts to SendGrid, Slack, and/or PagerDuty.

Endpoint

  • POST /api/admin/alerts
  • Header: Authorization: Bearer <ONSET_ADMIN_ALERTS_TOKEN>
  • Optional query: ?dry_run=1 (evaluate thresholds without sending notifications)

Required Environment Variables

Core:

  • ONSET_ADMIN_ALERTS_TOKEN
  • SUPABASE_URL
  • SUPABASE_ANON_KEY
  • ADMIN_DASHBOARD_SECRET
  • SENDGRID_API_KEY

Destinations:

  • ALERT_EMAIL_TO (comma-separated, e.g. ops@theonset.app,founder@theonset.app)
  • ALERT_SLACK_WEBHOOK_URL (optional)
  • PAGERDUTY_ROUTING_KEY (optional)

Threshold overrides (optional):

  • ALERT_MAX_SECURITY_EVENTS_24H (default 50)
  • ALERT_MAX_FLAGGED_24H (default 5)
  • ALERT_MIN_PAYWALL_SHOWN_24H (default 20)
  • ALERT_MIN_CONVERSION_RATIO (default 0.02)

GitHub Actions Scheduler

Workflow: .github/workflows/admin-alert-check.yml

Set GitHub secrets in onset-web repo:

  • ONSET_WEB_BASE_URL (e.g. https://theonset.app)
  • ONSET_ADMIN_ALERTS_TOKEN

The workflow runs weekly (Sunday at 19:00 UTC) and calls /api/admin/alerts.

Email cadence controls (optional, defaults shown):

  • ALERT_EMAIL_WEEKLY_SUNDAY_ONLY=true
  • ALERT_EMAIL_WEEKLY_DAY_UTC=0 (0=Sunday)
  • ALERT_EMAIL_WEEKLY_TIME_ENFORCED=true
  • ALERT_EMAIL_WEEKLY_HOUR_UTC=19
  • ALERT_EMAIL_WEEKLY_MINUTE_UTC=0

With these defaults, email sends only once per week at Sunday 19:00 UTC, avoiding repeated alerts throughout Sunday.

Manual Test

Dry run:

curl -sS -X POST "https://theonset.app/api/admin/alerts?dry_run=1" \
  -H "Authorization: Bearer $ONSET_ADMIN_ALERTS_TOKEN" \
  -H "Content-Type: application/json"

Live run:

curl -sS -X POST "https://theonset.app/api/admin/alerts" \
  -H "Authorization: Bearer $ONSET_ADMIN_ALERTS_TOKEN" \
  -H "Content-Type: application/json"