Skip to content

Commit 5956aad

Browse files
committed
e2e
1 parent 518f6e4 commit 5956aad

5 files changed

Lines changed: 40 additions & 2 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use client';
2+
3+
import * as Sentry from '@sentry/nextjs';
4+
5+
function throwFirstPartyError(): void {
6+
throw new Error('first-party-error');
7+
}
8+
9+
export default function Page() {
10+
return (
11+
<button
12+
id="first-party-error-btn"
13+
onClick={() => {
14+
try {
15+
throwFirstPartyError();
16+
} catch (e) {
17+
Sentry.captureException(e);
18+
}
19+
}}
20+
>
21+
Throw First Party Error
22+
</button>
23+
);
24+
}

dev-packages/e2e-tests/test-applications/nextjs-16-bun/instrumentation-client.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ Sentry.init({
66
tunnel: `http://localhost:3031/`, // proxy server
77
tracesSampleRate: 1.0,
88
sendDefaultPii: true,
9+
integrations: [
10+
Sentry.thirdPartyErrorFilterIntegration({
11+
filterKeys: ['nextjs-16-bun-e2e'],
12+
behaviour: 'apply-tag-if-exclusively-contains-third-party-frames',
13+
}),
14+
],
915
});
1016

1117
export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;

dev-packages/e2e-tests/test-applications/nextjs-16-bun/next.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ const nextConfig: NextConfig = {};
55

66
export default withSentryConfig(nextConfig, {
77
silent: true,
8+
_experimental: {
9+
turbopackApplicationKey: 'nextjs-16-bun-e2e',
10+
},
811
});

dev-packages/e2e-tests/test-applications/nextjs-16/instrumentation-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Sentry.init({
1010
integrations: [
1111
Sentry.thirdPartyErrorFilterIntegration({
1212
filterKeys: ['nextjs-16-e2e'],
13-
behaviour: 'apply-tag-if-exclusively-contains-third-party-frames',
13+
behaviour: 'apply-tag-if-contains-third-party-frames',
1414
}),
1515
],
1616
// Verify Log type is available

dev-packages/e2e-tests/test-applications/nextjs-16/tests/third-party-filter.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { waitForError } from '@sentry-internal/test-utils';
33

44
const isWebpackDev = process.env.TEST_ENV === 'development-webpack';
55

6-
test('First-party error should not be tagged as third-party code', async ({ page }) => {
6+
test('First-party error with React frames should not be tagged as third-party code', async ({ page }) => {
77
test.skip(isWebpackDev, 'Only relevant for Turbopack builds');
88

99
const errorPromise = waitForError('nextjs-16', errorEvent => {
@@ -20,6 +20,11 @@ test('First-party error should not be tagged as third-party code', async ({ page
2020
// In production, TEST_ENV=production is shared by both turbopack and webpack variants.
2121
// Only assert when the build is actually turbopack.
2222
if (errorEvent.tags?.turbopack) {
23+
// The integration uses `apply-tag-if-contains-third-party-frames` which tags errors
24+
// if ANY frame is third-party. This error is thrown inside a React onClick handler,
25+
// so the stack trace contains React frames from node_modules. These must NOT be
26+
// treated as third-party — the module metadata injection must cover node_modules too
27+
// (matching the webpack plugin's behavior).
2328
expect(errorEvent.tags?.third_party_code).toBeUndefined();
2429
}
2530
});

0 commit comments

Comments
 (0)