feat(notifications): scheduled workflow execution digest emails (paid)#1475
Draft
joelorzet wants to merge 6 commits into
Draft
feat(notifications): scheduled workflow execution digest emails (paid)#1475joelorzet wants to merge 6 commits into
joelorzet wants to merge 6 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
GET /api/internal/failure-digestdaily at 14:00 UTC viadeploy/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.notifications.failure-digestfeature in the registry (requiredPlan: pro, no actionTypes, so it is a pure entitlement). Client grays out the UI viauseFeature; the settings API enforces it server-side (402 for free orgs)./api/organizations/{id}/failure-digest(owner/admin only). Subscribers are restricted to org owners/admins; enabling requires at least one subscriber.Data / migration
New
workflow_failure_digest_settingstable. The migration is hand-authored (idempotent) becausedrizzle-kit generateis currently blocked repo-wide by a pre-existing snapshot-chain collision indrizzle/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_failedtrigger 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.