From e4ae88df0f4c95cebbc07742cc7ff5d2645c7d69 Mon Sep 17 00:00:00 2001 From: Shubham Padkonde Date: Sat, 19 Sep 2026 11:23:04 +0530 Subject: [PATCH 1/4] fix(elysia): Set SDK metadata on the options passed to init applySdkMetadata was applied to userOptions after they had already been copied into the options passed to @sentry/bun's init, so the copy kept no metadata and Bun set its own. Events were reported as sentry.javascript.bun instead of sentry.javascript.elysia. Fixes #24045 Co-Authored-By: Claude Opus 5 --- packages/elysia/src/sdk.ts | 2 +- packages/elysia/test/sdk.test.ts | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/elysia/src/sdk.ts b/packages/elysia/src/sdk.ts index f8d8dd9d8a35..b151b8282361 100644 --- a/packages/elysia/src/sdk.ts +++ b/packages/elysia/src/sdk.ts @@ -48,7 +48,7 @@ export function init(userOptions: ElysiaOptions = {}): NodeClient | undefined { serverName: userOptions.serverName || global.process.env.SENTRY_NAME || os.hostname(), }; - applySdkMetadata(userOptions, 'elysia', ['elysia', options.runtime.name]); + applySdkMetadata(options, 'elysia', ['elysia', options.runtime.name]); options.transport = options.transport || makeFetchTransport; diff --git a/packages/elysia/test/sdk.test.ts b/packages/elysia/test/sdk.test.ts index 142c3f4ff456..4f3828679bc4 100644 --- a/packages/elysia/test/sdk.test.ts +++ b/packages/elysia/test/sdk.test.ts @@ -42,6 +42,12 @@ describe('init', () => { ); }); + it('sets SDK metadata on the options passed to initNode', () => { + init({ dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0' }); + + expect(mockApplySdkMetadata.mock.calls[0]?.[0]).toBe(mockInitNode.mock.calls[0]?.[0]); + }); + it('calls initNode with the options', () => { init({ dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0' }); From ba5af5a8f056bd95bc520491ac479c2ed3377b19 Mon Sep 17 00:00:00 2001 From: Shubham Padkonde Date: Thu, 24 Sep 2026 22:53:36 +0530 Subject: [PATCH 2/4] test(elysia): assert metadata received by the runtime SDK Co-Authored-By: OpenAI Codex --- packages/elysia/test/sdk.test.ts | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/packages/elysia/test/sdk.test.ts b/packages/elysia/test/sdk.test.ts index 4f3828679bc4..196b5e00db82 100644 --- a/packages/elysia/test/sdk.test.ts +++ b/packages/elysia/test/sdk.test.ts @@ -1,20 +1,10 @@ import type { Integration } from '@sentry/core'; import { afterEach, describe, expect, it, vi } from 'vitest'; -const mockApplySdkMetadata = vi.fn(); const mockInitNode = vi.fn(); const mockGetBunDefaultIntegrations = vi.fn(() => [] as Integration[]); const mockMakeFetchTransport = vi.fn(); -vi.mock('@sentry/core', async importActual => { - // eslint-disable-next-line @typescript-eslint/consistent-type-imports - const actual = await importActual(); - return { - ...actual, - applySdkMetadata: mockApplySdkMetadata, - }; -}); - vi.mock('@sentry/bun', () => ({ init: mockInitNode, getDefaultIntegrations: mockGetBunDefaultIntegrations, @@ -32,22 +22,16 @@ describe('init', () => { vi.unstubAllGlobals(); }); - it('sets SDK metadata to elysia', () => { + it('passes Elysia SDK metadata to initNode', () => { init({ dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0' }); - expect(mockApplySdkMetadata).toHaveBeenCalledWith( - expect.objectContaining({ dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0' }), - 'elysia', - ['elysia', 'node'], + expect(mockInitNode).toHaveBeenCalledWith( + expect.objectContaining({ + _metadata: { sdk: expect.objectContaining({ name: 'sentry.javascript.elysia' }) }, + }), ); }); - it('sets SDK metadata on the options passed to initNode', () => { - init({ dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0' }); - - expect(mockApplySdkMetadata.mock.calls[0]?.[0]).toBe(mockInitNode.mock.calls[0]?.[0]); - }); - it('calls initNode with the options', () => { init({ dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0' }); From 9fc226a22d97a7e03d6be7876875f80a2e2c0902 Mon Sep 17 00:00:00 2001 From: Shubham Padkonde Date: Thu, 24 Sep 2026 23:01:19 +0530 Subject: [PATCH 3/4] test(elysia): assert SDK name in both runtime apps Co-Authored-By: OpenAI Codex --- .../e2e-tests/test-applications/elysia-bun/tests/errors.test.ts | 1 + .../e2e-tests/test-applications/elysia-node/tests/errors.test.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/dev-packages/e2e-tests/test-applications/elysia-bun/tests/errors.test.ts b/dev-packages/e2e-tests/test-applications/elysia-bun/tests/errors.test.ts index 5e587e28fd41..0b3ac95d7cb4 100644 --- a/dev-packages/e2e-tests/test-applications/elysia-bun/tests/errors.test.ts +++ b/dev-packages/e2e-tests/test-applications/elysia-bun/tests/errors.test.ts @@ -19,6 +19,7 @@ test('Captures an error thrown in a route handler', async ({ baseURL, request }) }); expect(errorEvent.transaction).toEqual('GET /test-exception/:id'); + expect(errorEvent.sdk?.name).toBe('sentry.javascript.elysia'); expect(errorEvent.contexts?.trace).toEqual( expect.objectContaining({ diff --git a/dev-packages/e2e-tests/test-applications/elysia-node/tests/errors.test.ts b/dev-packages/e2e-tests/test-applications/elysia-node/tests/errors.test.ts index 258d7abc5adf..64fc4a132d80 100644 --- a/dev-packages/e2e-tests/test-applications/elysia-node/tests/errors.test.ts +++ b/dev-packages/e2e-tests/test-applications/elysia-node/tests/errors.test.ts @@ -19,6 +19,7 @@ test('Captures an error thrown in a route handler', async ({ baseURL, request }) }); expect(errorEvent.transaction).toEqual('GET /test-exception/:id'); + expect(errorEvent.sdk?.name).toBe('sentry.javascript.elysia'); expect(errorEvent.contexts?.trace).toEqual( expect.objectContaining({ From d5e0a0d47bbe6fb1ee4808384df872ea0575f87f Mon Sep 17 00:00:00 2001 From: isaacs Date: Sat, 17 Oct 2026 18:40:45 -0700 Subject: [PATCH 4/4] test(elysia): Assert SDK packages per runtime Check that the SDK metadata lists `@sentry/elysia` and the runtime package (`@sentry/node` or `@sentry/bun`). Assert the detected Node runtime with `toHaveBeenCalledWith` instead of reading `mock.calls`. Co-Authored-By: Claude Opus 5.5 (1M context) --- packages/elysia/test/sdk.test.ts | 35 +++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/packages/elysia/test/sdk.test.ts b/packages/elysia/test/sdk.test.ts index 196b5e00db82..d969387c2220 100644 --- a/packages/elysia/test/sdk.test.ts +++ b/packages/elysia/test/sdk.test.ts @@ -27,7 +27,15 @@ describe('init', () => { expect(mockInitNode).toHaveBeenCalledWith( expect.objectContaining({ - _metadata: { sdk: expect.objectContaining({ name: 'sentry.javascript.elysia' }) }, + _metadata: { + sdk: expect.objectContaining({ + name: 'sentry.javascript.elysia', + packages: [ + expect.objectContaining({ name: 'npm:@sentry/elysia' }), + expect.objectContaining({ name: 'npm:@sentry/node' }), + ], + }), + }, }), ); }); @@ -94,10 +102,12 @@ describe('init', () => { it('detects runtime correctly', () => { init({ dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0' }); - const calledOptions = mockInitNode.mock.calls[0]![0]; // In vitest (Node), Bun is not defined, so runtime should be node - expect(calledOptions.runtime.name).toBe('node'); - expect(calledOptions.runtime.version).toBe(process.version); + expect(mockInitNode).toHaveBeenCalledWith( + expect.objectContaining({ + runtime: { name: 'node', version: process.version }, + }), + ); }); it('detects bun runtime when Bun is defined', () => { @@ -105,9 +115,20 @@ describe('init', () => { init({ dsn: 'https://***@o0.ingest.sentry.io/0' }); - const calledOptions = mockInitNode.mock.calls[0]![0]; - expect(calledOptions.runtime).toEqual({ name: 'bun', version: '1.2.3' }); - expect(mockApplySdkMetadata).toHaveBeenCalledWith(expect.anything(), 'elysia', ['elysia', 'bun']); + expect(mockInitNode).toHaveBeenCalledWith( + expect.objectContaining({ + runtime: { name: 'bun', version: '1.2.3' }, + _metadata: { + sdk: expect.objectContaining({ + name: 'sentry.javascript.elysia', + packages: [ + expect.objectContaining({ name: 'npm:@sentry/elysia' }), + expect.objectContaining({ name: 'npm:@sentry/bun' }), + ], + }), + }, + }), + ); }); });