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 @@ -7,9 +7,7 @@
"build": "astro build",
"preview": "wrangler pages dev ./dist --port 3030",
"test:build": "pnpm install && pnpm build",
"test:assert": "TEST_ENV=production playwright test",
"test:build:tunnel": "pnpm install && PUBLIC_E2E_TEST_TUNNEL=1 PUBLIC_E2E_TEST_DSN=http://public@localhost:3031/1337 pnpm build",
"test:assert:tunnel": "PUBLIC_E2E_TEST_TUNNEL=1 TEST_ENV=production playwright test tunnel"
"test:assert": "TEST_ENV=production playwright test"
},
"dependencies": {
"@astrojs/cloudflare": "^12.6.12",
Expand All @@ -22,14 +20,5 @@
"devDependencies": {
"@sentry/conventions": "0.33.0",
"wrangler": "^4.63.0"
},
"sentryTest": {
"variants": [
{
"build-command": "pnpm test:build:tunnel",
"assert-command": "pnpm test:assert:tunnel",
"label": "astro-5-cf-pages (tunnel)"
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ Sentry.init({
dsn: import.meta.env.PUBLIC_E2E_TEST_DSN,
environment: 'qa',
tracesSampleRate: 1.0,
tunnel: import.meta.env.PUBLIC_E2E_TEST_TUNNEL ? true : 'http://localhost:3031/', // proxy server
tunnel: 'http://localhost:3031/', // proxy server
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ Sentry.init({
environment: 'qa',
tracesSampleRate: 1.0,
tunnel: 'http://localhost:3031/', // proxy server
integrations: import.meta.env.PUBLIC_E2E_TEST_TUNNEL ? [Sentry.serveTunnelIntegration()] : [],
});

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@ import { defineConfig } from 'astro/config';
import cloudflare from '@astrojs/cloudflare';
import { sentryCloudflareVitePlugin } from '@sentry/cloudflare/vite';

// The tunnel variant serves the app under a base path with trailing slashes to cover that the managed tunnel
// follows both on Workers too.
const tunnelVariant = !!process.env.PUBLIC_E2E_TEST_TUNNEL;

// https://astro.build/config
export default defineConfig({
...(tunnelVariant && { base: '/docs', trailingSlash: 'always' }),
integrations: [
sentry({
debug: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { defineCloudflareOptions, serveTunnelIntegration } from '@sentry/cloudflare';
import { defineCloudflareOptions } from '@sentry/cloudflare';

export default defineCloudflareOptions(env => ({
dsn: env.E2E_TEST_DSN,
environment: 'qa',
tracesSampleRate: 1.0,
tunnel: 'http://localhost:3031/', // proxy server
integrations: import.meta.env.PUBLIC_E2E_TEST_TUNNEL ? [serveTunnelIntegration()] : [],
debug: true,
}));
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
"start": "wrangler dev --var \"E2E_TEST_DSN:$E2E_TEST_DSN\" --port 3030",
"test:build": "pnpm install && pnpm build",
"test:assert": "TEST_ENV=production playwright test",
"cf-typegen": "wrangler types --include-runtime=false",
"test:build:tunnel": "pnpm install && PUBLIC_E2E_TEST_TUNNEL=1 PUBLIC_E2E_TEST_DSN=http://public@localhost:3031/1337 pnpm build",
"test:assert:tunnel": "PUBLIC_E2E_TEST_TUNNEL=1 E2E_TEST_DSN=http://public@localhost:3031/1337 TEST_ENV=production playwright test tunnel"
"cf-typegen": "wrangler types --include-runtime=false"
},
"dependencies": {
"@astrojs/cloudflare": "^13.0.2",
Expand All @@ -23,14 +21,5 @@
"astro": "^6.0.0",
"mysql": "2.18.1",
"wrangler": "^4.72.0"
},
"sentryTest": {
"variants": [
{
"build-command": "pnpm test:build:tunnel",
"assert-command": "pnpm test:assert:tunnel",
"label": "astro-6-cf-workers (tunnel)"
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Sentry.init({
dsn: import.meta.env.PUBLIC_E2E_TEST_DSN,
environment: 'qa',
tracesSampleRate: 1.0,
tunnel: import.meta.env.PUBLIC_E2E_TEST_TUNNEL ? true : 'http://localhost:3031/', // proxy server
tunnel: 'http://localhost:3031/', // proxy server
integrations: [
Sentry.browserTracingIntegration({
beforeStartSpan: opts => {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import cloudflare from '@astrojs/cloudflare';
import sentry from '@sentry/astro/integration';
import { sentryCloudflareVitePlugin } from '@sentry/cloudflare/vite';
import { defineConfig } from 'astro/config';

// Pages needs `@astrojs/cloudflare` 12, which has no `@cloudflare/vite-plugin` for the Sentry plugin to wrap.
const pages = !!process.env.E2E_TEST_CF_PAGES;

export default defineConfig({
...(!pages && { base: '/docs', trailingSlash: 'always' }),
integrations: [sentry({ sourcemaps: { disable: true } })],
output: 'server',
adapter: cloudflare(),
vite: { plugins: pages ? [] : [sentryCloudflareVitePlugin()] },
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import node from '@astrojs/node';
import sentry from '@sentry/astro/integration';
import { defineConfig } from 'astro/config';

export default defineConfig({
base: '/docs',
trailingSlash: 'always',
integrations: [sentry({ sourcemaps: { disable: true } })],
output: 'server',
adapter: node({ mode: 'standalone' }),
});
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,43 @@
{
"name": "astro-7-tunnel",
"type": "module",
"version": "0.0.1",
"private": true,
"scripts": {
"build": "astro build",
"start": "node ./dist/server/entry.mjs",
"test:build": "pnpm install && pnpm build",
"test:build:cloudflare-workers": "pnpm install && rm sentry.server.config.js && pnpm build",
"test:build:cloudflare-pages": "pnpm install && pnpm add astro@^5.17.1 @astrojs/cloudflare@^12.6.12 && cp wrangler.pages.jsonc wrangler.jsonc && rm src/pages/static.astro && E2E_TEST_CF_PAGES=1 pnpm build",
"test:assert": "pnpm test:prod && TEST_ENV=development playwright test",
"test:prod": "TEST_ENV=production playwright test"
},
"dependencies": {
"@astrojs/cloudflare": "^14.4.8",
"@astrojs/node": "^11.1.4",
"@sentry/astro": "file:../../packed/sentry-astro-packed.tgz",
"@sentry/cloudflare": "file:../../packed/sentry-cloudflare-packed.tgz",
"astro": "^7.4.0",
"wrangler": "^4.125.0"
},
"devDependencies": {
"@playwright/test": "1.64.1",
"@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz"
},
"sentryTest": {
"variants": [
{
"runtime": "cloudflare",
"build-command": "pnpm test:build:cloudflare-workers",
"assert-command": "pnpm test:prod",
"label": "astro-7-tunnel (cloudflare workers)"
},
{
"runtime": "cloudflare",
"build-command": "pnpm test:build:cloudflare-pages",
"assert-command": "E2E_TEST_CF_PAGES=1 pnpm test:prod",
"label": "astro-7-tunnel (astro 5, cloudflare pages)"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { getPlaywrightConfig, getRuntime } from '@sentry-internal/test-utils';

const getStartCommand = () => {
if (process.env.TEST_ENV === 'development') {
// `astro dev` ignores PORT.
return 'pnpm exec astro dev --port 3030';
}
if (getRuntime() !== 'cloudflare') {
return 'pnpm start';
}
return process.env.E2E_TEST_CF_PAGES
? 'pnpm exec wrangler pages dev ./dist --port 3030'
: 'pnpm exec wrangler dev --port 3030';
};

export default getPlaywrightConfig({ startCommand: getStartCommand() });
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
minimumReleaseAge: 0
allowBuilds:
esbuild: true
sharp: true
workerd: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as Sentry from '@sentry/astro';

Sentry.init({
dsn: 'http://public@localhost:3031/1337',
tunnel: true,
integrations: [Sentry.browserTracingIntegration()],
tracesSampleRate: 1,
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as Sentry from '@sentry/astro';

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,5 @@
import { defineMiddleware } from 'astro:middleware';

export const onRequest = defineMiddleware((context, next) =>
context.request.method === 'POST' ? new Response('blocked by user auth', { status: 401 }) : next(),
);
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 @@
<html lang="en">
<head>
<title>Astro Tunnel E2E Test</title>
</head>
<body></body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
export const prerender = true;
---

<html lang="en">
<head>
<title>Astro Tunnel E2E Test</title>
</head>
<body></body>
</html>
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: 'astro-7-tunnel',
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { expect, test } from '@playwright/test';
import { runManagedTunnelSuite } from '@sentry-internal/test-utils/tunnel-suite';

// The Pages variant serves the app at the root, the others under a base path with trailing slashes.
const pages = !!process.env.E2E_TEST_CF_PAGES;
const basePath = pages ? '' : '/docs';
const trailingSlash = !pages;

// First, while the server has only served a prerendered page, so no SSR page has run `Sentry.init` yet.
test('answers the managed tunnel when the first page is prerendered', async ({ page }) => {
// With `@sentry/astro`, an Astro 5 Cloudflare build fails to prerender, so the Pages variant has no prerendered page.
test.skip(pages);

const tunnelPath = `${basePath}/qpo967${trailingSlash ? '/' : ''}`;
const tunnelResponsePromise = page.waitForResponse(
response => response.request().method() === 'POST' && new URL(response.url()).pathname === tunnelPath,
);

await page.goto(`${basePath}/static${trailingSlash ? '/' : ''}`);

expect((await tunnelResponsePromise).status()).toBe(200);
});

runManagedTunnelSuite({ appName: 'astro-7-tunnel', basePath, trailingSlash });
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "astro-7-tunnel",
"compatibility_date": "2026-03-12",
"compatibility_flags": ["nodejs_compat"],
"main": "@astrojs/cloudflare/entrypoints/server",
"assets": { "directory": "./dist", "binding": "ASSETS" },
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "astro-7-tunnel",
"pages_build_output_dir": "./dist",
"compatibility_date": "2025-12-01",
"compatibility_flags": ["nodejs_compat"],
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@ import { defineConfig } from 'astro/config';

import node from '@astrojs/node';

// The tunnel variant serves the app under a base path with trailing slashes to cover that the managed tunnel
// follows both.
const tunnelVariant = !!process.env.PUBLIC_E2E_TEST_TUNNEL;

// https://astro.build/config
export default defineConfig({
...(tunnelVariant && { base: '/docs', trailingSlash: 'always' }),
integrations: [
sentry({
debug: true,
Expand Down
13 changes: 2 additions & 11 deletions dev-packages/e2e-tests/test-applications/astro-7/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
"test:build": "pnpm install && pnpm build",
"test:assert": "pnpm test:prod && pnpm test:dev",
"test:prod": "TEST_ENV=production playwright test",
"test:dev": "TEST_ENV=development playwright test db",
"test:build:tunnel": "pnpm install && PUBLIC_E2E_TEST_TUNNEL=1 PUBLIC_E2E_TEST_DSN=http://public@localhost:3031/1337 pnpm build",
"test:assert:tunnel": "PUBLIC_E2E_TEST_TUNNEL=1 PUBLIC_E2E_TEST_DSN=http://public@localhost:3031/1337 sh -c 'TEST_ENV=production playwright test tunnel && TEST_ENV=development playwright test tunnel'"
"test:dev": "TEST_ENV=development playwright test db"
},
"//": "Need to use ioredis 5.10.1 because that's the last version before they support tracing channels",
"dependencies": {
Expand All @@ -26,13 +24,6 @@
"mysql": "^2.18.1"
},
"sentryTest": {
"optional": true,
"variants": [
{
"build-command": "pnpm test:build:tunnel",
"assert-command": "pnpm test:assert:tunnel",
"label": "astro-7 (tunnel)"
}
]
"optional": true
}
}
Loading
Loading