Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/astro/src/index.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export {
logger,
consoleLoggingIntegration,
wrapMcpServerWithSentry,
NODE_VERSION,
} from '@sentry/node';

export { init } from './server/sdk';
Expand Down
1 change: 1 addition & 0 deletions packages/aws-serverless/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export {
logger,
consoleLoggingIntegration,
wrapMcpServerWithSentry,
NODE_VERSION,
} from '@sentry/node';

export {
Expand Down
1 change: 1 addition & 0 deletions packages/bun/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export {
consoleLoggingIntegration,
createSentryWinstonTransport,
wrapMcpServerWithSentry,
NODE_VERSION,
} from '@sentry/node';

export {
Expand Down
1 change: 1 addition & 0 deletions packages/google-cloud-serverless/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export {
logger,
consoleLoggingIntegration,
wrapMcpServerWithSentry,
NODE_VERSION,
} from '@sentry/node';

export {
Expand Down
1 change: 1 addition & 0 deletions packages/node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
14 changes: 8 additions & 6 deletions packages/react-router/src/server/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -13,11 +13,13 @@ 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) {
integrations.push(reactRouterServerIntegration());
}

return integrations;
}

/**
Expand Down
36 changes: 36 additions & 0 deletions packages/react-router/test/server/sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,41 @@ 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://[email protected]/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://[email protected]/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();
});
});
});