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 @@ -3,8 +3,8 @@ import { NextResponse } from 'next/server';
export const dynamic = 'force-dynamic';

export async function GET() {
const data = await fetch(`http://localhost:3030/propagation/test-outgoing-fetch-external-disallowed/check`).then(
res => res.json(),
);
const data = await fetch(`http://localhost:3030/propagation/test-outgoing-fetch-external-disallowed/check`, {
cache: 'no-store',
}).then(res => res.json());
return NextResponse.json(data);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { NextResponse } from 'next/server';
export const dynamic = 'force-dynamic';

export async function GET() {
const data = await fetch(`http://localhost:3030/propagation/test-outgoing-fetch/check`).then(res => res.json());
const data = await fetch(`http://localhost:3030/propagation/test-outgoing-fetch/check`, { cache: 'no-store' }).then(
res => res.json(),
);
return NextResponse.json(data);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { expect, test } from '@playwright/test';
import { waitForError } from '@sentry-internal/test-utils';

const packageJson = require('../package.json');

test('Sends a client-side exception to Sentry', async ({ page }) => {
const nextjsVersion = packageJson.dependencies.next;
const nextjsMajor = Number(nextjsVersion.split('.')[0]);
const isDevMode = process.env.TEST_ENV === 'development';

await page.goto('/');

const errorEventPromise = waitForError('nextjs-app-dir', errorEvent => {
Expand All @@ -23,6 +29,9 @@ test('Sends a client-side exception to Sentry', async ({ page }) => {
expect(errorEvent.transaction).toEqual('/');

expect(errorEvent.contexts?.trace).toEqual({
// Next.js >= 15 propagates a trace ID to the client via a meta tag. Also, only dev mode emits a meta tag because
// the requested page is static and only in dev mode SSR is kicked off.
parent_span_id: nextjsMajor >= 15 && isDevMode ? expect.any(String) : undefined,
trace_id: expect.any(String),
span_id: expect.any(String),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import { waitForTransaction } from '@sentry-internal/test-utils';
const packageJson = require('../package.json');

test('Sends a pageload transaction', async ({ page }) => {
const nextjsVersion = packageJson.dependencies.next;
const nextjsMajor = Number(nextjsVersion.split('.')[0]);
const isDevMode = process.env.TEST_ENV === 'development';

const pageloadTransactionEventPromise = waitForTransaction('nextjs-app-dir', transactionEvent => {
return transactionEvent?.contexts?.trace?.op === 'pageload' && transactionEvent?.transaction === '/';
});
Expand All @@ -23,6 +27,9 @@ test('Sends a pageload transaction', async ({ page }) => {
version: expect.any(String),
},
trace: {
// Next.js >= 15 propagates a trace ID to the client via a meta tag. Also, only dev mode emits a meta tag because
// the requested page is static and only in dev mode SSR is kicked off.
parent_span_id: nextjsMajor >= 15 && isDevMode ? expect.any(String) : undefined,
span_id: expect.any(String),
trace_id: expect.any(String),
op: 'pageload',
Expand Down