Skip to content

Commit 120ae6d

Browse files
authored
feat(sveltekit): Add Undici integration by default (#7650)
1 parent 9e98330 commit 120ae6d

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

packages/sveltekit/src/server/sdk.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { configureScope } from '@sentry/core';
22
import type { NodeOptions } from '@sentry/node';
3-
import { init as initNodeSdk } from '@sentry/node';
3+
import { init as initNodeSdk, Integrations } from '@sentry/node';
4+
import { addOrUpdateIntegration } from '@sentry/utils';
45

56
import { applySdkMetadata } from '../common/metadata';
67

@@ -11,9 +12,15 @@ import { applySdkMetadata } from '../common/metadata';
1112
export function init(options: NodeOptions): void {
1213
applySdkMetadata(options, ['sveltekit', 'node']);
1314

15+
addServerIntegrations(options);
16+
1417
initNodeSdk(options);
1518

1619
configureScope(scope => {
1720
scope.setTag('runtime', 'node');
1821
});
1922
}
23+
24+
function addServerIntegrations(options: NodeOptions): void {
25+
options.integrations = addOrUpdateIntegration(new Integrations.Undici(), options.integrations || []);
26+
}

packages/sveltekit/test/server/sdk.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,20 @@ describe('Sentry server SDK', () => {
4747
// @ts-ignore need access to protected _tags attribute
4848
expect(currentScope._tags).toEqual({ runtime: 'node' });
4949
});
50+
51+
it('adds the Undici integration', () => {
52+
init({});
53+
54+
expect(nodeInit).toHaveBeenCalledTimes(1);
55+
expect(nodeInit).toHaveBeenCalledWith(
56+
expect.objectContaining({
57+
integrations: expect.arrayContaining([
58+
expect.objectContaining({
59+
name: 'Undici',
60+
}),
61+
]),
62+
}),
63+
);
64+
});
5065
});
5166
});

0 commit comments

Comments
 (0)