Skip to content

Commit

Permalink
fix(nextjs): Fix version detection and option insertion logic for `cl…
Browse files Browse the repository at this point in the history
…ientTraceMetadata` option (#12323)

Co-authored-by: Luca Forstner <luca.forstner@sentry.io>
  • Loading branch information
ykzts and lforst authored Jun 3, 2024
1 parent 9865472 commit 4172e16
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/nextjs/src/config/withSentryConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4172e16

Please sign in to comment.