Skip to content

feat: add client log transport#23

Merged
HugoRCD merged 9 commits intomainfrom
feat/log-transport
Feb 2, 2026
Merged

feat: add client log transport#23
HugoRCD merged 9 commits intomainfrom
feat/log-transport

Conversation

@HugoRCD
Copy link
Copy Markdown
Owner

@HugoRCD HugoRCD commented Jan 31, 2026

This pull request introduces client-to-server log transport support, enabling browser logs to be sent to the server for centralized logging.
The main changes include new configuration options, server route handling for log ingestion, and updates to the client and server code to support this feature.

@HugoRCD HugoRCD self-assigned this Jan 31, 2026
@vercel
Copy link
Copy Markdown

vercel Bot commented Jan 31, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
evlog-docs Ready Ready Preview, Comment Feb 2, 2026 10:30am

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 31, 2026

Thank you for following the naming conventions! 🙏

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jan 31, 2026

npm i https://pkg.pr.new/evlog@23

commit: 19fd047

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds client-to-server log transport functionality, allowing browser logs to be centrally collected on the server for unified logging across client and server contexts.

Changes:

  • Introduces TransportConfig and IngestPayload types for client log transport configuration
  • Adds /api/_evlog/ingest POST endpoint for receiving client logs with validation via Zod
  • Extends client logger to send logs to the server via fetch when transport is enabled (default: enabled in production, disabled in development)

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
packages/evlog/src/types.ts Defines TransportConfig and IngestPayload interfaces for log transport
packages/evlog/src/runtime/server/routes/_evlog/ingest.post.ts Implements server endpoint to receive and process client logs via evlog:drain hook
packages/evlog/src/runtime/client/plugin.ts Configures transport settings in client plugin initialization
packages/evlog/src/runtime/client/log.ts Adds sendToServer function to transmit logs to the ingest endpoint
packages/evlog/src/nuxt/module.ts Registers ingest handler and exposes transport configuration to runtime config
packages/evlog/src/index.ts Exports new IngestPayload and TransportConfig types
packages/evlog/build.config.ts Adds ingest handler to build entries and marks h3/zod as external dependencies
apps/playground/nuxt.config.ts Enables transport in playground for testing
apps/docs/content/1.getting-started/2.installation.md Documents client transport feature with configuration and usage examples

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

Comment thread packages/evlog/src/runtime/server/routes/_evlog/ingest.post.ts Outdated
Comment thread packages/evlog/src/runtime/server/routes/_evlog/ingest.post.ts Outdated
Comment thread packages/evlog/src/runtime/server/routes/_evlog/ingest.post.ts Outdated
Comment thread packages/evlog/src/runtime/server/routes/_evlog/ingest.post.ts Outdated
Comment thread packages/evlog/src/runtime/server/routes/_evlog/ingest.post.ts Outdated
Comment thread packages/evlog/src/runtime/server/routes/_evlog/ingest.post.ts Outdated
Comment thread packages/evlog/src/types.ts
Comment thread packages/evlog/src/runtime/client/log.ts
Comment thread packages/evlog/src/runtime/server/routes/_evlog/ingest.post.ts
Comment thread packages/evlog/src/runtime/client/log.ts
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 11 comments.


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

await fetch(transportEndpoint, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(event),
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fetch request doesn't specify credentials mode. For authenticated applications where cookies are needed for authentication or CSRF protection, the fetch should include credentials: 'same-origin' to ensure cookies are sent with the request. Consider adding this option or documenting the authentication requirements.

Suggested change
body: JSON.stringify(event),
body: JSON.stringify(event),
credentials: 'same-origin',

Copilot uses AI. Check for mistakes.
Comment thread packages/evlog/src/runtime/server/routes/_evlog/ingest.post.ts Outdated
Comment on lines +48 to +50
if (typeof rawTimestamp === 'number') {
timestamp = new Date(rawTimestamp).toISOString()
} else if (typeof rawTimestamp === 'string') {
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The timestamp validation accepts numeric timestamps and converts them to ISO strings, but doesn't validate if the timestamp value is reasonable. Extremely large or negative numbers could result in invalid dates like "Invalid Date" or dates far in the future/past. Consider adding bounds checking to ensure timestamps are within a reasonable range (e.g., not before 2000 or more than 1 day in the future).

Copilot uses AI. Check for mistakes.
Comment thread packages/evlog/src/runtime/server/routes/_evlog/ingest.post.ts
await fetch(transportEndpoint, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(event),
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fetch call doesn't include the keepalive flag. When a page is being unloaded or navigated away from, logs sent at that moment might be cancelled before completion. Adding keepalive: true to the fetch options would ensure that the request continues even if the page is closed, improving reliability of log delivery during page transitions.

Suggested change
body: JSON.stringify(event),
body: JSON.stringify(event),
keepalive: true,

Copilot uses AI. Check for mistakes.
Comment thread packages/evlog/src/runtime/client/log.ts
Comment thread packages/evlog/src/runtime/server/routes/_evlog/ingest.post.ts
Comment thread packages/evlog/src/nuxt/module.ts Outdated
Comment thread packages/evlog/src/runtime/server/routes/_evlog/ingest.post.ts Outdated
Comment thread packages/evlog/src/runtime/server/routes/_evlog/ingest.post.ts Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

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


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

Comment thread packages/evlog/src/nuxt/module.ts
Comment thread packages/evlog/src/runtime/server/routes/_evlog/ingest.post.ts
Comment thread packages/evlog/src/runtime/server/routes/_evlog/ingest.post.ts
Comment thread packages/evlog/src/runtime/server/routes/_evlog/ingest.post.ts
Comment thread packages/evlog/src/runtime/server/routes/_evlog/ingest.post.ts
Comment thread packages/evlog/src/runtime/client/log.ts
@HugoRCD HugoRCD merged commit 3ade790 into main Feb 2, 2026
18 checks passed
@HugoRCD HugoRCD deleted the feat/log-transport branch February 2, 2026 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants