Skip to content

Commit d5c211d

Browse files
nicohrubeccodex
andauthored
fix(react-router): Respect custom default integrations (#25259)
The React Router Node SDK overwrites `defaultIntegrations`, so `false`, `[]`, and custom arrays are ignored. Only generate the framework defaults when the option is unset, matching the underlying Node SDK's behavior. Co-authored-by: Codex <codex@openai.com>
1 parent 4aa5981 commit d5c211d

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

‎packages/react-router/src/server/sdk.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function getDefaultReactRouterServerIntegrations(options: NodeOptions): I
2424
export function init(options: NodeOptions): NodeClient | undefined {
2525
const opts: NodeOptions = {
2626
...options,
27-
defaultIntegrations: getDefaultReactRouterServerIntegrations(options),
27+
defaultIntegrations: options.defaultIntegrations ?? getDefaultReactRouterServerIntegrations(options),
2828
};
2929

3030
DEBUG_BUILD && debug.log('Initializing SDK...');

‎packages/react-router/test/server/sdk.test.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,26 @@ describe('React Router server SDK', () => {
4646
expect(client).not.toBeUndefined();
4747
});
4848

49+
it.each([
50+
{ value: 'false', defaultIntegrations: false as const },
51+
{ value: 'an empty array', defaultIntegrations: [] },
52+
])('disables default integrations when set to $value', ({ defaultIntegrations }) => {
53+
const client = reactRouterInit({ defaultIntegrations });
54+
55+
expect(client?.getOptions().integrations.map(integration => integration.name)).toEqual(['SpanStreaming']);
56+
});
57+
58+
it('replaces default integrations with a custom array', () => {
59+
const integration = { name: 'CustomIntegration' };
60+
61+
const client = reactRouterInit({ defaultIntegrations: [integration] });
62+
63+
expect(client?.getOptions().integrations.map(integration => integration.name)).toEqual([
64+
'CustomIntegration',
65+
'SpanStreaming',
66+
]);
67+
});
68+
4969
it('adds the low quality transactions filter integration by default', () => {
5070
const filterSpy = vi.spyOn(LowQualityModule, 'lowQualityTransactionsFilterIntegration');
5171

0 commit comments

Comments
 (0)