Skip to content

fix(elysia): Set SDK metadata on the options passed to init - #24521

Open
Shubham-Padkonde wants to merge 4 commits into
getsentry:developfrom
Shubham-Padkonde:fix/elysia-sdk-metadata
Open

Shubham-Padkonde wants to merge 4 commits into
getsentry:developfrom
Shubham-Padkonde:fix/elysia-sdk-metadata

Conversation

@Shubham-Padkonde

@Shubham-Padkonde Shubham-Padkonde commented Sep 19, 2026 •

Copy link
Copy Markdown

init() copied userOptions into options and then applied SDK metadata to userOptions. When metadata was initially absent, the copied options passed to the underlying SDK did not receive Elysia's SDK name.

Apply SDK metadata to the options passed to the underlying SDK. The regression test uses the real metadata helper and checks that initNode receives sentry.javascript.elysia metadata.

Closes #24045

Original contribution generated with Claude Code; review follow-up prepared with OpenAI Codex assistance.

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 getsentry#24045

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Shubham-Padkonde
Shubham-Padkonde requested a review from a team as a code owner September 19, 2026 09:30
@Shubham-Padkonde
Shubham-Padkonde requested review from mydea and s1gr1d and removed request for a team September 19, 2026 09:30
@github-actions

Copy link
Copy Markdown
Contributor

👋 @mydea, @s1gr1d — Please review this PR when you get a chance!

@s1gr1d
s1gr1d requested a review from logaretm September 24, 2026 12:21

@logaretm logaretm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, it looks good mostly but I think we need to test this properly. I've called out a simple change in the existing test.

We should also assert the SDK metadata in both e2e test Elysia apps we have, each should detect the runtime/name correctly.

You can add an assertions in these test cases:

Something like this should be fine:

expect(errorEvent.sdk?.name).toBe('sentry.javascript.elysia');

That checks the real event on both runtimes.

Comment thread packages/elysia/test/sdk.test.ts Outdated
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]);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We avoid asserting via mock.calls[0]?.[0], and I don't think it asserts what we want to test.

Could we drop the applySdkMetadata mock and assert what initNode should receive.

expect(mockInitNode).toHaveBeenCalledWith(
  expect.objectContaining({
    _metadata: { sdk: expect.objectContaining({ name: 'sentry.javascript.elysia' }) },
  }),
);

Co-Authored-By: OpenAI Codex <codex@openai.com>
@Shubham-Padkonde

Shubham-Padkonde commented Sep 24, 2026 •

Copy link
Copy Markdown
Author

Removed the applySdkMetadata mock and now assert the actual Elysia metadata received by initNode, as requested. Confirmed that the revised test fails when metadata is applied to userOptions instead of options, and all 31 Elysia package tests pass with the fix. Formatting and lint checks pass on the changed unit test.

Also added the requested errorEvent.sdk?.name assertion to both the Node and Bun E2E error tests. Their formatting checks pass. Local E2E execution stopped before running tests because this checkout has no packed SDK tarballs; those two runtime checks still need CI verification. I did not run the full monorepo suite. Prepared with OpenAI Codex assistance.

Co-Authored-By: OpenAI Codex <codex@openai.com>

@logaretm logaretm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are failing due to a mockApplySdkMetadata not being defined, probably a simple typo

Co-Authored-By: OpenAI Codex <codex@openai.com>
@Shubham-Padkonde

Copy link
Copy Markdown
Author

The failure came from the new Bun-runtime test added on develop: the automatic CI merge retained its reference to the removed mock. Merged develop and changed that assertion to verify the runtime and actual Elysia SDK metadata received by initNode (7fe29ad).

All 32 Elysia package tests now pass locally, including the Bun-runtime case; the changed test passes formatting and lint. The E2E Hydrogen failures in the previous run are separate from this missing-reference failure and are not claimed fixed by this change. Prepared with Codex assistance.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Elysia events report as sentry.javascript.bun

2 participants