Skip to content

Commit af08ff4

Browse files
authored
Merge branch 'develop' into fix/elysia-sdk-metadata
2 parents d5e0a0d + 045bcb0 commit af08ff4

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

‎packages/elysia/src/sdk.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
bunServerIntegration,
44
getDefaultIntegrations as getBunDefaultIntegrations,
55
makeFetchTransport,
6+
makeNodeTransport,
67
} from '@sentry/bun';
78
import type { Integration, Options } from '@sentry/core';
89
import { applySdkMetadata } from '@sentry/core';
@@ -50,7 +51,7 @@ export function init(userOptions: ElysiaOptions = {}): NodeClient | undefined {
5051

5152
applySdkMetadata(options, 'elysia', ['elysia', options.runtime.name]);
5253

53-
options.transport = options.transport || makeFetchTransport;
54+
options.transport = options.transport || (options.runtime.name === 'bun' ? makeFetchTransport : makeNodeTransport);
5455

5556
if (options.defaultIntegrations === undefined) {
5657
options.defaultIntegrations = getDefaultIntegrations(options);

‎packages/elysia/test/sdk.test.ts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ import { afterEach, describe, expect, it, vi } from 'vitest';
44
const mockInitNode = vi.fn();
55
const mockGetBunDefaultIntegrations = vi.fn(() => [] as Integration[]);
66
const mockMakeFetchTransport = vi.fn();
7+
const mockMakeNodeTransport = vi.fn();
78

89
vi.mock('@sentry/bun', () => ({
910
init: mockInitNode,
1011
getDefaultIntegrations: mockGetBunDefaultIntegrations,
1112
makeFetchTransport: mockMakeFetchTransport,
13+
makeNodeTransport: mockMakeNodeTransport,
1214
bunServerIntegration: () => ({ name: 'BunServer', setupOnce: vi.fn() }),
1315
}));
1416

@@ -51,16 +53,24 @@ describe('init', () => {
5153
);
5254
});
5355

54-
it('uses makeFetchTransport by default', () => {
56+
it('uses makeNodeTransport by default on Node', () => {
5557
init({ dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0' });
5658

5759
expect(mockInitNode).toHaveBeenCalledWith(
5860
expect.objectContaining({
59-
transport: mockMakeFetchTransport,
61+
transport: mockMakeNodeTransport,
6062
}),
6163
);
6264
});
6365

66+
it('uses makeFetchTransport by default on Bun', () => {
67+
vi.stubGlobal('Bun', { version: '1.2.3' });
68+
69+
init({ dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0' });
70+
71+
expect(mockInitNode).toHaveBeenCalledWith(expect.objectContaining({ transport: mockMakeFetchTransport }));
72+
});
73+
6474
it('allows overriding transport', () => {
6575
const customTransport = vi.fn();
6676
init({ dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0', transport: customTransport });

0 commit comments

Comments
 (0)