feat(core): Allow to pass mechanism
as event hint
#9590
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This allows to pass
mechanism
as an event hint. Also, we now allow to passhint
as an alternative toCaptureContext
tocaptureException
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 exportedcaptureException()
we take aCaptureContext
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.