-
-
Notifications
You must be signed in to change notification settings - Fork 10
feat: evlog:enrich hook and built-in enrichers
#55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: evlog:enrich hook and built-in enrichers
#55
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Thank you for following the naming conventions! 🙏 |
commit: |
evlog:enrich hook and built-in enrichers
There was a problem hiding this comment.
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 dedicated evlog:enrich Nitro hook that runs after emit() and before evlog:drain, plus a set of built-in enrichers to derive common context (UA/geo/sizes/trace) from request/response metadata.
Changes:
- Introduces
EnrichContextand registers the newevlog:enrichhook in Nitro hook typings. - Updates server request logging and the client ingest endpoint to run
evlog:enrichbeforeevlog:drain, with shared safe-header filtering and response metadata collection. - Adds built-in enrichers (
user-agent,geo,request-size,trace-context), exports them asevlog/enrichers, and adds unit tests + docs.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/evlog/test/nitro-plugin.test.ts | Updates tests to use shared header filtering and adds enrichment pipeline tests. |
| packages/evlog/test/enrichers.test.ts | Adds comprehensive unit tests for the built-in enrichers. |
| packages/evlog/src/utils.ts | Centralizes sensitive-header filtering via SENSITIVE_HEADERS + filterSafeHeaders. |
| packages/evlog/src/types.ts | Adds EnrichContext and Nitro hook typing for evlog:enrich. |
| packages/evlog/src/runtime/server/routes/_evlog/ingest.post.ts | Runs evlog:enrich before draining for client ingest, adds safe headers + waitUntil usage. |
| packages/evlog/src/nitro/plugin.ts | Adds enrich→drain pipeline for server requests; collects safe request/response metadata. |
| packages/evlog/src/index.ts | Exports EnrichContext from the main package entrypoint. |
| packages/evlog/src/enrichers/index.ts | Implements built-in enrichers and related types/helpers. |
| packages/evlog/package.json | Adds ./enrichers export + types mapping. |
| packages/evlog/build.config.ts | Adds an enrichers build entry. |
| packages/evlog/README.md | Documents the new hook and built-in enrichers (package-level docs). |
| apps/playground/server/plugins/evlog-enrich.ts | Adds a playground example using evlog:enrich + enrichers. |
| README.md | Documents the new hook/enrichers at the repo root. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This pull request introduces a new enrichment hook for event logging, allowing for flexible addition of derived context to events before they are drained.
It adds a set of built-in enrichers for user agent, geo, request size, and trace context, and updates the Nitro plugin and documentation to support and demonstrate these features. The changes also improve header handling and event enrichment in both the main package and playground app.