react-nativesentryreact-native-webreact-native-sentry

@sentry/react-native with react-native-web -- ErrorUtils is not defined


I'm trying to use @sentry/react-native in a project that uses React Native Web.

React Native Web seems to not define ErrorUtils, which from what I gather is a React Native function. This is unfortunate as @sentry/react-native seems to depend on it, from what I can tell from the following error output when I try to use it:

node_modules/@sentry/react-native/dist/js/integrations/reactnativeerrorhandlers.js

Uncaught ReferenceError: ErrorUtils is not defined
    at ReactNativeErrorHandlers._handleOnError (reactnativeerrorhandlers.ts:169:9)
    at ReactNativeErrorHandlers.setupOnce (reactnativeerrorhandlers.ts:52:10)

So is there any way for me to somehow swap out the necessary functions before Sentry tries to use them, or some workaround to this issue, or will I have to use the Sentry JS SDK on the web with a platform.select or something?


Solution

  • This was kindly answered on the Sentry Github

    This was fixed in #2808. Release 4.14.1 is coming later today (16 Feb 2023). Note that react-native-web is not officially supported. You will need to add GlohalHandlers and TryCatch to the integrations to get web errors.