Skip to content

Commit df225dd

Browse files
Lms24cursoragent
andcommitted
fix(sveltekit): Support browser tracing with SvelteKit 3
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>
1 parent c85347c commit df225dd

21 files changed

Lines changed: 369 additions & 19 deletions
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.DS_Store
2+
node_modules
3+
/build
4+
/.svelte-kit
5+
/package
6+
.env
7+
.env.*
8+
!.env.example
9+
vite.config.js.timestamp-*
10+
vite.config.ts.timestamp-*
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "sveltekit-3-preview",
3+
"version": "0.0.1",
4+
"private": true,
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite dev",
8+
"build": "vite build",
9+
"preview": "vite preview",
10+
"proxy": "node start-event-proxy.mjs",
11+
"clean": "npx rimraf node_modules pnpm-lock.yaml",
12+
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
13+
"test:prod": "TEST_ENV=production playwright test",
14+
"test:build": "pnpm install && pnpm build",
15+
"test:assert": "pnpm test:prod"
16+
},
17+
"dependencies": {
18+
"@sentry/sveltekit": "file:../../packed/sentry-sveltekit-packed.tgz"
19+
},
20+
"devDependencies": {
21+
"@playwright/test": "~1.56.0",
22+
"@sentry-internal/test-utils": "link:../../../test-utils",
23+
"@sveltejs/adapter-node": "6.0.0-next.3",
24+
"@sveltejs/kit": "3.0.0-next.8",
25+
"@sveltejs/vite-plugin-svelte": "7.2.0",
26+
"svelte": "5.56.5",
27+
"svelte-check": "4.7.2",
28+
"typescript": "6.0.0-beta",
29+
"vite": "8.1.4"
30+
},
31+
"sentryTest": {
32+
"skip": true
33+
},
34+
"volta": {
35+
"extends": "../../package.json"
36+
}
37+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { getPlaywrightConfig } from '@sentry-internal/test-utils';
2+
3+
const config = getPlaywrightConfig({
4+
startCommand: 'ORIGIN=http://localhost:3030 node ./build/index.js',
5+
port: 3030,
6+
});
7+
8+
export default config;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
declare global {
2+
namespace App {}
3+
}
4+
5+
export {};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1" />
6+
%sveltekit.head%
7+
</head>
8+
<body data-sveltekit-preload-data="hover">
9+
<div style="display: contents">%sveltekit.body%</div>
10+
</body>
11+
</html>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { defineEnvVars } from '@sveltejs/kit/hooks';
2+
3+
export const variables = defineEnvVars({
4+
PUBLIC_E2E_TEST_DSN: {
5+
public: true,
6+
},
7+
});
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { PUBLIC_E2E_TEST_DSN } from '$app/env/public';
2+
import * as Sentry from '@sentry/sveltekit';
3+
4+
Sentry.init({
5+
dsn: PUBLIC_E2E_TEST_DSN,
6+
tunnel: 'http://localhost:3031/',
7+
tracesSampleRate: 1.0,
8+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<script lang="ts">
2+
import { onMount } from 'svelte';
3+
import type { Snippet } from 'svelte';
4+
5+
let { children }: { children: Snippet } = $props();
6+
7+
onMount(() => {
8+
document.body.classList.add('hydrated');
9+
});
10+
</script>
11+
12+
{@render children()}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<h1>SvelteKit 3 preview</h1>
2+
<a href="/target">Target</a>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<h1>Target</h1>

0 commit comments

Comments
 (0)