Skip to content

feat: add SvelteKit support#142

Merged
HugoRCD merged 6 commits intomainfrom
claude/xenodochial-panini
Mar 7, 2026
Merged

feat: add SvelteKit support#142
HugoRCD merged 6 commits intomainfrom
claude/xenodochial-panini

Conversation

@HugoRCD
Copy link
Copy Markdown
Owner

@HugoRCD HugoRCD commented Mar 7, 2026

Summary

  • Add evlog/sveltekit entry point with createEvlogHooks() returning handle and handleError hooks, plus useLogger() for request-scoped logging via AsyncLocalStorage
  • Handle SvelteKit's unique error flow where resolve() catches route errors internally — intercept 500 responses when handleError logged an EvlogError, returning structured JSON at the correct status
  • Full evlog pipeline support: drain (PostHog/OTLP), enrich, tail sampling, route filtering
  • Example app with 5 demo routes: /health, /users/:id, /checkout (402 EvlogError), /crash (unexpected error), /slow (tail sampling)
  • 33 tests covering hooks creation, request lifecycle, error handling, useLogger, route filtering, enrichment, and tail sampling

Closes EVL-91

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 7, 2026

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

Project Deployment Actions Updated (UTC)
evlog-docs Ready Ready Preview, Comment, Open in v0 Mar 7, 2026 3:40pm

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 7, 2026

Thank you for following the naming conventions! 🙏

@HugoRCD HugoRCD changed the title feat(sveltekit): SvelteKit support feat: SvelteKit support Mar 7, 2026
@HugoRCD HugoRCD changed the title feat: SvelteKit support feat: add SvelteKit support Mar 7, 2026
@HugoRCD HugoRCD requested a review from Copilot March 7, 2026 14:48
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 7, 2026

npm i https://pkg.pr.new/evlog@142
npm i https://pkg.pr.new/@evlog/nuxthub@142

commit: 8b11a0c

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 PR adds a first-class SvelteKit integration to evlog via a new evlog/sveltekit entry point, aligning SvelteKit with the existing framework adapters (Express/Fastify/Elysia/etc.) and extending docs/examples accordingly.

Changes:

  • Add evlog/sveltekit adapter with handle, handleError, createEvlogHooks(), and useLogger() (AsyncLocalStorage-based request scoping).
  • Add a SvelteKit example app + documentation pages and landing-page framework tab.
  • Add a comprehensive Vitest suite for the SvelteKit adapter and wire up build/package exports.

Reviewed changes

Copilot reviewed 27 out of 29 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
skills/evlog/SKILL.md Updates skill guide to mention SvelteKit and adds setup/usage snippets.
packages/evlog/tsdown.config.ts Adds SvelteKit build entry and externalizes @sveltejs/kit.
packages/evlog/test/sveltekit.test.ts Adds SvelteKit adapter tests (hooks lifecycle, errors, pipeline, useLogger, filtering).
packages/evlog/src/sveltekit/index.ts Implements the SvelteKit adapter (handle + handleError hooks, ALS logger scoping).
packages/evlog/package.json Adds ./sveltekit export, typesVersions entry, and peer dep on @sveltejs/kit.
packages/evlog/README.md Adds SvelteKit line to the framework quickstart table.
package.json Adds example:sveltekit script.
examples/sveltekit/vite.config.ts New SvelteKit example config.
examples/sveltekit/tsconfig.json New SvelteKit example TypeScript config.
examples/sveltekit/svelte.config.js New SvelteKit example adapter configuration.
examples/sveltekit/src/routes/users/[id]/+server.ts Example route demonstrating useLogger() + context accumulation.
examples/sveltekit/src/routes/slow/+server.ts Example route demonstrating tail sampling via a slow request.
examples/sveltekit/src/routes/health/+server.ts Example health route using locals.log.
examples/sveltekit/src/routes/crash/+server.ts Example route throwing an unexpected error.
examples/sveltekit/src/routes/checkout/+server.ts Example route throwing an EvlogError via createError.
examples/sveltekit/src/routes/+page.svelte Interactive UI to call example routes and show responses.
examples/sveltekit/src/hooks.server.ts Example hook setup with drain + enrichers + tail sampling.
examples/sveltekit/src/app.html SvelteKit base HTML template.
examples/sveltekit/src/app.d.ts App locals typing for log: RequestLogger.
examples/sveltekit/package.json Example workspace package definition and dependencies.
examples/sveltekit/.gitignore Ignores .svelte-kit build directory.
bun.lock Updates lockfile for new example/workspace dependencies.
apps/docs/content/6.examples/7.sveltekit.md Adds a full SvelteKit example doc page.
apps/docs/content/1.getting-started/2.installation.md Adds SvelteKit installation/setup section.
apps/docs/content/0.landing.md Adds SvelteKit snippet to landing framework tabs.
apps/docs/app/components/features/FeatureFrameworks.vue Adds SvelteKit as a selectable framework tab.
.github/workflows/semantic-pull-request.yml Allows sveltekit as a semantic PR scope.
.github/pull_request_template.md Documents sveltekit as an allowed PR scope.
.changeset/sveltekit-integration.md Declares a minor release for the new SvelteKit integration.

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

HugoRCD and others added 5 commits March 7, 2026 15:36
- Add `evlog/sveltekit` entry point with `createEvlogHooks()` returning
  `handle` and `handleError` hooks, plus `useLogger()` for request-scoped
  logging via AsyncLocalStorage
- Handle SvelteKit's unique error flow: intercept 500 responses when
  `handleError` already logged an EvlogError with a specific status,
  returning structured JSON instead of SvelteKit's generic error page
- Support full evlog pipeline: drain, enrich, tail sampling, route filtering
- Add example app with 5 demo routes: /health, /users/:id, /checkout (402),
  /crash (unexpected), /slow (tail sampling)
- Add 33 tests covering hooks creation, request lifecycle, error handling,
  useLogger, route filtering, enrichment, and tail sampling
- Update docs, CI scopes, changeset, and README

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Remove unnecessary async on mock functions, fix brace-style on inline
mock objects, and add missing await in skipped route path.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Replace the minimal hooks setup with a full checkout route handler
showing useLogger(), log.set(), and createError() — matching the
pattern used by all other framework tabs.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
- Replace `App.Error` with local `AppError` type in
  `SvelteKitHandleServerError` so the adapter's types remain
  self-contained without requiring SvelteKit ambient types
- Unify EvlogError response shape: the intercept-500 branch now uses
  `serializeEvlogErrorResponse` (same as the catch branch), ensuring
  clients always receive the same `{ message, status, data }` shape

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@HugoRCD HugoRCD force-pushed the claude/xenodochial-panini branch from 74ea952 to 7d68483 Compare March 7, 2026 15:37
@HugoRCD HugoRCD merged commit 866b286 into main Mar 7, 2026
10 of 11 checks passed
@HugoRCD HugoRCD deleted the claude/xenodochial-panini branch March 7, 2026 15:39
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