Skip to content

feat(listener): delivery metrics endpoint — closes #482 - #538

Open
kitWarse wants to merge 1 commit into
Core-Foundry:mainfrom
kitWarse:feature/482-metrics-delivery-endpoint
Open

feat(listener): delivery metrics endpoint — closes #482#538
kitWarse wants to merge 1 commit into
Core-Foundry:mainfrom
kitWarse:feature/482-metrics-delivery-endpoint

Conversation

@kitWarse

@kitWarse kitWarse commented Jul 26, 2026

Copy link
Copy Markdown

Closes #482


Summary

Implements issue #482 — Expose delivery statistics through an API endpoint for monitoring notification performance.


Changes

listener/src/api/events-server.ts

New route GET /api/metrics/delivery inserted after the existing GET /api/analytics block.

  • Reuses the process-wide NotificationAnalyticsAggregator (or the injected options.analyticsAggregator) — zero new dependencies, no extra allocations.
  • Optional ?window filter — restricts the report to 1h, 6h, 24h, or 7d; returns 400 with a descriptive message for any other value.
  • Response shape:
    jsonc { meta: { generatedAt, windowStart, windowEnd, windowParam, totalRecorded }, delivery: { total, success, failure, retry, skipped, successRate, averageDurationMs }, byType: [ { notificationType, total, success, failure, successRate } ], errorBreakdown: { reason: count }, hourlyBuckets: [ { bucketStart, total, success, failure, retry, skipped, averageDurationMs } ] }
  • Read-only — never resets the aggregator (use GET /api/analytics?reset=true for that).
  • Fully logged via the existing structured logger (
    equestId, correlationId, window, otal, durationMs).

docs/api/metrics-delivery.md (new)

Complete API reference covering:

  • Method, path, query parameters table
  • Request/response schema with inline comments
  • Error response table (400, 503)
  • Notes on auth, rate-limiting, performance, and links to related endpoints

Acceptance Criteria

Criterion Status
Metrics endpoint is available ✅ GET /api/metrics/delivery registered in createEventsServer
Response includes delivery statistics ✅ delivery, �yType, errorBreakdown, hourlyBuckets all included
Endpoint is documented ✅ docs/api/metrics-delivery.md — full reference with schema, errors, and examples

…y#482

## What changed

### listener/src/api/events-server.ts
- Added GET /api/metrics/delivery route (inserted after GET /api/analytics)
- Reuses the existing NotificationAnalyticsAggregator (options.analyticsAggregator
  or the process-wide default) — zero new dependencies or allocations
- Accepts optional ?window=1h|6h|24h|7d query parameter to restrict the report
  to a recent time slice; returns 400 for unrecognised values
- Response shape:
    meta         { generatedAt, windowStart, windowEnd, windowParam, totalRecorded }
    delivery     { total, success, failure, retry, skipped, successRate, averageDurationMs }
    byType       [ { notificationType, total, success, failure, successRate } ]
    errorBreakdown { reason: count, ... }
    hourlyBuckets  [ { bucketStart, total, success, failure, retry, skipped, avgDuration } ]
- Fully logged via existing logger (requestId, correlationId, window, total, durationMs)
- Read-only — never resets the aggregator

### docs/api/metrics-delivery.md  [NEW]
- Full API reference: method, path, query parameters, request/response schema,
  error table, notes on auth, rate-limiting, performance, and related endpoints

Closes Core-Foundry#482
@drips-wave

drips-wave Bot commented Jul 27, 2026

Copy link
Copy Markdown

@kitWarse Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Add Notification Delivery Metrics API

1 participant