【发布时间】:2021-01-27 07:27:00
【问题描述】:
也许我误解了目的。我正在寻找一种解决方案来替换我的应用程序中的 console.log(errors),因为我已经准备好投入生产。我完成了将 Sentry 功能添加到我的 expo 托管工作流程项目的步骤。它似乎工作,它连接,它运行 Sentry.init() 就好了。但是当我尝试使用 Sentry.captureException('some exception') 代替 console.log 时,应用程序崩溃并且我得到“Sentry.captureException 不是函数”。它在我的哨兵控制台中记录了那个错误。所以错误被传递给我的哨兵项目。但是从我关注的文档来看, Sentry.captureException 应该是一个有效的函数吗?我错过了什么?我也尝试过 Sentry.captureMessage,结果相同。
App.js
import * as Sentry from 'sentry-expo';
Sentry.init({
dsn: 'xxxx',
enableInExpoDevelopment: true,
debug: true, // Sentry will try to print out useful debugging information if something goes wrong with sending an event. Set this to `false` in production.
});
enableScreens();
export default function App() {
return (
<NavigationContainer>
<AuthNavigator />
</NavigationContainer>
)
}
app.json 展示钩子
"hooks": {
"postPublish": [
{
"file": "sentry-expo/upload-sourcemaps",
"config": {
"organization": "myorganization",
"project": "myproject",
"authToken": "xxxx"
}
}
]
}
【问题讨论】: