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 @@ -6,8 +6,8 @@ import { HydratedRouter } from 'react-router/dom';
Sentry.init({
environment: 'qa', // dynamic sampling bias to keep transactions
// todo: get this from env
dsn: __E2E_TEST_TUNNEL__ ? 'http://public@localhost:3031/1337' : 'https://username@domain/123',
tunnel: __E2E_TEST_TUNNEL__ ? true : `http://localhost:3031/`, // proxy server
dsn: 'https://username@domain/123',
tunnel: `http://localhost:3031/`, // proxy server
integrations: [Sentry.reactRouterTracingIntegration()],
tracesSampleRate: 1.0,
tracePropagationTargets: [/^\//],
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,6 @@ import { Links, Meta, Outlet, Scripts, ScrollRestoration, isRouteErrorResponse }
import type { Route } from './+types/root';
import stylesheet from './app.css?url';

// The tunnel variant checks that the managed tunnel answers before an auth middleware like this one. Other variants
// get none, so their span assertions stay as they are.
export const middleware: Route.MiddlewareFunction[] = __E2E_TEST_TUNNEL__
? [
({ request }, next) => {
if (request.method === 'POST' && request.headers.get('x-auth') !== 'ok') {
return new Response('blocked by user auth', { status: 401 });
}

return next();
},
]
: [];

export const links: Route.LinksFunction = () => [
{ rel: 'preconnect', href: 'https://fonts.googleapis.com' },
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import * as Sentry from '@sentry/react-router';

Sentry.init({
dsn: process.env.E2E_TEST_TUNNEL ? 'http://public@localhost:3031/1337' : 'https://username@domain/123',
dsn: 'https://username@domain/123',
environment: 'qa', // dynamic sampling bias to keep transactions
tracesSampleRate: 1.0,
tunnel: `http://localhost:3031/`, // proxy server
// The tunnel variants also accept another app's DSN, so the server serves more than one tunnel path.
integrations: process.env.E2E_TEST_TUNNEL
? [Sentry.serveTunnelIntegration({ allowedDsns: ['http://other@localhost:3031/1338'] })]
: [],
});
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@
"test:build": "pnpm install && pnpm build",
"test:assert": "pnpm test:ts && pnpm test:playwright",
"test:ts": "pnpm typecheck",
"test:playwright": "playwright test",
"test:build:tunnel-basepath": "pnpm install && E2E_TEST_TUNNEL=1 E2E_TEST_BASE_PATH=/app pnpm build",
"test:assert:tunnel-basepath": "E2E_TEST_TUNNEL=1 E2E_TEST_BASE_PATH=/app pnpm test:playwright tunnel",
"test:assert:tunnel-basepath-dev": "TEST_ENV=development E2E_TEST_TUNNEL=1 E2E_TEST_BASE_PATH=/app pnpm test:playwright tunnel"
"test:playwright": "playwright test"
},
"eslintConfig": {
"extends": [
Expand Down Expand Up @@ -85,22 +82,6 @@
{
"runtime": "cloudflare",
"label": "react-router-8-framework (cloudflare)"
},
{
"build-command": "pnpm test:build:tunnel-basepath",
"assert-command": "pnpm test:assert:tunnel-basepath",
"label": "react-router-8-framework (tunnel-basepath)"
},
{
"runtime": "cloudflare",
"build-command": "pnpm test:build:tunnel-basepath",
"assert-command": "pnpm test:assert:tunnel-basepath",
"label": "react-router-8-framework (tunnel-basepath-cloudflare)"
},
{
"label": "react-router-8-framework (tunnel-basepath-dev)",
"build-command": "pnpm install",
"assert-command": "pnpm test:assert:tunnel-basepath-dev"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@ import type { Config } from '@react-router/dev/config';

export default {
ssr: true,
// The base-path variant serves the app, and so the tunnel, under `/app`.
...(process.env.E2E_TEST_BASE_PATH && { basename: `${process.env.E2E_TEST_BASE_PATH}/` }),
prerender: ['/performance/static'],
} satisfies Config;

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ import { sentryReactRouter } from '@sentry/react-router/vite';
import { defineConfig } from 'vite';

export default defineConfig(async config => ({
define: {
__E2E_TEST_TUNNEL__: JSON.stringify(!!process.env.E2E_TEST_TUNNEL),
},
plugins: [
cloudflare({ viteEnvironment: { name: 'ssr' } }),
reactRouter(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import { defineConfig } from 'vite';

export default defineConfig(config => {
return {
define: {
__E2E_TEST_TUNNEL__: JSON.stringify(!!process.env.E2E_TEST_TUNNEL),
},
plugins: [reactRouter(), sentryReactRouter({ sourcemaps: { disable: true } }, config)],
};
});
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { defineCloudflareOptions, serveTunnelIntegration } from '@sentry/cloudflare';

declare const __E2E_TEST_TUNNEL__: boolean;
import { defineCloudflareOptions } from '@sentry/cloudflare';

export default defineCloudflareOptions({
dsn: __E2E_TEST_TUNNEL__ ? 'http://public@localhost:3031/1337' : 'https://username@domain/123',
dsn: 'https://username@domain/123',
environment: 'qa', // dynamic sampling bias to keep transactions
tracesSampleRate: 1.0,
tunnel: 'http://localhost:3031/', // proxy server
integrations: __E2E_TEST_TUNNEL__ ? [serveTunnelIntegration()] : [],
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as Sentry from '@sentry/react-router';
import { startTransition } from 'react';
import { hydrateRoot } from 'react-dom/client';
import { HydratedRouter } from 'react-router/dom';

Sentry.init({
dsn: 'http://public@localhost:3031/1337',
// The SDK serves it under the app's `basename`.
tunnel: true,
integrations: [Sentry.reactRouterTracingIntegration()],
tracesSampleRate: 1,
});

startTransition(() => {
hydrateRoot(document, <HydratedRouter onError={Sentry.sentryOnError} />);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { captureException } from '@sentry/cloudflare';
import * as Sentry from '@sentry/react-router/cloudflare';
import { renderToReadableStream } from 'react-dom/server';
import { type HandleErrorFunction, ServerRouter } from 'react-router';

export default Sentry.createSentryHandleRequest({ renderToReadableStream, ServerRouter });

export const handleError: HandleErrorFunction = error => {
captureException(error, { mechanism: { type: 'react-router', handled: false } });
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { createReadableStreamFromReadable } from '@react-router/node';
import * as Sentry from '@sentry/react-router';
import { renderToPipeableStream } from 'react-dom/server';
import { ServerRouter } from 'react-router';

export default Sentry.createSentryHandleRequest({
ServerRouter,
renderToPipeableStream,
createReadableStreamFromReadable,
});

export const handleError = Sentry.createSentryHandleError({ logErrors: false });
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Outlet, Scripts } from 'react-router';
import type { Route } from './+types/root';

export const middleware: Route.MiddlewareFunction[] = [
({ request }, next) => (request.method === 'POST' ? new Response('blocked by user auth', { status: 401 }) : next()),
];

export default function App() {
return (
<html lang="en">
<body>
<Outlet />
<Scripts />
</body>
</html>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { type RouteConfig, route } from '@react-router/dev/routes';

export default [route('api/anchor', 'routes/anchor.ts'), route('api/error', 'routes/error.ts')] satisfies RouteConfig;
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function loader() {
return Response.json({ ok: true });
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function loader() {
throw new Error('Tunnel test error');
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as Sentry from '@sentry/react-router';

Sentry.init({
dsn: 'http://public@localhost:3031/1337',
// A second DSN makes the server serve more than one tunnel path.
integrations: [Sentry.serveTunnelIntegration({ allowedDsns: ['http://other@localhost:3031/1338'] })],
tracesSampleRate: 1,
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "react-router-8-tunnel",
"version": "1.0.0",
"private": true,
"type": "module",
"scripts": {
"build": "react-router build",
"dev": "NODE_OPTIONS='--import ./instrument.mjs' react-router dev --port 3030",
"start": "PORT=3030 NODE_ENV=production NODE_OPTIONS='--import ./instrument.mjs' react-router-serve ./build/server/index.js",
"start:cloudflare": "wrangler dev --config ./build/server/wrangler.json --port 3030",
"clean": "npx rimraf node_modules pnpm-lock.yaml build",
"test:build": "pnpm install && pnpm build",
"test:assert": "TEST_ENV=production playwright test && TEST_ENV=development playwright test"
},
"dependencies": {
"@react-router/node": "^8.0.0",
"@react-router/serve": "^8.0.0",
"@sentry/cloudflare": "file:../../packed/sentry-cloudflare-packed.tgz",
"@sentry/react-router": "file:../../packed/sentry-react-router-packed.tgz",
"react": "^19.2.7",
"react-dom": "^19.2.7",
"react-router": "^8.0.0"
},
"devDependencies": {
"@cloudflare/vite-plugin": "^1.35.0",
"@playwright/test": "1.64.1",
"@react-router/dev": "^8.0.0",
"@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz",
"vite": "^7.3.2",
"wrangler": "^4.120.0"
},
"sentryTest": {
"variants": [
{
"runtime": "cloudflare",
"assert-command": "TEST_ENV=production pnpm exec playwright test",
"label": "react-router-8-tunnel (cloudflare)"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { getPlaywrightConfig, getRuntime } from '@sentry-internal/test-utils';

export default getPlaywrightConfig({
startCommand:
process.env.TEST_ENV === 'development'
? 'pnpm dev'
: getRuntime() === 'cloudflare'
? 'pnpm start:cloudflare'
: 'pnpm start',
});
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,6 @@
import type { Config } from '@react-router/dev/config';

export default {
ssr: true,
basename: '/app/',
} satisfies Config;
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: 'react-router-8-tunnel',
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { runManagedTunnelSuite } from '@sentry-internal/test-utils/tunnel-suite';

runManagedTunnelSuite({ appName: 'react-router-8-tunnel', basePath: '/app' });
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { cloudflare } from '@cloudflare/vite-plugin';
import { reactRouter } from '@react-router/dev/vite';
import { sentryCloudflareVitePlugin } from '@sentry/cloudflare/vite';
import { sentryReactRouter } from '@sentry/react-router/vite';
import { defineConfig } from 'vite';

export default defineConfig(async config => ({
plugins: [
cloudflare({ viteEnvironment: { name: 'ssr' } }),
reactRouter(),
sentryCloudflareVitePlugin(),
...((await sentryReactRouter({ sourcemaps: { disable: true } }, config)) as any[]),
],
}));
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { reactRouter } from '@react-router/dev/vite';
import { sentryReactRouter } from '@sentry/react-router/vite';
import { defineConfig } from 'vite';

export default defineConfig(config => ({
plugins: [reactRouter(), sentryReactRouter({ sourcemaps: { disable: true } }, config)],
}));
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { createRequestHandler } from 'react-router';

const requestHandler = createRequestHandler(() => import('virtual:react-router/server-build'), import.meta.env.MODE);

export default {
async fetch(request: Request) {
return requestHandler(request);
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineCloudflareOptions, serveTunnelIntegration } from '@sentry/cloudflare';

export default defineCloudflareOptions({
dsn: 'http://public@localhost:3031/1337',
integrations: [serveTunnelIntegration()],
tracesSampleRate: 1,
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "node_modules/wrangler/config-schema.json",
"name": "react-router-8-tunnel",
"compatibility_date": "2026-06-29",
"compatibility_flags": ["nodejs_compat"],
"main": "./workers/app.ts",
"assets": {
"directory": "./build/client",
},
}
Loading