getsentry / sentry-react-native

Official Sentry SDK for React Native
https://sentry.io
MIT License
1.59k stars 337 forks source link

Add `onunhandledrejection` error machanism type to rejected promises #4093

Open romtsn opened 2 months ago

romtsn commented 2 months ago

Description

Currently we override whatever mechanism comes from the JS sdk, see here: https://github.com/getsentry/sentry-react-native/blob/c2a4e9b9386a596d6e84a9d857c77418388c0e5f/src/js/integrations/reactnativeerrorhandlers.ts#L146-L160

Perhaps we should preserve the original mechanism type at least, because it might be useful when filtering issues in issue stream/discover. One such case was reported with regards to onunhandledrejection type for unhandled promise rejections.

krystofwoldrich commented 2 months ago

We create a new event in the global error handler and we set the error mechanism, there is no previous value.

onunhandledrejection is handled at: https://github.com/getsentry/sentry-react-native/blob/933804ec2ad2153b9bd42d91bff2bb69d7f2a672/packages/core/src/js/integrations/reactnativeerrorhandlers.ts#L81-L85

And I agree we should add the correct mechanism to it.