Skip to content

feat(notifications): scheduled workflow execution digest emails (paid)#1475

Draft
joelorzet wants to merge 6 commits into
stagingfrom
feat/KEEP-586-failure-digest
Draft

feat(notifications): scheduled workflow execution digest emails (paid)#1475
joelorzet wants to merge 6 commits into
stagingfrom
feat/KEEP-586-failure-digest

Conversation

@joelorzet
Copy link
Copy Markdown

Paid-only (Pro+) scheduled email digest: per org, a daily or weekly summary of workflow executions sent to an explicit subscriber list of org owners/admins managed in the org panel. Free orgs see the feature grayed out with an upgrade path to billing.

What is in it

  • Digest content: total runs, success rate, on-chain transaction count + gas spent, most-executed workflows, and top failing workflows (with last error).
  • Schedule: a k8s CronJob hits GET /api/internal/failure-digest daily at 14:00 UTC via deploy/scripts/digest-cron.sh (internal-service auth). Daily-cadence orgs send each run; weekly-cadence orgs send on Tuesdays (mid-week mornings have the best email engagement). Plan is re-checked at send time so a downgraded org stops receiving digests.
  • Paid gating: a new notifications.failure-digest feature in the registry (requiredPlan: pro, no actionTypes, so it is a pure entitlement). Client grays out the UI via useFeature; the settings API enforces it server-side (402 for free orgs).
  • Settings: GET/PUT /api/organizations/{id}/failure-digest (owner/admin only). Subscribers are restricted to org owners/admins; enabling requires at least one subscriber.
  • UI: a Notifications tab in the manage-orgs modal (enable toggle, frequency, subscriber picker). The dialog is pinned to a fixed size so tabs no longer resize on switch.

Data / migration

New workflow_failure_digest_settings table. The migration is hand-authored (idempotent) because drizzle-kit generate is currently blocked repo-wide by a pre-existing snapshot-chain collision in drizzle/meta (0081-0089) -- unrelated to this change and worth a separate cleanup.

Verification

Unit tests cover the scheduling logic (daily cadence + Tuesday-pinned weekly + window bounds). Type-check and lint pass. Manual: applied the table locally, enabled the digest for a Pro org with a subscriber, and invoked the endpoint to confirm the summary payload.

Out of scope (follow-ups)

The general workflow_failed trigger node, immediate per-failure alerts, non-email channels (Discord/Slack/webhook), and period-over-period trend metrics.

Draft: pending design review of the UI and the digest contents.

joelorzet added 6 commits June 5, 2026 15:37
Per-org config for the scheduled execution digest: enabled flag, daily/
weekly cadence, explicit subscriber user-id list, and last-sent marker.
Migration hand-authored (idempotent) because drizzle-kit generate is
blocked by a pre-existing snapshot-chain collision in drizzle/meta.
Add the notifications.failure-digest feature (requiredPlan: pro). No
actionTypes, so it is a pure plan entitlement -- not a workflow action --
read by useFeature client-side and isFeatureEnabledForOrg server-side.
getOrgFailureDigest aggregates an org's executions over a window (totals,
success rate inputs, on-chain tx count + gas, most-executed, top failing
with last error). isDigestDue pins weekly sends to Tuesday and daily to a
~24h cadence. sendWorkflowFailureDigestEmail renders the summary. Shared
copy lives in digest-messages. Unit tests cover the scheduling logic.
GET /api/internal/failure-digest (internal-service auth) sends due digests
to subscribed members, re-checking the org plan at send time. Wired as a
k8s CronJob running daily at 14:00 UTC via deploy/scripts/digest-cron.sh;
daily-cadence orgs send each run, weekly orgs on Tuesdays. Returns a
reaper-style summary listing the orgs notified (id + name).
GET/PUT /api/organizations/{id}/failure-digest, owner/admin only. GET
returns the config plus the org's owners/admins for the subscriber
picker; PUT validates cadence and that subscribers are current owners/
admins, returns 402 for free orgs and 400 if enabled with no subscriber.
New Notifications tab in the manage-orgs modal (active org, owner/admin):
enable toggle, daily/weekly frequency, owner/admin subscriber checkboxes.
Free orgs see a grayed-out card that routes to /billing. Pin the dialog to
a fixed size with top-aligned content so tabs no longer resize on switch.
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