expo - Sentry 找不到我的源代码

标签 expo sentry react-native-sentry

我无法在 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>"
          }
        }
      ]
    }
}

  1. organization 你可以在这里找到 https://sentry.io/settings/其中命名为“组织名称”
  2. project 输入你的项目名称,你可以在这里找到:https://sentry.io/organizations/ORGANIZATION_NAME/projects/
  3. authToken 使用此 url 创建一个 authToken https://sentry.io/api/

然后运行expo publish,它会自动上传源 map 。

本地测试

确保您启用了 expo development。 添加行;

Sentry.enableInExpoDevelopment = true;
Sentry.config(publicDsn, options).install();

结果

在 Sentry 上,仅适用于ios,您可以看到发生错误的源代码。 enter image description here

但是:无法查看 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/

相关文章:

javascript - 使用 TypeScript 将 JSON(来自 Sentry)转换为 HTML

python - 在新的 sentry-python SDK 中将 extra 的字典传递给 captureException 有什么等价物?

react-native - React Native 0.60+ on iOS : Code Push, Sentry、React Native Navigation v3 和 AppDelegate.m

javascript - 如何在 React Native 中添加多个组件?

javascript - 无法在 React Native 中使用从 AsyncStorage/SecureStore 返回的电子邮件和 token ?

python - 如何忽略 Sentry 的一些错误(不发送它们)?

react-native - 如何使用@sentry/react-native 在我的模拟器中打开用户反馈窗口

react-native - 如何使用 react-native 设置 Sentry-cli 源 map

react-native - 如何修改app.json文件并更改博览会小吃的sdkVersion?

Image.prefetch 不会自动从缓存中加载 [React-Native/Expo]