diff --git a/dev-packages/e2e-tests/test-applications/nextjs-turbo/next-env.d.ts b/dev-packages/e2e-tests/test-applications/nextjs-turbo/next-env.d.ts index 40c3d68096c2..725dd6f24515 100644 --- a/dev-packages/e2e-tests/test-applications/nextjs-turbo/next-env.d.ts +++ b/dev-packages/e2e-tests/test-applications/nextjs-turbo/next-env.d.ts @@ -1,5 +1,6 @@ /// /// +/// // NOTE: This file should not be edited // see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information. diff --git a/dev-packages/e2e-tests/test-applications/nextjs-turbo/pages/[param]/client-trace-propagation.tsx b/dev-packages/e2e-tests/test-applications/nextjs-turbo/pages/[param]/client-trace-propagation.tsx new file mode 100644 index 000000000000..be0391c3618e --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/nextjs-turbo/pages/[param]/client-trace-propagation.tsx @@ -0,0 +1,10 @@ +export default function Page() { +

Hello World!

; +} + +// getServerSideProps makes this page dynamic and allows tracing data to be inserted +export async function getServerSideProps() { + return { + props: {}, + }; +} diff --git a/dev-packages/e2e-tests/test-applications/nextjs-turbo/tests/rsc-error.test.ts b/dev-packages/e2e-tests/test-applications/nextjs-turbo/tests/app-router/rsc-error.test.ts similarity index 100% rename from dev-packages/e2e-tests/test-applications/nextjs-turbo/tests/rsc-error.test.ts rename to dev-packages/e2e-tests/test-applications/nextjs-turbo/tests/app-router/rsc-error.test.ts diff --git a/dev-packages/e2e-tests/test-applications/nextjs-turbo/tests/pages-router/client-trace-propagation.test.ts b/dev-packages/e2e-tests/test-applications/nextjs-turbo/tests/pages-router/client-trace-propagation.test.ts new file mode 100644 index 000000000000..6991466acb71 --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/nextjs-turbo/tests/pages-router/client-trace-propagation.test.ts @@ -0,0 +1,25 @@ +import { expect, test } from '@playwright/test'; +import { waitForTransaction } from '@sentry-internal/test-utils'; +import { extractTraceparentData } from '@sentry/utils'; + +test('Should propagate traces from server to client in pages router', async ({ page }) => { + const serverTransactionPromise = waitForTransaction('nextjs-turbo', async transactionEvent => { + return transactionEvent?.transaction === 'GET /[param]/client-trace-propagation'; + }); + + await page.goto(`/123/client-trace-propagation`); + + const sentryTraceLocator = await page.locator('meta[name="sentry-trace"]'); + const sentryTraceValue = await sentryTraceLocator.getAttribute('content'); + expect(sentryTraceValue).toMatch(/^[a-f0-9]{32}-[a-f0-9]{16}-[0-1]$/); + + const baggageLocator = await page.locator('meta[name="baggage"]'); + const baggageValue = await baggageLocator.getAttribute('content'); + expect(baggageValue).toMatch(/sentry-public_key=/); + + const traceparentData = extractTraceparentData(sentryTraceValue!); + + const serverTransaction = await serverTransactionPromise; + + expect(serverTransaction.contexts?.trace?.trace_id).toBe(traceparentData?.traceId); +});