diff --git a/packages/nextjs/src/config/withSentryConfig.ts b/packages/nextjs/src/config/withSentryConfig.ts index 32a4a885f9d7..ec9115b4ce3e 100644 --- a/packages/nextjs/src/config/withSentryConfig.ts +++ b/packages/nextjs/src/config/withSentryConfig.ts @@ -89,11 +89,13 @@ function getFinalConfigObject( const nextJsVersion = getNextjsVersion(); if (nextJsVersion) { const { major, minor } = parseSemver(nextJsVersion); - if (major && minor && (major >= 15 || (major === 14 && minor >= 3))) { - incomingUserNextConfigObject.experimental = { - clientTraceMetadata: ['baggage', 'sentry-trace'], - ...incomingUserNextConfigObject.experimental, - }; + if (major !== undefined && minor !== undefined && (major >= 15 || (major === 14 && minor >= 3))) { + incomingUserNextConfigObject.experimental = incomingUserNextConfigObject.experimental || {}; + incomingUserNextConfigObject.experimental.clientTraceMetadata = [ + 'baggage', + 'sentry-trace', + ...(incomingUserNextConfigObject.experimental?.clientTraceMetadata || []), + ]; } } else { // eslint-disable-next-line no-console