Skip to content

fix(core): Respect event.event_id in scope.captureEvent return value#19113

Merged
andreiborza merged 1 commit intogetsentry:developfrom
limbonaut:fix/event-id-not-respected
Feb 3, 2026
Merged

fix(core): Respect event.event_id in scope.captureEvent return value#19113
andreiborza merged 1 commit intogetsentry:developfrom
limbonaut:fix/event-id-not-respected

Conversation

@limbonaut
Copy link
Contributor

I found a bug while working on the JavaScript SDK integration in Sentry for Godot (it's a game engine SDK).

When you call Sentry.captureEvent({ event_id: "<custom-event-id>" }), the event_id you provide IS actually used when the event is processed and sent to Sentry (because prepareEvent.ts correctly checks event.event_id first). However, the return value from captureEvent() is wrong because:

In sentry-javascript/packages/core/src/scope.ts:

const eventId = hint?.event_id || uuid4();

This only checks hint?.event_id, not event.event_id. So while your supplied event_id gets sent to Sentry correctly, the function returns a newly generated UUID.

Closes #issue_link_here

*/
public captureEvent(event: Event, hint?: EventHint): string {
const eventId = hint?.event_id || uuid4();
const eventId = event.event_id || hint?.event_id || uuid4();
Copy link
Member

Choose a reason for hiding this comment

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

For prosperity: I was initially thinking we should prioritize hint over event but it seems like we aren't doing that in other places as you brought up:

isolationScope.setLastEventId(event.event_id || hint.event_id);

event_id: event.event_id || hint.event_id || uuid4(),

Let's stick with event over hint over uuid for now!

Copy link
Member

@andreiborza andreiborza left a comment

Choose a reason for hiding this comment

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

Thanks for taking care of this!

@andreiborza andreiborza merged commit 3fa7a86 into getsentry:develop Feb 3, 2026
195 of 196 checks passed
Lms24 pushed a commit that referenced this pull request Feb 4, 2026
This PR adds the external contributor to the CHANGELOG.md file, so that
they are credited for their contribution. See #19113

Co-authored-by: andreiborza <168741329+andreiborza@users.noreply.github.com>
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.

2 participants