@sentry/react-native与react-native-web一起使用 – ErrorUtils未定义

huangapple go评论56阅读模式
英文:

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

问题

我正在尝试在一个使用 React Native Web 的项目中使用 @sentry/react-native。

React Native Web 似乎没有定义 ErrorUtils,根据我的了解,这是一个 React Native 的函数。这很不幸,因为据我观察,@sentry/react-native 似乎依赖于它。当我尝试使用它时,以下错误输出显示了这一点:

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)

那么,在 Sentry 尝试使用这些必要函数之前,我是否有办法在某种程度上替换这些函数,或者有解决这个问题的一些变通方法?还是我必须使用 Sentry 的 JavaScript SDK 在 Web 上使用 platform.select 或类似的方法?

英文:

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?

答案1

得分: 0

这在Sentry Github上友好地得到了回答

> 这在#2808中已修复。4.14.1版本将于今天稍后发布(2023年2月16日)。请注意,react-native-web不受官方支持。您需要将GlohalHandlers和TryCatch添加到集成中以获取Web错误。

英文:

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.

huangapple
  • 本文由 发表于 2023年2月16日 17:11:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/75469993.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定