Skip to content

feat(webhooks): honour per-webhook event subscriptions - #1239

Merged
gkhngyk merged 29 commits into
ansvisor:mainfrom
knockknock10:feature/webhook-event-subscriptions-911
Oct 20, 2026
Merged

gkhngyk merged 29 commits into
ansvisor:mainfrom
knockknock10:feature/webhook-event-subscriptions-911

Conversation

@knockknock10

Copy link
Copy Markdown
Contributor

Summary

  • Add per-webhook event checkboxes for Opportunity sent, Daily Pulse created, and Action Center task sent.
  • Persist selected event subscriptions from Content → Configure Webhook.
  • Filter generic event dispatch using the webhook's events array and require opportunity.sent for single and bulk content sends.
  • Keep webhook.test independent of saved subscriptions.
  • Add a migration that backfills existing webhooks with the events they currently receive, updates the default, and regenerate supabase/schema.sql.
  • Document event subscriptions and the Action Center task payload.
  • Add tests for event-filtered dispatch and best-effort failure handling.

Related issue

Closes #911

Type of change

  • feat — New feature
  • test — Adding or updating tests
  • docs — Documentation update

Validation

  • Server test suite: 1,821 tests passed
  • Server ESLint
  • Server Prettier check
  • Web Prettier check
  • Web ESLint
  • Web TypeScript typecheck
  • Full web build

The web checks still need confirmation from CI. The migration was added and supabase/schema.sql was regenerated as required by CONTRIBUTING.md.

Copilot AI balanced review requested due to automatic review settings October 20, 2026 03:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this covers #911 well. The backfill keeps every existing webhook on the events it gets today, and adding action_task.sent is right, since it goes through dispatchBrandWebhook too.

To change:

  1. Migration number. Open PRs already use 00188–00197, so please rename the file to 00198_webhook_event_subscriptions.sql, fix its header, and rebuild supabase/schema.sql with bash supabase/build-schema.sh. If the number moves again before merge, I'll tell you.
  2. Send to webhook with the event unticked. hasActiveWebhook (web/src/lib/actions/action-task-send.ts) ignores events, so the drawer still offers the button. Clicking it then returns 409 no_webhook: "This brand has no active webhook…". Content has the same problem (content.js:856, :1039: "No workflow connected"). Check the event in hasActiveWebhook, and return a distinct "not subscribed" message on both paths.

Smaller:

  • Constrain events to the three names: a check (events <@ array[...]), or a whitelist in saveWebhookConfig.
  • Saving with no event ticked leaves a webhook that looks connected but gets only test events. Require one, or say so.
  • In docs/guides/daily-pulse.mdx:105, add "if subscribed". webhooks.mdx needs a blank line before ### webhook.test.
  • Use components/ui/checkbox.tsx instead of the raw checkbox.

@knockknock10

Copy link
Copy Markdown
Contributor Author

I addressed the review points on this PR and corrected the branch's upstream conflict.

  • Renamed the migration to 00198_webhook_event_subscriptions.sql, added a whitelist constraint and server-action whitelist, and regenerated supabase/schema.sql from the current upstream migration history plus this migration.
  • The generated schema now matches bash supabase/build-schema.sh byte-for-byte, and GitHub reports the branch up to date with main and mergeable.
  • The Action Center drawer checks action_task.sent; sending to an unsubscribed webhook is reported distinctly for Action Center and single/bulk Content sends.
  • Saving requires at least one supported event; the UI uses the shared Checkbox, and the Daily Pulse/API docs are updated.

Validation: server lint, format, and all 1,821 server tests passed locally; web formatting and ESLint on the changed TypeScript files passed; the focused Action Center test passed (3/3). The latest CI run has server and schema jobs green; web checks are running. The needs-migration label remains as instructed by CONTRIBUTING.md for the maintainer to apply the migration when merging.

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, all points are addressed. Tested on top of main together with #1240–#1242 and #1131: server 1,897 and web 1,796 tests pass, tsc, lint and Prettier are clean. 00198 is applied to production.

@gkhngyk
gkhngyk merged commit bbbbd1a into ansvisor:main Oct 20, 2026
5 checks passed
gkhngyk added a commit to shahzainshafique/ansvisor that referenced this pull request Oct 20, 2026
00198 went to the webhook event subscriptions (ansvisor#1239), so this
migration moves to 00199. schema.sql is rebuilt with build-schema.sh.

Claude-Session: https://claude.ai/code/session_0121amRjX7UFrgmGELAtkc7A
cihan-gyk added a commit to cihan-gyk/ansvisor that referenced this pull request Oct 20, 2026
… to 00200

main now has 00198 (ansvisor#1239) and 00199 (ansvisor#1131), so the soft-404 migration
moves from 00198 to 00200, with the comments that name it, and
schema.sql is rebuilt from the migrations.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-migration Adds or edits a migration — apply it to the hosted database

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(webhooks): honour per-webhook event subscriptions so Daily Pulse payloads stop reaching content workflows

3 participants