diff --git a/dev-packages/e2e-tests/test-applications/hydrogen-react-router-7/app/routes/action-error.tsx b/dev-packages/e2e-tests/test-applications/hydrogen-react-router-7/app/routes/action-error.tsx new file mode 100644 index 000000000000..083926e454ff --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/hydrogen-react-router-7/app/routes/action-error.tsx @@ -0,0 +1,11 @@ +export async function action() { + throw new Error('Action Error'); +} + +export default function ActionError() { + return ( +
+

Action Error

+
+ ); +} diff --git a/dev-packages/e2e-tests/test-applications/hydrogen-react-router-7/server.ts b/dev-packages/e2e-tests/test-applications/hydrogen-react-router-7/server.ts index 9bb5529320b6..74ef453d062b 100644 --- a/dev-packages/e2e-tests/test-applications/hydrogen-react-router-7/server.ts +++ b/dev-packages/e2e-tests/test-applications/hydrogen-react-router-7/server.ts @@ -9,7 +9,7 @@ import { import { type AppLoadContext, createRequestHandler, getStorefrontHeaders } from '@shopify/remix-oxygen'; import { CART_QUERY_FRAGMENT } from '~/lib/fragments'; import { AppSession } from '~/lib/session'; -import { wrapRequestHandler } from '@sentry/cloudflare/request'; +import { httpServerIntegration, wrapRequestHandler } from '@sentry/cloudflare/request'; // Virtual entry point for the app // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-expect-error @@ -38,6 +38,7 @@ export default { dsn: 'https://public@dsn.ingest.sentry.io/1337', tracesSampleRate: 1.0, tunnel: `http://localhost:3031/`, // proxy server + integrations: [httpServerIntegration({ maxRequestBodySize: 'small' })], }, // Need to cast to any because this is not on cloudflare request: request as any, diff --git a/dev-packages/e2e-tests/test-applications/hydrogen-react-router-7/tests/server-errors.test.ts b/dev-packages/e2e-tests/test-applications/hydrogen-react-router-7/tests/server-errors.test.ts new file mode 100644 index 000000000000..3b1030adacec --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/hydrogen-react-router-7/tests/server-errors.test.ts @@ -0,0 +1,18 @@ +import { expect, test } from '@playwright/test'; +import { waitForError } from '@sentry-internal/test-utils'; + +test('Applies the options of `httpServerIntegration` imported from `@sentry/cloudflare/request`', async ({ + request, +}) => { + const errorPromise = waitForError('hydrogen-react-router-7', errorEvent => { + return errorEvent.exception?.values?.[0]?.value === 'Action Error'; + }); + + const body = JSON.stringify({ payload: 'x'.repeat(4_000) }); + await request.post('/action-error', { data: body, headers: { 'content-type': 'application/json' } }); + + const errorEvent = await errorPromise; + + // `maxRequestBodySize: 'small'` truncates at 1,000 bytes, the default (`'medium'`) would keep the full body. + expect(errorEvent.request?.data).toBe(`${body.slice(0, 997)}...`); +}); diff --git a/packages/cloudflare/src/request.ts b/packages/cloudflare/src/request.ts index dadd4059fd5c..760398c38b73 100644 --- a/packages/cloudflare/src/request.ts +++ b/packages/cloudflare/src/request.ts @@ -20,3 +20,5 @@ export function wrapRequestHandler( ): Promise { return wrapRequestHandlerWithInit(wrapperOptions, handler, initBaseSdk); } + +export { httpServerIntegration } from './integrations/httpServer';