Skip to content

feat(webhooks): add outbound webhook integrations for DevTrack activity alerts (#2525) - #3278

Open
sureshsuriya wants to merge 1 commit into
Priyanshu-byte-coder:mainfrom
sureshsuriya:feat/2525-outbound-webhook-integrations
Open

feat(webhooks): add outbound webhook integrations for DevTrack activity alerts (#2525)#3278
sureshsuriya wants to merge 1 commit into
Priyanshu-byte-coder:mainfrom
sureshsuriya:feat/2525-outbound-webhook-integrations

Conversation

@sureshsuriya

Copy link
Copy Markdown
Contributor

Summary

Implements Outbound Webhook Integrations for DevTrack Activity Alerts (Closes #2525).

This PR adds support for activity alert webhook events, introduces a dedicated activity alerts API, enhances outbound webhook configuration with customizable content types and secret tokens, improves the webhook management UI, and adds comprehensive test coverage.


Type of Change

  • ✨ New feature
  • 🧪 Tests only (includes new test coverage)

What Changed

  • Added three new activity alert webhook events:

    • streak.milestone_reached
    • goal.completed
    • weekly_summary.ready
  • Added dispatchActivityAlert() and activity alert helper utilities in src/lib/webhooks.ts.

  • Added new authenticated API endpoint:

    • POST /api/webhooks/activity-alerts
    • GET /api/webhooks/activity-alerts
  • Enhanced custom webhook creation and update APIs with:

    • configurable content_type
    • optional secret_token
    • support for the new activity alert events
  • Updated the Webhook Manager UI with:

    • grouped Activity Alert events
    • Content-Type selector
    • Secret Token input
    • copy-to-clipboard support
    • improved descriptions and layout
  • Added comprehensive tests for activity alerts and updated existing webhook tests.


How to Test

  1. Create a custom outbound webhook.
  2. Select one or more activity alert events.
  3. Trigger an activity alert using the new API endpoint or server-side helper.
  4. Verify the webhook request is delivered with the expected payload and headers.
  5. Run:
npm run lint
npm run type-check
npm run test

Expected result:

  • All feature-related tests pass.
  • Activity alert events dispatch successfully.
  • Existing webhook functionality continues to work as expected.

Screenshots / Recordings

UI changes included. Screenshots will be added before review.


Checklist

  • Linked the related issue
  • Self-reviewed my own diff
  • No unnecessary debug code
  • npm run lint passes locally
  • No TypeScript errors (npm run type-check)
  • Added tests for new functionality
  • Updated relevant comments where needed

Additional Context

Feature-specific tests pass successfully. The repository has pre-existing unrelated test failures on the current main branch, and this PR does not introduce additional failures.

…ty alerts (Priyanshu-byte-coder#2525)

## Summary

Implements GitHub Issue Priyanshu-byte-coder#2525 - Outbound Webhook Integrations for DevTrack
Activity Alerts.

## Changes

### New Events (Issue Priyanshu-byte-coder#2525 activity alerts)
- streak.milestone_reached - fired on streak milestone (7, 30, 100 days, etc.)
- goal.completed           - fired when a weekly coding goal is completed
- weekly_summary.ready     - fired when the weekly coding summary is generated

These are added alongside the existing 6 events and listed first in the UI.

### src/lib/webhooks.ts
- Add ACTIVITY_ALERT_EVENTS constant with the three new event types
- Add ActivityAlertEvent type
- Add isActivityAlertEvent() validator
- Add getActivityAlertEvents() helper
- Add dispatchActivityAlert() async helper (fire-and-forget, error-isolated)
- Fix Content-Type header to use per-webhook content_type column (defaults to
  application/json)
- Add X-DevTrack-Version: 1 header to all outbound webhook requests
- Fix misaligned indentation of redirect-check block

### src/app/api/webhooks/activity-alerts/route.ts (NEW)
- POST: receives activity-alert trigger events from server-side callers
  (goal-sync, cron jobs, streak checks); validates event type and dispatches
  asynchronously via dispatchActivityAlert()
- GET: returns the list of valid activity-alert event types (for discovery)
- Requires authenticated session; rejects non-activity-alert events

### src/app/api/webhooks/custom/route.ts
- Accept content_type field (stored in DB, used when dispatching)
- Accept optional user-supplied secret_token (falls back to auto-generated)
- Add streak.milestone_reached and weekly_summary.ready to valid events

### src/app/api/webhooks/custom/[id]/route.ts
- Add streak.milestone_reached and weekly_summary.ready to valid events
  in the PATCH handler

### src/components/webhook/WebhookManager.tsx
- Rewrite: Activity Alert events (Issue Priyanshu-byte-coder#2525) listed first with descriptions
- Add Content-Type selector (application/json / x-www-form-urlencoded)
- Add Secret Token input field with auto-generate fallback explanation
- Add copy-to-clipboard button for revealed secret tokens
- Rename heading to 'Outbound Webhooks' with clearer description
- Group events into 'Activity Alerts' and 'Other Events' sections

### test/webhook-activity-alerts.test.ts (NEW - 36 tests)
- ACTIVITY_ALERT_EVENTS constant validation
- isActivityAlertEvent() - all three events, negatives, null/undefined, case
- isValidWebhookEvent() - verifies new events accepted
- getActivityAlertEvents() - list consistency
- getAvailableEvents() - backwards-compat + new events present
- signPayload() - determinism, uniqueness per payload/secret
- dispatchActivityAlert() - no-op when no webhooks, supabase lookup, error
  isolation (DB failure does not throw), payload data injection
- GET /api/webhooks/activity-alerts - returns event list

### test/webhooks.test.ts
- Update event-count assertions from 6 to 8 (two new events added)
@github-actions github-actions Bot added type:bug GSSoC type bonus: bug fix type:feature GSSoC type bonus: new feature type:testing GSSoC type bonus: tests (+10 pts) type:design GSSoC type bonus: UI/design (+10 pts) type:performance GSSoC type bonus: performance (+15 pts) gssoc26 GSSoC 2026 contribution labels Jul 29, 2026
@github-actions

Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Priyanshu-byte-coder — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc26 GSSoC 2026 contribution type:bug GSSoC type bonus: bug fix type:design GSSoC type bonus: UI/design (+10 pts) type:feature GSSoC type bonus: new feature type:performance GSSoC type bonus: performance (+15 pts) type:testing GSSoC type bonus: tests (+10 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] Add Outbound Webhook Integrations for DevTrack Activity Alerts

1 participant