Skip to content

Commit b0297df

Browse files
committed
e2e
1 parent 82a6c9f commit b0297df

4 files changed

Lines changed: 57 additions & 0 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/instrumentation-client.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ Sentry.init({
77
tunnel: `http://localhost:3031/`, // proxy server
88
tracesSampleRate: 1.0,
99
sendDefaultPii: true,
10+
integrations: [
11+
Sentry.thirdPartyErrorFilterIntegration({
12+
filterKeys: ['nextjs-16-e2e'],
13+
behaviour: 'apply-tag-if-exclusively-contains-third-party-frames',
14+
}),
15+
],
1016
// Verify Log type is available
1117
beforeSendLog(log: Log) {
1218
return log;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ export default withSentryConfig(nextConfig, {
1010
silent: true,
1111
_experimental: {
1212
vercelCronsMonitoring: true,
13+
turbopackApplicationKey: 'nextjs-16-e2e',
1314
},
1415
});
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import test, { expect } from '@playwright/test';
2+
import { waitForError } from '@sentry-internal/test-utils';
3+
4+
test('First-party error should not be tagged as third-party code', async ({ page }) => {
5+
// This test only applies to Turbopack builds where the moduleMetadataInjectionLoader is active.
6+
// On webpack builds, the @sentry/webpack-plugin handles metadata injection instead.
7+
// We run the test for all environments since the integration is always configured,
8+
// but the assertion is meaningful primarily for Turbopack (development mode default).
9+
10+
const errorPromise = waitForError('nextjs-16', errorEvent => {
11+
return errorEvent?.exception?.values?.some(value => value.value === 'first-party-error') ?? false;
12+
});
13+
14+
await page.goto('/third-party-filter');
15+
await page.locator('#first-party-error-btn').click();
16+
17+
const errorEvent = await errorPromise;
18+
19+
expect(errorEvent.exception?.values?.[0]?.value).toBe('first-party-error');
20+
21+
// The thirdPartyErrorFilterIntegration is configured with
22+
// 'apply-tag-if-exclusively-contains-third-party-frames'.
23+
// Since this error originates entirely from first-party code,
24+
// it should NOT be tagged as third_party_code.
25+
expect(errorEvent.tags?.third_party_code).toBeUndefined();
26+
});

0 commit comments

Comments
 (0)