How to manually upload my source code to sentry?

怎甘沉沦 提交于 2019-12-10 19:35:50

问题


My app is built with expo and sentry dashboard shows me 2 errors :

Discarded invalid parameter 'type'

and

Source code was not found for app:///crna-entry.bundle? platform=ios&dev=true&minify=false&hot=false&assetPlugin=%2FUsers%2FUser%2FDesktop%2Fpath%2Fto%2Fnode_modules%2Fexp.

So when i receive errors, it's impossible to debug because i only have an uglyfied built js.

Is there any way to upload the source expo source code manually. Which file should i send to sentry?

Thanks


回答1:


First way

If you are using expo. You should use sentry-expo package which you can find here: sentry-expo

Put this hook to your expo json (app.json) file

{
  "expo": {
    "hooks": {
      "postPublish": [
        {
          "file": "sentry-expo/upload-sourcemaps",
          "config": {
            "organization": "<your organization name>",
            "project": "<your project name>",
            "authToken": "<your auth token here>"
          }
        }
      ]
    }
}

  1. organization you can find on here https://sentry.io/settings/ which named "Organization Name"
  2. project enter your project name, you can find here: https://sentry.io/organizations/ORGANIZATION_NAME/projects/
  3. authToken create a authToken with this url https://sentry.io/api/

Then run expo publish, it upload the source maps automatically.

Testing Locally

Make sure that you enabled expo development. add lines;

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

As a Result

On sentry, for only ios, you can able to see the source code where error occured.

BUT: unable to see the source code for ANDROID

https://github.com/getsentry/react-native-sentry/issues/372

Second way (manual upload)

Using the 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'


来源:https://stackoverflow.com/questions/51977239/how-to-manually-upload-my-source-code-to-sentry

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!