Skip to content

feat(core): Allow to pass mechanism as event hint #9590

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

Merged
merged 3 commits into from
Nov 22, 2023
Merged

Conversation

mydea
Copy link
Member

@mydea mydea commented Nov 17, 2023

This allows to pass mechanism as an event hint. Also, we now allow to pass hint as an alternative to CaptureContext to captureException as second argument.

We have quite a lot of code where we fork a scope and add an event processor, only to add a mechanism to the event.
Since this is a quite common pattern, I figured it makes more sense to allow to pass a mechanism as an EventHint.

In addition, I noticed that while hub.captureException() takes an event hint as second argument, in the core exported captureException() we take a CaptureContext as second argument instead (for legacy reasons).

In order to be able to pass a mechanism there as well, I updated the method signature to allow either a CaptureContext or an EventHint. I wrote some tests covering this to make sure that works - it's a bit tricky since both can be POJOs, but no fields overlap so we are able to parse this together.

@mydea mydea requested review from lforst, Lms24 and AbhiPrasad November 17, 2023 10:00
@mydea mydea self-assigned this Nov 17, 2023
Copy link
Contributor

github-actions bot commented Nov 17, 2023

size-limit report 📦

Path Size
@sentry/browser (incl. Tracing, Replay) - Webpack (gzipped) 66.02 KB (+0.12% 🔺)
@sentry/browser (incl. Tracing, Replay) - Webpack with treeshaking flags (gzipped) 56.1 KB (+0.14% 🔺)
@sentry/browser (incl. Tracing) - Webpack (gzipped) 31.1 KB (+0.27% 🔺)
@sentry/browser - Webpack (gzipped) 21.41 KB (+0.39% 🔺)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (gzipped) 62.42 KB (+0.1% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (gzipped) 29.23 KB (+0.29% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped) 21.35 KB (+0.35% 🔺)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (minified & uncompressed) 196.93 KB (+0.16% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (minified & uncompressed) 88.74 KB (+0.35% 🔺)
@sentry/browser - ES6 CDN Bundle (minified & uncompressed) 63.71 KB (+0.49% 🔺)
@sentry/browser (incl. Tracing) - ES5 CDN Bundle (gzipped) 31.96 KB (+0.3% 🔺)
@sentry/react (incl. Tracing, Replay) - Webpack (gzipped) 66.31 KB (+0.12% 🔺)
@sentry/react - Webpack (gzipped) 21.45 KB (+0.39% 🔺)
@sentry/nextjs Client (incl. Tracing, Replay) - Webpack (gzipped) 83.08 KB (+0.11% 🔺)
@sentry/nextjs Client - Webpack (gzipped) 48.25 KB (+0.18% 🔺)
@sentry-internal/feedback - Webpack (gzipped) 16.19 KB (+0.55% 🔺)

@mydea mydea force-pushed the fn/capture-mechanism branch from 9d6534f to ba30c7f Compare November 21, 2023 13:33
Also, allow to pass `hint` as an alternative to `CaptureContext` to `captureException` as second argument.
@mydea mydea force-pushed the fn/capture-mechanism branch from ba30c7f to 286d1fb Compare November 22, 2023 09:16
@mydea mydea merged commit f251833 into develop Nov 22, 2023
@mydea mydea deleted the fn/capture-mechanism branch November 22, 2023 10:48
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