在响应本机应用程序中在哪里初始化sentry.init

问题描述

在我的本机应用程序中,要跟踪错误,我将使用哨兵。所以,我到底应该在哪里使用Sentry.init

我试图在useEffect中的app.ts中使用它。但是,如果在加载应用程序之前出现任何错误,则不会对此进行跟踪。

我应该在哪里使用此代码正确处理哨兵?

 Sentry.init({
    dsn: SENTRY_DSN,environment: ENVIRONMENT,});

解决方法

在我的项目中,我像这样使用,并且遇到了所有错误(在App组件之前)

import * as Sentry from '@sentry/react-native';
Sentry.init({
  dsn: 'https://[email protected]/1781718'
});


export default class App extends Component {
...
}