Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
"clean": "npx rimraf node_modules pnpm-lock.yaml",
"test:e2e": "playwright test",
"test:build": "pnpm install && pnpm build",
"test:assert": "pnpm test:e2e",
"test:build:tunnel": "pnpm install && E2E_TEST_TUNNEL=1 PUBLIC_E2E_TEST_TUNNEL=1 E2E_TEST_DSN=http://public@localhost:3031/1337 PUBLIC_E2E_TEST_DSN=http://public@localhost:3031/1337 pnpm build",
"test:assert:tunnel": "E2E_TEST_TUNNEL=1 PUBLIC_E2E_TEST_TUNNEL=1 E2E_TEST_DSN=http://public@localhost:3031/1337 PUBLIC_E2E_TEST_DSN=http://public@localhost:3031/1337 playwright test tunnel"
"test:assert": "pnpm test:e2e"
},
"dependencies": {
"@sentry/sveltekit": "file:../../packed/sentry-sveltekit-packed.tgz"
Expand All @@ -28,14 +26,5 @@
"typescript": "^6.0.0",
"vite": "^8.0.12",
"wrangler": "^4.118.0"
},
"sentryTest": {
"variants": [
{
"label": "sveltekit-3-cloudflare-workers (tunnel)",
"build-command": "pnpm test:build:tunnel",
"assert-command": "pnpm test:assert:tunnel"
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,4 @@ export const variables = defineEnvVars({
// `process.env` at runtime, so a dynamic var would never reach the SDK.
E2E_TEST_DSN: { static: true },
PUBLIC_E2E_TEST_DSN: { public: true, static: true },
// Only the tunnel variant sets these, so a missing value means the tunnel is off.
E2E_TEST_TUNNEL: { static: true, schema: (value: string | undefined) => !!value },
PUBLIC_E2E_TEST_TUNNEL: { public: true, static: true, schema: (value: string | undefined) => !!value },
});
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { PUBLIC_E2E_TEST_DSN, PUBLIC_E2E_TEST_TUNNEL } from '$app/env/public';
import { PUBLIC_E2E_TEST_DSN } from '$app/env/public';
import * as Sentry from '@sentry/sveltekit';

Sentry.init({
environment: 'qa',
dsn: PUBLIC_E2E_TEST_DSN,
tunnel: PUBLIC_E2E_TEST_TUNNEL ? true : 'http://localhost:3031/', // proxy server
tunnel: 'http://localhost:3031/', // proxy server
tracesSampleRate: 1.0,
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import { E2E_TEST_DSN, E2E_TEST_TUNNEL } from '$app/env/private';
import {
handleErrorWithSentry,
initCloudflareSentryHandle,
sentryHandle,
serveTunnelIntegration,
} from '@sentry/sveltekit';
import { E2E_TEST_DSN } from '$app/env/private';
import { handleErrorWithSentry, initCloudflareSentryHandle, sentryHandle } from '@sentry/sveltekit';
import { sequence } from '@sveltejs/kit/hooks';

// not logging anything to console to avoid noise in the test output
Expand All @@ -16,7 +11,6 @@ export const handle = sequence(
dsn: E2E_TEST_DSN,
debug: !!process.env.DEBUG,
tunnel: 'http://localhost:3031/', // proxy server
integrations: E2E_TEST_TUNNEL ? [serveTunnelIntegration()] : [],
tracesSampleRate: 1.0,
}),
sentryHandle(),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import { sveltekit } from '@sveltejs/kit/vite';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
import { defineConfig } from 'vite';

// The tunnel variant serves the app under a base path to cover that the managed tunnel follows it.
const tunnelVariant = !!process.env.E2E_TEST_TUNNEL;

export default defineConfig({
plugins: [
sentrySvelteKit({
Expand All @@ -20,7 +17,6 @@ export default defineConfig({
prerender: {
handleHttpError: 'ignore',
},
paths: tunnelVariant ? { base: '/app' } : undefined,
}),
],
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "sveltekit-3-tunnel",
"version": "0.0.1",
"private": true,
"type": "module",
"scripts": {
"build": "vite build",
"clean": "npx rimraf node_modules pnpm-lock.yaml .svelte-kit build",
"test:build": "pnpm install && pnpm build",
"test:assert": "TEST_ENV=production playwright test && TEST_ENV=development playwright test"
},
"dependencies": {
"@sentry/sveltekit": "file:../../packed/sentry-sveltekit-packed.tgz"
},
"devDependencies": {
"@playwright/test": "1.64.1",
"@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz",
"@sveltejs/adapter-cloudflare": "^8.0.0",
"@sveltejs/adapter-node": "^6.0.0",
"@sveltejs/kit": "^3.0.0",
"@sveltejs/vite-plugin-svelte": "^7.3.1",
"svelte": "^5.57.1",
"vite": "^8.0.12",
"wrangler": "^4.118.0"
},
"sentryTest": {
"variants": [
{
"runtime": "cloudflare",
"label": "sveltekit-3-tunnel (cloudflare)"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { getPlaywrightConfig } from '@sentry-internal/test-utils';

const prodStartCommand =
process.env.RUNTIME === 'cloudflare' ? 'pnpm exec wrangler dev --port 3030' : 'PORT=3030 node build';

export default getPlaywrightConfig({
startCommand: process.env.TEST_ENV === 'development' ? 'pnpm exec vite dev --port 3030' : prodStartCommand,
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
allowBuilds:
esbuild: true
workerd: true
minimumReleaseAge: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
%sveltekit.head%
</head>
<body>
<div style="display: contents">%sveltekit.body%</div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as Sentry from '@sentry/sveltekit';

Sentry.init({
dsn: 'http://public@localhost:3031/1337',
tunnel: true,
tracesSampleRate: 1,
});

export const handleError = Sentry.handleErrorWithSentry();
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {
handleErrorWithSentry,
initCloudflareSentryHandle,
sentryHandle,
serveTunnelIntegration,
} from '@sentry/sveltekit';
import type { Handle } from '@sveltejs/kit';
import { sequence } from '@sveltejs/kit/hooks';

const blockPosts: Handle = ({ event, resolve }) =>
event.request.method === 'POST' ? new Response('blocked by user auth', { status: 401 }) : resolve(event);

export const handle = sequence(
initCloudflareSentryHandle({
dsn: 'http://public@localhost:3031/1337',
integrations: [serveTunnelIntegration()],
tracesSampleRate: 1,
}),
sentryHandle(),
blockPosts,
);

export const handleError = handleErrorWithSentry();
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { handleErrorWithSentry, sentryHandle } from '@sentry/sveltekit';
import type { Handle } from '@sveltejs/kit';
import { sequence } from '@sveltejs/kit/hooks';

const blockPosts: Handle = ({ event, resolve }) =>
event.request.method === 'POST' ? new Response('blocked by user auth', { status: 401 }) : resolve(event);

export const handle = sequence(sentryHandle(), blockPosts);

export const handleError = handleErrorWithSentry();
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// The Worker starts the SDK per request with `initCloudflareSentryHandle` in `hooks.server.ts`.
export {};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as Sentry from '@sentry/sveltekit';

Sentry.init({
dsn: 'http://public@localhost:3031/1337',
integrations: [Sentry.serveTunnelIntegration()],
tracesSampleRate: 1,
});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>Tunnel</h1>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const GET = () => Response.json({ ok: true });
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const GET = () => {
throw new Error('Tunnel test error');
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { startEventProxyServer } from '@sentry-internal/test-utils';

startEventProxyServer({
port: 3031,
proxyServerName: 'sveltekit-3-tunnel',
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { runManagedTunnelSuite } from '@sentry-internal/test-utils/tunnel-suite';

runManagedTunnelSuite({
appName: 'sveltekit-3-tunnel',
basePath: '/app',
// Kit's own `sveltekit.handle.root` span starts with only `http.url`, no `url.path`.
isTunnelSpan: (span, tunnelPath) => {
const url = span.attributes['http.url']?.value;
return typeof url === 'string' && new URL(url).pathname === tunnelPath;
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { sentrySvelteKit } from '@sentry/sveltekit/vite';
import cloudflareAdapter from '@sveltejs/adapter-cloudflare';
import nodeAdapter from '@sveltejs/adapter-node';
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';

const cloudflare = process.env.RUNTIME === 'cloudflare';

export default defineConfig({
plugins: [
sentrySvelteKit({ autoUploadSourceMaps: false }),
sveltekit({
adapter: cloudflare ? cloudflareAdapter() : nodeAdapter(),
// On Node, Kit's own tracing starts the request spans, and the SDK inits in `src/instrumentation.server.ts`.
tracing: { server: !cloudflare },
paths: { base: '/app' },
}),
],
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "sveltekit-3-tunnel",
"compatibility_date": "2026-08-01",
"compatibility_flags": ["nodejs_compat"],
"main": ".svelte-kit/cloudflare/_worker.js",
"assets": {
"directory": ".svelte-kit/cloudflare",
"binding": "ASSETS",
},
}
21 changes: 2 additions & 19 deletions dev-packages/e2e-tests/test-applications/sveltekit-3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
"check:sentry-types": "svelte-kit sync && tsc -p tsconfig.sentry-types.json",
"test:prod": "TEST_ENV=production playwright test",
"test:build": "pnpm install && pnpm check:sentry-types && pnpm build",
"test:assert": "pnpm test:prod",
"test:build:tunnel": "pnpm install && E2E_TEST_TUNNEL=1 PUBLIC_E2E_TEST_TUNNEL=1 E2E_TEST_DSN=http://public@localhost:3031/1337 PUBLIC_E2E_TEST_DSN=http://public@localhost:3031/1337 pnpm build",
"test:assert:tunnel": "E2E_TEST_TUNNEL=1 PUBLIC_E2E_TEST_TUNNEL=1 E2E_TEST_DSN=http://public@localhost:3031/1337 PUBLIC_E2E_TEST_DSN=http://public@localhost:3031/1337 TEST_ENV=production playwright test tunnel",
"test:assert:tunnel-dev": "E2E_TEST_TUNNEL=1 PUBLIC_E2E_TEST_TUNNEL=1 E2E_TEST_DSN=http://public@localhost:3031/1337 PUBLIC_E2E_TEST_DSN=http://public@localhost:3031/1337 TEST_ENV=development playwright test tunnel"
"test:assert": "pnpm test:prod"
},
"dependencies": {
"@sentry/sveltekit": "file:../../packed/sentry-sveltekit-packed.tgz"
Expand All @@ -33,19 +30,5 @@
"typescript": "^6.0.0",
"vite": "^8.0.12"
},
"type": "module",
"sentryTest": {
"variants": [
{
"label": "sveltekit-3 (tunnel)",
"build-command": "pnpm test:build:tunnel",
"assert-command": "pnpm test:assert:tunnel"
},
{
"label": "sveltekit-3 (tunnel-dev)",
"build-command": "pnpm install",
"assert-command": "pnpm test:assert:tunnel-dev"
}
]
}
"type": "module"
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,4 @@ export const variables = defineEnvVars({
// `process.env` — so the DSN would never reach the server SDK.
E2E_TEST_DSN: { static: true },
PUBLIC_E2E_TEST_DSN: { public: true },
// Only the tunnel variant sets these, so a missing value means the tunnel is off.
E2E_TEST_TUNNEL: { static: true, schema: (value: string | undefined) => !!value },
PUBLIC_E2E_TEST_TUNNEL: { public: true, static: true, schema: (value: string | undefined) => !!value },
});
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { PUBLIC_E2E_TEST_DSN, PUBLIC_E2E_TEST_TUNNEL } from '$app/env/public';
import { PUBLIC_E2E_TEST_DSN } from '$app/env/public';
import * as Sentry from '@sentry/sveltekit';

Sentry.init({
environment: 'qa', // dynamic sampling bias to keep transactions
dsn: PUBLIC_E2E_TEST_DSN,
tunnel: PUBLIC_E2E_TEST_TUNNEL ? true : `http://localhost:3031/`, // proxy server
tunnel: `http://localhost:3031/`, // proxy server
tracesSampleRate: 1.0,
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { E2E_TEST_DSN, E2E_TEST_TUNNEL } from '$app/env/private';
import { E2E_TEST_DSN } from '$app/env/private';
import * as Sentry from '@sentry/sveltekit';

// With SvelteKit 3 native instrumentation enabled (`experimental.instrumentation.server`),
Expand All @@ -8,6 +8,5 @@ Sentry.init({
dsn: E2E_TEST_DSN,
debug: !!process.env.DEBUG,
tunnel: `http://localhost:3031/`, // proxy server
integrations: E2E_TEST_TUNNEL ? [Sentry.serveTunnelIntegration()] : [],
tracesSampleRate: 1.0,
});

This file was deleted.

Loading
Loading