feat(core): Allow to pass mechanism as event hint#9590
Merged
Conversation
Contributor
size-limit report 📦
|
AbhiPrasad
approved these changes
Nov 20, 2023
9d6534f to
ba30c7f
Compare
Also, allow to pass `hint` as an alternative to `CaptureContext` to `captureException` as second argument.
ba30c7f to
286d1fb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
mechanismas an event hint. Also, we now allow to passhintas an alternative toCaptureContexttocaptureExceptionas 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 aCaptureContextas 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.