Skip to content

feat: add database record of webhook refresh attempts#440

Merged
joaquimds merged 4 commits into
mainfrom
feat/track-webhook-refresh
Jun 16, 2026
Merged

feat: add database record of webhook refresh attempts#440
joaquimds merged 4 commits into
mainfrom
feat/track-webhook-refresh

Conversation

@joaquimds

Copy link
Copy Markdown
Member

No description provided.

Copilot AI 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.

Pull request overview

Adds a persistent audit trail for webhook refresh operations by recording the outcome of each refreshWebhooks attempt (per run, per data source) in the database. This fits into the server’s webhook maintenance flow (cron + per-source refresh) and makes webhook lifecycle changes observable and debuggable.

Changes:

  • Introduces a webhookRefreshLog table (migration + schema/model wiring) and repository helpers to write/read log rows.
  • Updates DataSourceAdaptor.toggleWebhook() to return a structured WebhookToggleResult and updates adaptors to populate it.
  • Enhances refreshWebhooks to persist the toggle outcome/error, and adds feature/unit tests around the new behavior.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/unit/server/adaptors/airtable.test.ts Updates Airtable webhook toggle test to assert lifecycle actions/ids and adds timeout.
tests/setup.ts Makes webhook test server startup awaitable to avoid unhandled async error events.
tests/feature/webhookRefreshLog.test.ts Adds feature tests for JSONB round-tripping and job-driven log insertion.
src/server/services/database/schema.ts Adds WebhookRefreshLog interface and registers it on the database schema type.
src/server/services/database/index.ts Registers webhookRefreshLog table type on the Kysely Database interface.
src/server/repositories/WebhookRefreshLog.ts New repository functions to insert logs and query by data source.
src/server/models/WebhookRefreshLog.ts New Kysely table typings for webhookRefreshLog.
src/server/jobs/refreshWebhooks.ts Generates a run id and writes audit rows per processed data source (success/failure).
src/server/adaptors/zetkin.ts Updates adaptor to return WebhookToggleResult for unsupported webhooks (but signature currently mismatched).
src/server/adaptors/mailchimp.ts Returns structured toggle results (created/kept/removed) with webhook ids.
src/server/adaptors/googlesheets.ts Returns structured toggle results with sheet ids/details.
src/server/adaptors/csv.ts Updates signature to return WebhookToggleResult (still throws Unimplemented).
src/server/adaptors/airtable.ts Returns structured toggle results including expiration details.
src/server/adaptors/actionnetwork.ts Returns noop structured result for unsupported webhooks.
src/server/adaptors/abstract.ts Introduces WebhookToggleResult and updates DataSourceAdaptor.toggleWebhook contract.
src/models/WebhookRefreshLog.ts Adds shared Zod schema + types for webhook refresh logs/actions.
migrations/1781568000000_webhook_refresh_log.ts Creates webhookRefreshLog table + index for querying by dataSourceId/createdAt.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/server/adaptors/zetkin.ts
Comment thread src/server/jobs/refreshWebhooks.ts
Comment thread src/server/jobs/refreshWebhooks.ts
Comment thread tests/feature/webhookRefreshLog.test.ts
Comment on lines 420 to 426
if (!enable) {
logger.info(
`Removing Airtable webhooks for data source ${this.dataSourceId}`,
);
await this.removeWebhooks(webhooks);
return;
return { action: "removed", oldWebhookIds, newWebhookIds: [] };
}
Comment on lines 423 to 430
// Remove webhooks on user request
if (!enable) {
logger.info(
`Removing Mailchimp webhooks for data source ${this.dataSourceId}`,
);
await this.removeWebhooks(webhooks);
return;
return { action: "removed", oldWebhookIds, newWebhookIds: [] };
}
joaquimds and others added 3 commits June 16, 2026 13:31
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…ge/ts-mapped into feat/track-webhook-refresh
@joaquimds joaquimds merged commit e64a182 into main Jun 16, 2026
1 check passed
@joaquimds joaquimds deleted the feat/track-webhook-refresh branch June 16, 2026 12:37
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.

2 participants