Sentry: How to build for android and ios but only one bundle to Sentry

Please provide the following:

  1. SDK Version: 37.0.0
  2. Platforms(Android/iOS/web/all): Android/iOS

To make an ios build for the store I run - expo build:ios.

Then to make an android build for the store I run - expo build:android -t app-bundle.

However each of these commands creates a new js bundle and uploads to Sentry so I get situations like screenshot below.

Is it possible to build for both ios/android but only use 1 js bundle?

Hi! yep you can definitely do this. The sentry upload step takes place after publishing, so you just need to only publish once. expo build:* runs expo publish under the hood, but you can avoid that by passing the --no-publish flag.

So if you want to publish once, you can either run:

- expo build:ios 
- expo build:android --no-publish

or

- expo publish
- expo build:ios --no-publish
- expo build:android --no-publish

Thanks Charlie for such a fast reply!

However if I do this, then the other build that got --no-publish will not find it’s Sentry map on Sentry when it reports. Is it possible to tell the 2nd build to use Sentry bundle id from previous?

You’ll have to provide more information :confused: otherwise I can’t say what’s going on

what does your sentry dashboard say? are the release and dist that the error is under the same as the release and dist of the uploaded sourcemap artifacts? are the sourcemap artifacts even present?

Oh thank you again so much for your speed.

So lets say I do this:

- expo build:ios 
- expo build:android --no-publish

In this case, the Sentry sourcecode was uploaded only on ios. Lets say with sentry id X.
In android case it wasn’t.

Now in runtime of the production bundle, if in the Android bundle an error occurs, will it log to Sentry that this happened in sentry id X? It wouldn’t know its bundle is for Sentry bundle id X right?

In this case, the Sentry sourcecode was uploaded only on ios

What makes you say this? In the terminal output, you should see something like:


Source Map Upload Report
  Minified Scripts
    ~/index.android.bundle (sourcemap at index.android.bundle.map)
    ~/main.jsbundle (sourcemap at main.jsbundle.map)
  Source Maps
    ~/index.android.bundle.map
    ~/main.jsbundle.map

which indicates bundles and maps being uploaded for both iOS and Android

Thanks. So I was just thinking ahead because right now, i have to sentry ids for two bundles which are exactly teh same. Ios reports to one id, and android reports to the other.

How does Sentry for my android build know, to mark any errors with the id for that android bundle that got uploaded with my ios build?

Sorry, but I’m not really following your question. What ID are you referring to?

Your sentry errors / sourcemaps are related to bundles, not to builds. The android build your making is pulling the most recently published bundle, which is the one you just published by building for ios without the --no-publish key.

If your Sentry set up is more complicated than normal, you may need to just opt for uploading sourcemaps yourself with sentry-cli

Thanks so much for sticking with me on this. Sorry my expalnations are real bad haha.

This is what I do today:

build ios (this uploads source code to Sentry and gets assigned id X by Sentry)
build android (this uploads same source code to Sentry but gets id Y by Sentry)

Now when errors happen on Android, sentry says this happend in “Y”.
And if error in iOS it says it happend in “X”.

So with your new technique im wondering:

ios build and publish sourcecode to Sentry and gets Sentry id Z
android build but no publish sourcemap to Sentry

Now if ios errors it will tell me it errored in Sentry ID Z. But now if Android errors, what Sentry ID will it say the error happened in?

it will say id Z because it’s using the sourcecode and sourcemaps from “ios build and publish sourcecode to Sentry and gets Sentry id Z”

Or at least the android equivalent of id Z

I encourage you to try this and test it :smile:

Thanks so so much for the incredible speed.

Ohh no way! I was asuming that even with --no-publish it will build the sourcemap again!

Gosh so true I should test this. Haha im scared to test got so many people on prod thanks Expo team!! Single man team here couldn’t do it without you!

sure thing :+1:

btw- you may want to create a separate environment for testing rather than testing on your production users :stuck_out_tongue:

1 Like

Gosh totally haha thanks man!

1 Like

Have a look at “release channels” if you haven’t before now.

Oo I haven’t thank you! Checking now!