fix(sveltekit): Support browser tracing with SvelteKit 3#22264
Draft
Lms24 wants to merge 5 commits into
Draft
Conversation
chargome
added a commit
that referenced
this pull request
Jul 15, 2026
SvelteKit 3.0.0-next.8 promoted native tracing config out of `experimental` (`kit.experimental.tracing` -> `kit.tracing`) and dropped the `experimental.instrumentation` flag, which broke the app build. Migrate the Vite config to the new API. Client-side capture is also broken on next.8 because the SDK's browser integration imports `$app/stores`, which now throws at runtime (removed in favour of `$app/state`), so the app never hydrates. Skip the client-side tests until SvelteKit 3 browser support lands (#22264); server-side tests pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
df225dd to
1ca9e2e
Compare
…nfig SvelteKit 3.0.0-next.8 promoted the native server-tracing config out of `experimental` (`kit.experimental.tracing.server` -> `kit.tracing.server`). Read both locations when detecting native tracing so the SDK works across the supported peer range (SvelteKit 2.31+ and early Kit 3 prereleases keep it under `experimental`). Applies to detection from both the Vite plugin `api.options` and `svelte.config.js`, and covers both shapes in the unit tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Select the compatible tracing state API at runtime so existing setups continue to work across SvelteKit 2 and 3. Add preview coverage for pageload and navigation tracing without the removed $app/stores module. Fixes #22263 Co-Authored-By: Cursor <cursoragent@cursor.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Lms24
commented
Jul 15, 2026
Comment on lines
+37
to
+42
| if (IS_SVELTEKIT_3) { | ||
| void import('./kit3BrowserTracingIntegration').then(({ instrumentSvelteKit3Tracing }) => { | ||
| instrumentSvelteKit3Tracing(client, options); | ||
| }); | ||
| } else { | ||
| void _instrumentSvelteKit2Tracing(client, options); |
Member
Author
There was a problem hiding this comment.
I kinda don't like the dynamic import here because:
- parts of the SDK will be duplicated in the lazily loaded bundle
- timing-wise, we start our instrumentation later than the original, eagerly imported integration.
Maybe the way forward is to instruct users to switch to a new version of the integration that imports eagerly from $app/state
1ca9e2e to
8b95aff
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Support SvelteKit 3 browser tracing without changing existing SDK setup. The integration selects
$app/storesfor SvelteKit 2 and$app/statefor SvelteKit 3, using rune-based navigation observation for the latter. A preview E2E app verifies client startup, pageload tracing, and navigation tracing while existing SvelteKit 2 coverage guards compatibility.Breaking changes: None. The public API and configuration remain unchanged; the peer range is only widened to accept SvelteKit 3.
Fixes #22263