Difficulty: Hard
Type: Bug
Summary
Remove the duplicate webhook mapping implementation from the webhook route so the dashboard has one reliable, tested path for converting webhook payloads into activity events.
Current Behaviour
apps/dashboard/app/api/webhooks/route.ts imports mapWebhookToActivity from @/lib/activity/mapper and also defines a local mapWebhookToActivity function in the same file. This creates a naming conflict and makes the route hard to maintain. The local mapper also applies sanitised metadata differently from the shared mapper, so webhook activity behaviour can drift depending on which mapper is used.
Expected Behaviour
Webhook payloads should be mapped through a single shared mapper module. The route handler should focus on request parsing, signature verification, validation, idempotency, and response handling.
Suggested Implementation
Remove the local mapWebhookToActivity function from apps/dashboard/app/api/webhooks/route.ts. Move sanitised metadata and sanitised descriptions into the shared mapper in apps/dashboard/lib/activity/mapper.ts, or wrap the mapper with a clear sanitisation step before storage. Add tests that confirm every supported webhook event maps correctly and that unsupported events return null.
Files or Areas Likely Affected
apps/dashboard/app/api/webhooks/route.ts
apps/dashboard/lib/activity/mapper.ts
apps/dashboard/lib/activity/sanitise.ts
apps/dashboard/lib/activity/types.ts
apps/dashboard/test/
Acceptance Criteria
Additional Notes
This issue should not change the webhook signature verification contract. Keep the scope limited to mapping, sanitisation, and route cleanup.
Difficulty: Hard
Type: Bug
Summary
Remove the duplicate webhook mapping implementation from the webhook route so the dashboard has one reliable, tested path for converting webhook payloads into activity events.
Current Behaviour
apps/dashboard/app/api/webhooks/route.tsimportsmapWebhookToActivityfrom@/lib/activity/mapperand also defines a localmapWebhookToActivityfunction in the same file. This creates a naming conflict and makes the route hard to maintain. The local mapper also applies sanitised metadata differently from the shared mapper, so webhook activity behaviour can drift depending on which mapper is used.Expected Behaviour
Webhook payloads should be mapped through a single shared mapper module. The route handler should focus on request parsing, signature verification, validation, idempotency, and response handling.
Suggested Implementation
Remove the local
mapWebhookToActivityfunction fromapps/dashboard/app/api/webhooks/route.ts. Move sanitised metadata and sanitised descriptions into the shared mapper inapps/dashboard/lib/activity/mapper.ts, or wrap the mapper with a clear sanitisation step before storage. Add tests that confirm every supported webhook event maps correctly and that unsupported events returnnull.Files or Areas Likely Affected
apps/dashboard/app/api/webhooks/route.tsapps/dashboard/lib/activity/mapper.tsapps/dashboard/lib/activity/sanitise.tsapps/dashboard/lib/activity/types.tsapps/dashboard/test/Acceptance Criteria
apps/dashboard/app/api/webhooks/route.tsno longer declares a localmapWebhookToActivityfunction.pnpm typecheckpasses without mapper naming conflicts.Additional Notes
This issue should not change the webhook signature verification contract. Keep the scope limited to mapping, sanitisation, and route cleanup.