Skip to content

Commit c922bcc

Browse files
authored
feat(nextjs): Un experimentify clientInstrumentationHook (#15992)
They actually unexperimentified it vercel/next.js@2737373
1 parent 4d0c270 commit c922bcc

File tree

5 files changed

+5
-24
lines changed

5 files changed

+5
-24
lines changed

Diff for: CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ Work in this release was contributed by @Page-. Thank you for your contribution!
119119

120120
- **feat(nextjs): Support `instrumentation-client.ts` ([#15705](https://github.com/getsentry/sentry-javascript/pull/15705))**
121121

122-
Next.js recently added a feature to support [client-side (browser) instrumentation via the `experimental.clientInstrumentationHook` flag and the `instrumentation-client.ts` file](https://nextjs.org/docs/app/api-reference/config/next-config-js/clientInstrumentationHook).
122+
Next.js recently added a feature to support [client-side (browser) instrumentation via a `instrumentation-client.ts` file](https://nextjs.org/docs/app/api-reference/file-conventions/instrumentation-client).
123123

124124
To be forwards compatible, the Sentry Next.js SDK will now pick up `instrumentation-client.ts` files even on older Next.js versions and add them to your client bundles.
125125
It is suggested that you either rename your `sentry.client.config.ts` file to `instrumentation-client.ts`, or if you already happen to have a `instrumentation-client.ts` file move the contents of `sentry.client.config.ts` to `instrumentation-client.ts`.

Diff for: dev-packages/e2e-tests/test-applications/nextjs-turbo/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"@types/node": "^18.19.1",
1818
"@types/react": "18.0.26",
1919
"@types/react-dom": "18.0.9",
20-
"next": "15.3.0-canary.26",
20+
"next": "15.3.0-canary.40",
2121
"react": "rc",
2222
"react-dom": "rc",
2323
"typescript": "~5.0.0"

Diff for: packages/nextjs/src/config/types.ts

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ export type NextConfigObject = {
4444
// Next.js experimental options
4545
experimental?: {
4646
instrumentationHook?: boolean;
47-
clientInstrumentationHook?: boolean;
4847
clientTraceMetadata?: string[];
4948
};
5049
productionBrowserSourceMaps?: boolean;

Diff for: packages/nextjs/src/config/webpack.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ export function constructWebpackConfigFunction(
344344
if (clientSentryConfigFileName) {
345345
// eslint-disable-next-line no-console
346346
console.warn(
347-
`[@sentry/nextjs] DEPRECATION WARNING: It is recommended renaming your \`${clientSentryConfigFileName}\` file, or moving its content to \`instrumentation-client.ts\`. When using Turbopack \`${clientSentryConfigFileName}\` will no longer work. Read more about the \`instrumentation-client.ts\` file: https://nextjs.org/docs/app/api-reference/config/next-config-js/clientInstrumentationHook`,
347+
`[@sentry/nextjs] DEPRECATION WARNING: It is recommended renaming your \`${clientSentryConfigFileName}\` file, or moving its content to \`instrumentation-client.ts\`. When using Turbopack \`${clientSentryConfigFileName}\` will no longer work. Read more about the \`instrumentation-client.ts\` file: https://nextjs.org/docs/app/api-reference/file-conventions/instrumentation-client`,
348348
);
349349
}
350350
}

Diff for: packages/nextjs/src/config/withSentryConfig.ts

+2-20
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,10 @@ function getFinalConfigObject(
173173
minor === 3 &&
174174
patch === 0 &&
175175
prerelease.startsWith('canary.') &&
176-
parseInt(prerelease.split('.')[1] || '', 10) >= 8;
176+
parseInt(prerelease.split('.')[1] || '', 10) >= 28;
177177
const supportsClientInstrumentation = isSupportedCanary || isSupportedVersion;
178178

179-
if (supportsClientInstrumentation) {
180-
incomingUserNextConfigObject.experimental = {
181-
clientInstrumentationHook: true,
182-
...incomingUserNextConfigObject.experimental,
183-
};
184-
} else if (process.env.TURBOPACK) {
179+
if (!supportsClientInstrumentation && process.env.TURBOPACK) {
185180
if (process.env.NODE_ENV === 'development') {
186181
// eslint-disable-next-line no-console
187182
console.warn(
@@ -194,19 +189,6 @@ function getFinalConfigObject(
194189
);
195190
}
196191
}
197-
} else {
198-
// If we cannot detect a Next.js version for whatever reason, the sensible default is still to set the `experimental.instrumentationHook`.
199-
incomingUserNextConfigObject.experimental = {
200-
clientInstrumentationHook: true,
201-
...incomingUserNextConfigObject.experimental,
202-
};
203-
}
204-
205-
if (incomingUserNextConfigObject.experimental?.clientInstrumentationHook === false) {
206-
// eslint-disable-next-line no-console
207-
console.warn(
208-
'[@sentry/nextjs] WARNING: You set the `experimental.clientInstrumentationHook` option to `false`. Note that Sentry will not be initialized if you did not set it up inside `instrumentation-client.(js|ts)`.',
209-
);
210192
}
211193

212194
return {

0 commit comments

Comments
 (0)