我无法在 sentry 仪表板中显示我的原始代码。
我得到以下错误
丢弃无效参数'type'
Source code was not found for app:///crna-entry.delta?
platform=ios&dev=true&minify=false`
我已经按照文档中的说明配置了 app.json
。
"hooks": {
"postPublish": [
{
"file": "sentry-expo/upload-sourcemaps",
"config": {
"organization": "xxxxx",
"project": "xxxxxxx",
"authToken": "xxxxxxxxxx"
}
}
]
}
最佳答案
我回答了这个问题here
第一种方式
如果你正在使用 expo.你应该使用 sentry-expo
包,你可以在这里找到它:sentry-expo
把这个钩子(Hook)放到你的 expo json (app.json) 文件中
{
"expo": {
"hooks": {
"postPublish": [
{
"file": "sentry-expo/upload-sourcemaps",
"config": {
"organization": "<your organization name>",
"project": "<your project name>",
"authToken": "<your auth token here>"
}
}
]
}
}
organization
你可以在这里找到 https://sentry.io/settings/其中命名为“组织名称”project
输入你的项目名称,你可以在这里找到:https://sentry.io/organizations/ORGANIZATION_NAME/projects/authToken
使用此 url 创建一个 authToken https://sentry.io/api/
然后运行expo publish
,它会自动上传源 map 。
本地测试
确保您启用了 expo development。 添加行;
Sentry.enableInExpoDevelopment = true;
Sentry.config(publicDsn, options).install();
结果
在 Sentry 上,仅适用于ios,您可以看到发生错误的源代码。
但是:无法查看 ANDROID 的源代码
https://github.com/getsentry/react-native-sentry/issues/372
第二种方式(手动上传)
使用 API https://docs.sentry.io/platforms/javascript/sourcemaps/
curl -X POST \
https://sentry.io/api/0/organizations/ORG_NAME/releases/VERSION/files/ \
-H 'Authorization: Bearer AUTH_TOKEN' \
-H 'content-type: multipart/form-data' \
-F file=@script.min.js.map \
-F 'name=~/scripts/script.min.js.map'
关于expo - Sentry 找不到我的源代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51963208/