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

fix(core): Only generate eventIds in client #6247

Merged
merged 4 commits into from Nov 22, 2022

Conversation

AbhiPrasad
Copy link
Member

@AbhiPrasad AbhiPrasad commented Nov 21, 2022

Fixes #6244

This changes moves all generation of eventId uuids to the client. Since we can't change the signature of hub.captureException and similar, we return a event id of zeros, 00000000000000000000000000000000, if the client method returns undefined.

This should improve the performance of the SDKs!

@github-actions
Copy link
Contributor

github-actions bot commented Nov 21, 2022

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.5 KB (-0.12% 🔽)
@sentry/browser - ES5 CDN Bundle (minified) 60.29 KB (-0.14% 🔽)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.16 KB (-0.05% 🔽)
@sentry/browser - ES6 CDN Bundle (minified) 53.63 KB (-0.17% 🔽)
@sentry/browser - Webpack (gzipped + minified) 19.9 KB (-0.04% 🔽)
@sentry/browser - Webpack (minified) 65.12 KB (-0.1% 🔽)
@sentry/react - Webpack (gzipped + minified) 19.92 KB (-0.09% 🔽)
@sentry/nextjs Client - Webpack (gzipped + minified) 45.91 KB (-0.04% 🔽)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 26.34 KB (-0.07% 🔽)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 24.77 KB (-0.01% 🔽)

@AbhiPrasad AbhiPrasad self-assigned this Nov 21, 2022
@AbhiPrasad AbhiPrasad marked this pull request as ready for review November 21, 2022 13:29
Comment on lines 189 to 190
return (this._lastEventId =
this._withClient((client, scope) => {
Copy link
Member

Choose a reason for hiding this comment

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

l: Can we make this assignment a little clearer by first assigning this._lastEventId and then returning it? Or does this syntax save significantly more bundle size? Just asking because it took me a second to realize what's going on here

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah I was maybe overzealous with the bundle size saving here, will refactor.

Copy link
Member Author

Choose a reason for hiding this comment

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

function makeClient() {
return {
getOptions: jest.fn(),
captureEvent: jest.fn(),
captureException: jest.fn(),
captureException: jest.fn().mockReturnValue(MOCK_EVENT_ID),
Copy link
Member

Choose a reason for hiding this comment

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

Where are we using this value? Couldn't find usage in the changed tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

MOCK_EVENT_ID is what hub.lastEventId() is being set as. It's not being directly asserted on, just used as a return value from captureException (so we can differentiate between undefined)


expect(args[2].event_id).toBeTruthy();
const id = hub.captureMessage('a');
expect(id).toBeTruthy();
Copy link
Member

Choose a reason for hiding this comment

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

l: Probably related to my point above but can we check the id here for a more precise value than it being truthy or is this alright (totally your call, just asking)?

Copy link
Member Author

Choose a reason for hiding this comment

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

All I care about is that this is not undefined, will adjust for that.


expect(args[1].event_id).toBeTruthy();
const id = hub.captureEvent(event);
expect(id).toBeTruthy();
});

test('should keep event_id from hint', () => {
Copy link
Member

Choose a reason for hiding this comment

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

Is this ("from hint") still correct?

Copy link
Member Author

Choose a reason for hiding this comment

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

yup it is

@AbhiPrasad AbhiPrasad enabled auto-merge (squash) November 22, 2022 14:26
@AbhiPrasad AbhiPrasad merged commit 3fe5f7a into master Nov 22, 2022
@AbhiPrasad AbhiPrasad deleted the abhi-fix-eventid-processing branch November 22, 2022 16:33
AbhiPrasad added a commit that referenced this pull request Dec 2, 2022
AbhiPrasad added a commit that referenced this pull request Dec 2, 2022
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.

Unneeded additional overhead of instrumentation
2 participants