react native documentation
Hey there, I know sentry is growing in popularity as the leading solution for production error reporting and analysis, but the process for uploading source code and source maps is lacking.
For example here is how you upload a source file using the API directly:
curl https://sentry.io/api/0/projects/:organization_slug/:project_slug/releases/2da95dfb052f477380608d59d32b4ab9/files/ \
-X POST \
-H 'Authorization: Bearer {TOKEN}' \
-F [email protected] \
-F name="http://example.com/app.js.map"
The questions I have are:
1) what do the last 2 parameters look like when uploading your local main.jsbundle.map?
2) what about main.jsbundle? Just upload it in a separate request, and Sentry will know what to do with it? sentry-sourcemaps is only for sourcemaps it seems. Simply what are 2 recommended commands to upload the 2 bundles from React Native. No where is it covered how best to get your complete source code and maps into Sentry.
3) main.jsbundle might be a highly transformed piece of minified code, is the source map really going to translate everything back to your actual source? There are recommendations in the docs that the absolute best coverage can be achieved by uploading your full source? File by file? I see that this package supports accessing a private NPM package. That seems like a great option (though I'm confused why it's not a private github repo instead, since many times more people are doing that than also releasing their entire app as a private NPM repo). So will that match up properly with main.jsbundle.map? Do you still need main.jsbundle? Your left wondering whether all this will work. I complete start to front example for react native would make a lot of sense and be great for business for you guys, since it's easy to imagine the React Native community stamping Sentry as the go to solution for production error reporting.
4) what about getting the proper release name passed into your code? The git commit sha seems like the way to go. Basically the solution seems to be writing an npm run script that commits your code, gets the release #, writes a file that it stores it in which can be required by code, then build your react native bundle and map, and this of code course dynamically retrieves the release #:
let name = require('../sentry-config.js').releaseName;
Raven.config(MyDsn, { release: name }).install();
And for React Native possibly something like this would be used for exposing config values generated at build time: https://github.com/luggit/react-native-config ...Of course you still have to generate files with the latest releaseName at build time. It makes you wonder: if you're doing this just to get the commit sha, if there is some way sentry can automatically figure this out.
After it's all said and done, of course your build script needs to upload these artifacts.
5) the final point is most React Native developers are using Microsoft Code Push to push updates to live apps. That's what I determined at least. So basically the above automated build should coincide with your code-push deployments.
Overall--and especially after writing this--what must be done is seeming obvious, but I'd just like to draw attention to the opportunities here for everyone. If you look at what Microsoft Code Push did in terms of React Native (http://microsoft.github.io/code-push/docs/react-native.html), you will come to this conclusion: they jumped on the React Native bus early and doubled down on it. And they gained a lot as a result. Hence, it has become the leading--or at least one of the leading--live deployment solutions for React Native. The offering they have, as it exists on the above web page, has existed for almost a year now. Sentry has the same opportunity. I researched Sentry about 6 months ago and said to myself "by the fall when I'm about to launch my app, I'm sure they will have more React Native support." While React Native support is out of beta, it effectively isn't because it's far from obvious how to truly integrate it. You can't just paste Raven.config().install() in your code and simply be done with this kind of product. If it's not integrated into an automated build and deployment setup, it's essentially pointless. And how to do so is far from clear. At the very least a paragraph describing some of the options I've described above could be added to this page:
https://docs.sentry.io/clients/javascript/integrations/react-native/
My recommendation is to take it a step farther and also write a version of your source maps docs specifically for React Native:
https://docs.sentry.io/clients/javascript/sourcemaps/
And obviously to crush it, you would provide some automated integrations with the React Native bundling process, and specifically Microsoft Code Push. If Sentry wants to become the defacto error reporting solution for the exponentially growing React Native crowd, THIS IS HOW IT'S DONE!
Now that all said--cuz obviously we are all insanely busy and if you're still reading this--am I on the right track? Any nudges in the right direction would be more than appreciated. And of course thank you for your awesome product offering. I look forward to integrating it soon.