From 428c94f78e5dfe3798fccf83f47ce12a32c20527 Mon Sep 17 00:00:00 2001 From: Shubham Padkonde Date: Sat, 19 Sep 2026 11:23:04 +0530 Subject: [PATCH 1/3] 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 d27011f0e416..8fc40b71d30e 100644 --- a/packages/elysia/test/sdk.test.ts +++ b/packages/elysia/test/sdk.test.ts @@ -41,6 +41,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 4a278b7d8c1590a86b63531b56ef6cc647453519 Mon Sep 17 00:00:00 2001 From: Shubham Padkonde Date: Thu, 24 Sep 2026 22:53:36 +0530 Subject: [PATCH 2/3] 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 8fc40b71d30e..af0881d90485 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, @@ -31,22 +21,16 @@ describe('init', () => { vi.clearAllMocks(); }); - 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 68cf6702cedc98eb0c28f396a786044f23ea6067 Mon Sep 17 00:00:00 2001 From: Shubham Padkonde Date: Thu, 24 Sep 2026 23:01:19 +0530 Subject: [PATCH 3/3] 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({