Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(scope): Bring back lastEventId on isolation scope (#11951) #12022

Merged
merged 4 commits into from
May 14, 2024

Conversation

andreiborza
Copy link
Member

As discussed, we'll keep it simple and set the event id regardless of the event getting dropped.

A follow-up PR will update ReportDialogOptions to make eventId optional again as well as use the isolation scope directly in React ErrorBoundaries.

@andreiborza andreiborza requested a review from mydea May 14, 2024 11:45
@andreiborza andreiborza changed the title Ab/last event id scope feat(scope): Bring back lastEventId on isolation scope (#11951) May 14, 2024
Copy link
Contributor

github-actions bot commented May 14, 2024

size-limit report 📦

Path Size
@sentry/browser 21.67 KB (+0.19% 🔺)
@sentry/browser (incl. Tracing) 32.8 KB (+0.12% 🔺)
@sentry/browser (incl. Tracing, Replay) 68.14 KB (+0.06% 🔺)
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 61.5 KB (+0.07% 🔺)
@sentry/browser (incl. Tracing, Replay with Canvas) 72.19 KB (+0.06% 🔺)
@sentry/browser (incl. Tracing, Replay, Feedback) 84.2 KB (+0.05% 🔺)
@sentry/browser (incl. Feedback) 37.6 KB (+0.11% 🔺)
@sentry/browser (incl. sendFeedback) 26.23 KB (+0.14% 🔺)
@sentry/browser (incl. FeedbackAsync) 30.6 KB (+0.14% 🔺)
@sentry/react 24.35 KB (+0.16% 🔺)
@sentry/react (incl. Tracing) 35.76 KB (+0.11% 🔺)
@sentry/vue 25.5 KB (+0.16% 🔺)
@sentry/vue (incl. Tracing) 34.59 KB (+0.12% 🔺)
@sentry/svelte 21.8 KB (+0.18% 🔺)
CDN Bundle 24.18 KB (+0.2% 🔺)
CDN Bundle (incl. Tracing) 34.15 KB (+0.16% 🔺)
CDN Bundle (incl. Tracing, Replay) 67.85 KB (+0.09% 🔺)
CDN Bundle (incl. Tracing, Replay, Feedback) 72.81 KB (+0.07% 🔺)
CDN Bundle - uncompressed 71.16 KB (+0.25% 🔺)
CDN Bundle (incl. Tracing) - uncompressed 101.31 KB (+0.17% 🔺)
CDN Bundle (incl. Tracing, Replay) - uncompressed 210.93 KB (+0.09% 🔺)
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 223.23 KB (+0.08% 🔺)
@sentry/nextjs (client) 35 KB (+0.14% 🔺)
@sentry/sveltekit (client) 33.37 KB (+0.14% 🔺)
@sentry/node 140.99 KB (+0.04% 🔺)
@sentry/aws-serverless 128.03 KB (+0.04% 🔺)

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

Great! Just had two comments but looking good!

packages/core/src/exports.ts Outdated Show resolved Hide resolved
Comment on lines 653 to 656
const eventId = event.event_id || hint.event_id;
if (eventId) {
isolationScope.setLastEventId(eventId);
}
Copy link
Member

Choose a reason for hiding this comment

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

m: I think we pass all kinds of events through _prepareEvent right? Before removing this function, we only updated the last event id for error events. I'd argue we should do the same now.

see

if (!event.type) {
this._lastEventId = eventId;
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea, everything goes through that, including captureMessage and captureEvent. I aligned this change to the Python SDK (ref: getsentry/sentry-python#3064) where they also store it for any event.

The name kind of sounds to me like it would really contain any event, not just errors, but I can change it to just errors, wdyt?

cc @mydea

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I think I worded this incorrectly. I'm totally fine with error and message events that's all good. They all have event.type === 'undefined'.

As for Replay or transaction/span events, these also go through _prepareEvent but they have a different event.type. I woudn't update lastEventId for them because

  1. then users will much more likely get completely unexpected lastEventId return values. For example, a transaction could end right between the error being captured and users calling lastEventId --> the return value would return the transaction event id.
  2. previous behaviour was also to not update the id for these events.

I agree, naming-wise lastEventId implies any event but this has historic reasons. This API probably existed long before we decided to send spans/transactions and also treat them as events with a different type.

Happy to be overruled but I think we should consider at least point 1

Copy link
Member

Choose a reason for hiding this comment

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

I agree with lukas, that makes the most sense to me too! :)

Copy link
Member Author

Choose a reason for hiding this comment

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

@Lms24 fixed. Thanks for the explanation, I assumed too much what an Event is :)

andreiborza and others added 2 commits May 14, 2024 17:11
Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

Great, thanks!

@andreiborza andreiborza merged commit 6f81262 into develop May 14, 2024
98 checks passed
@andreiborza andreiborza deleted the ab/last-event-id-scope branch May 14, 2024 15:50
andreiborza added a commit that referenced this pull request May 16, 2024
…2022)

Co-authored-by: Lukas Stracke <lukas.stracke@sentry.io>
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.

None yet

3 participants