getsentry / sentry-react-native

Official Sentry SDK for React Native
https://sentry.io
MIT License
1.57k stars 337 forks source link

Upload sourcemaps for debug release #386

Closed sfratini closed 5 years ago

sfratini commented 6 years ago

OS:

Platform:

v8.4.0 4.6.1 nebula-core@0.1.0-dynamic-builddir-and-versions.1 C:\VSTS\Nebula-Core +-- assign-deep@0.4.6 +-- bcrypt@1.0.3 +-- clevertap-react-native@0.1.8 +-- d3-array@1.2.1 +-- d3-scale@1.0.6 +-- d3-shape@1.2.0 +-- fs@0.0.1-security +-- lottie-react-native@2.2.7 +-- path@0.12.7 +-- prop-types@15.6.0 +-- UNMET PEER DEPENDENCY react@16.0.0 +-- react-native@0.48.4 +-- react-native-action-button@2.8.3 +-- react-native-app-intro-slider@0.2.2 +-- react-native-audio-streamer@0.0.9 +-- react-native-collapsible@0.9.0 +-- react-native-config@0.8.1 +-- react-native-device-info@0.21.4 +-- react-native-firebase@3.2.0 +-- react-native-google-analytics-bridge@5.3.3 +-- react-native-image-crop-picker@0.20.0 +-- react-native-image-progress@1.1.0 +-- react-native-localization@0.1.32 +-- react-native-maps@0.17.0 +-- react-native-modal@4.1.1 +-- react-native-music-control@0.5.4 +-- react-native-navigation@1.1.210 +-- react-native-open-settings@1.0.1 +-- react-native-permissions@1.1.1 +-- react-native-progress@3.4.0 +-- react-native-sentry@0.30.0 +-- react-native-simple-encryption@1.2.1 +-- react-native-slider@0.11.0 +-- react-native-storage@0.2.2 +-- react-native-swiper@1.5.13 -- react-native-vector-icons@4.3.0

I was working on setting up version code, version names and releases all automatically. I was struggling but I succeded in adding a gradle script that takes an automatic git SemVer, adds that to the package.json and then updates the buld versionName. So far it works.

I couldn't understand at first why the sourcemaps were not being attached however I then realized I had to do this:

Sentry.setTagsContext({
    "environment": Config.ENVIRONMENT,  //Debug, Staging, Production
    "react-native": true,
    "uniqueID": DeviceInfo.getUniqueID()  ///Kinda like UUID
}); 
Sentry.setRelease(DeviceInfo.getBundleId() + '-' + helper.getAppVersion());
Sentry.setVersion(helper.getAppVersion()); //This returns the package.json version which I override as a versionName. This is working. 
Sentry.setDist(DeviceInfo.getBuildNumber().toString());

I am using DeviceInfo to get the buildID and buildNumber. This is actually working for assembleRelease. When I am testing the debug build, the crashes appear on the server however they do not get attached to the release because it was uploaded with the release bundle ID, which does not match my debug build as I am using suffixes.

I tried adding:

project.ext.sentry = [
    flavorAware: true
]

However it didn't do anything. Is there any setting I could use to upload the sourcemaps always and with the current bundleID?

Example: https://sentry.io/share/issue/c0d1d8c5121b49c18d6dfa987e34eb5d/

Thanks

sfratini commented 6 years ago

I just read the sentry.gradle. I think I need to force RN to bundle for debug too so it runs the bundleJsAssets task. I'll try and post back.

sfratini commented 6 years ago

Alright, focing RN to bundle the assets in debug did the trick and uploaded the sourcemaps to the debug release. Now, the issue is that I have 2 different releases for the same version, because Sentry is uploading the release_name as: bundleID + '-' + versionName

Is there a way to skip the bundleID or change that when you upload the sourcemaps from gradle? I can set a different setRelease name but they dont get matched unless I also send the bundleID correctly.

The issue is that I otherwise the Environment context tag is useless right now, since I end up having two releases (debug and production) separately anyway.

rawrmaan commented 6 years ago

I'm also seeing the issue with duplicate releases with the same name. I think it's because the dev version creates a "seen" release once a crash is sent, and the release version explicitly creates a release, and somehow they're both able to have the same name. This is frustrating because only one of them has source maps uploaded and issues can be assigned to the one that doesn't have source maps.

songxiaoliang commented 6 years ago

same problem! @rawrmaan @sfratini

HazAT commented 5 years ago

I am closing all old issues, please if this is still a problem feel free to revive it. Also, consider moving to our new SDK @sentry/react-native if it still happens there please open a new issue.