diff --git a/dev-packages/e2e-tests/test-applications/node-exports-test-app/scripts/consistentExports.ts b/dev-packages/e2e-tests/test-applications/node-exports-test-app/scripts/consistentExports.ts index 8c3e51b14024..f355654bf6a2 100644 --- a/dev-packages/e2e-tests/test-applications/node-exports-test-app/scripts/consistentExports.ts +++ b/dev-packages/e2e-tests/test-applications/node-exports-test-app/scripts/consistentExports.ts @@ -50,6 +50,7 @@ const DEPENDENTS: Dependent[] = [ ignoreExports: [ // not supported in bun: 'NodeClient', + 'NODE_VERSION', 'childProcessIntegration', ], }, diff --git a/packages/astro/src/index.server.ts b/packages/astro/src/index.server.ts index 29105cfb4b18..ac222eca825b 100644 --- a/packages/astro/src/index.server.ts +++ b/packages/astro/src/index.server.ts @@ -134,6 +134,7 @@ export { logger, consoleLoggingIntegration, wrapMcpServerWithSentry, + NODE_VERSION, } from '@sentry/node'; export { init } from './server/sdk'; diff --git a/packages/aws-serverless/src/index.ts b/packages/aws-serverless/src/index.ts index 942951c165da..24513a325188 100644 --- a/packages/aws-serverless/src/index.ts +++ b/packages/aws-serverless/src/index.ts @@ -120,6 +120,7 @@ export { logger, consoleLoggingIntegration, wrapMcpServerWithSentry, + NODE_VERSION, } from '@sentry/node'; export { diff --git a/packages/google-cloud-serverless/src/index.ts b/packages/google-cloud-serverless/src/index.ts index f5d593312743..f2622e591497 100644 --- a/packages/google-cloud-serverless/src/index.ts +++ b/packages/google-cloud-serverless/src/index.ts @@ -120,6 +120,7 @@ export { logger, consoleLoggingIntegration, wrapMcpServerWithSentry, + NODE_VERSION, } from '@sentry/node'; export { diff --git a/packages/node/src/index.ts b/packages/node/src/index.ts index 5a933002bc23..589937b21fd4 100644 --- a/packages/node/src/index.ts +++ b/packages/node/src/index.ts @@ -54,6 +54,7 @@ export { createGetModuleFromFilename } from './utils/module'; export { makeNodeTransport } from './transports'; export { NodeClient } from './sdk/client'; export { cron } from './cron'; +export { NODE_VERSION } from './nodeVersion'; export type { NodeOptions } from './types'; diff --git a/packages/react-router/src/server/sdk.ts b/packages/react-router/src/server/sdk.ts index 55eaf6962a28..07ea80e867ea 100644 --- a/packages/react-router/src/server/sdk.ts +++ b/packages/react-router/src/server/sdk.ts @@ -2,7 +2,7 @@ import { ATTR_HTTP_ROUTE } from '@opentelemetry/semantic-conventions'; import type { EventProcessor, Integration } from '@sentry/core'; import { applySdkMetadata, getGlobalScope, logger, setTag } from '@sentry/core'; import type { NodeClient, NodeOptions } from '@sentry/node'; -import { getDefaultIntegrations as getNodeDefaultIntegrations, init as initNodeSdk } from '@sentry/node'; +import { getDefaultIntegrations as getNodeDefaultIntegrations, init as initNodeSdk, NODE_VERSION } from '@sentry/node'; import { DEBUG_BUILD } from '../common/debug-build'; import { SEMANTIC_ATTRIBUTE_SENTRY_OVERWRITE } from './instrumentation/util'; import { lowQualityTransactionsFilterIntegration } from './integration/lowQualityTransactionsFilterIntegration'; @@ -13,11 +13,16 @@ import { reactRouterServerIntegration } from './integration/reactRouterServer'; * @param options The options for the SDK. */ export function getDefaultReactRouterServerIntegrations(options: NodeOptions): Integration[] { - return [ - ...getNodeDefaultIntegrations(options), - lowQualityTransactionsFilterIntegration(options), - reactRouterServerIntegration(), - ]; + const integrations = [...getNodeDefaultIntegrations(options), lowQualityTransactionsFilterIntegration(options)]; + + if ( + (NODE_VERSION.major === 20 && NODE_VERSION.minor < 19) || // https://nodejs.org/en/blog/release/v20.19.0 + (NODE_VERSION.major === 22 && NODE_VERSION.minor < 12) // https://nodejs.org/en/blog/release/v22.12.0 + ) { + integrations.push(reactRouterServerIntegration()); + } + + return integrations; } /** diff --git a/packages/react-router/test/server/sdk.test.ts b/packages/react-router/test/server/sdk.test.ts index fdb894299760..861144e3f62b 100644 --- a/packages/react-router/test/server/sdk.test.ts +++ b/packages/react-router/test/server/sdk.test.ts @@ -71,5 +71,77 @@ describe('React Router server SDK', () => { expect(filterIntegration).toBeDefined(); }); + + it('adds reactRouterServer integration for Node.js 20.18', () => { + vi.spyOn(SentryNode, 'NODE_VERSION', 'get').mockReturnValue({ major: 20, minor: 18, patch: 0 }); + + reactRouterInit({ + dsn: 'https://public@dsn.ingest.sentry.io/1337', + }); + + expect(nodeInit).toHaveBeenCalledTimes(1); + const initOptions = nodeInit.mock.calls[0]?.[0]; + const defaultIntegrations = initOptions?.defaultIntegrations as Integration[]; + + const reactRouterServerIntegration = defaultIntegrations.find( + integration => integration.name === 'ReactRouterServer', + ); + + expect(reactRouterServerIntegration).toBeDefined(); + }); + + it('adds reactRouterServer integration for Node.js 22.11', () => { + vi.spyOn(SentryNode, 'NODE_VERSION', 'get').mockReturnValue({ major: 22, minor: 11, patch: 0 }); + + reactRouterInit({ + dsn: 'https://public@dsn.ingest.sentry.io/1337', + }); + + expect(nodeInit).toHaveBeenCalledTimes(1); + const initOptions = nodeInit.mock.calls[0]?.[0]; + const defaultIntegrations = initOptions?.defaultIntegrations as Integration[]; + + const reactRouterServerIntegration = defaultIntegrations.find( + integration => integration.name === 'ReactRouterServer', + ); + + expect(reactRouterServerIntegration).toBeDefined(); + }); + + it('does not add reactRouterServer integration for Node.js 20.19', () => { + vi.spyOn(SentryNode, 'NODE_VERSION', 'get').mockReturnValue({ major: 20, minor: 19, patch: 0 }); + + reactRouterInit({ + dsn: 'https://public@dsn.ingest.sentry.io/1337', + }); + + expect(nodeInit).toHaveBeenCalledTimes(1); + const initOptions = nodeInit.mock.calls[0]?.[0]; + const defaultIntegrations = initOptions?.defaultIntegrations as Integration[]; + + const reactRouterServerIntegration = defaultIntegrations.find( + integration => integration.name === 'ReactRouterServer', + ); + + expect(reactRouterServerIntegration).toBeUndefined(); + }); + + it('does not add reactRouterServer integration for Node.js 22.12', () => { + vi.spyOn(SentryNode, 'NODE_VERSION', 'get').mockReturnValue({ major: 22, minor: 12, patch: 0 }); + + reactRouterInit({ + dsn: 'https://public@dsn.ingest.sentry.io/1337', + }); + + expect(nodeInit).toHaveBeenCalledTimes(1); + const initOptions = nodeInit.mock.calls[0]?.[0]; + const defaultIntegrations = initOptions?.defaultIntegrations as Integration[]; + + const reactRouterServerIntegration = defaultIntegrations.find( + integration => integration.name === 'ReactRouterServer', + ); + + expect(reactRouterServerIntegration).toBeUndefined(); + }); }); }); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy