Which Sentry package in bare workflow?

Hi, everyone,

My project originally started in the managed workflow but a few months ago I ejected. Since around that time, I’ve been having trouble with Sentry and the uploading of source maps.

In the sentry-expo docs, I understand the setup as follows:

  1. Install sentry-expo package (and set up the init, etc.).
  2. If on bare, do the above but also install the @sentry/react-native package and stick with the import initial call that you set up previously.

The @sentry/react-native package, however, doesn’t mention also needing to use sentry-expo. I’ve asked on Slack, too, and some people are saying to only use @sentry/react-native while others say I need to have both.

Just to be clear, how should I be setting things up? Right now, I’m getting the following at the top of all issues in Sentry:

There was 1 error encountered while processing this event
Source code was not found 
Url app:///bundle-xxxxxxxxxxxxx

For context, here’s my setup in App.tsx:

import { Native as Sentry } from 'sentry-expo'

Sentry.init({
  dsn: "xxx",
  enableAutoSessionTracking: true,
  debug: true,
})

// Sentry.captureException(error)

What am I missing here? Thanks in advance. Have a nice day!

You can either use sentry-expo (in bare, you will need to install @sentry/react-native as well), or you can just use @sentry/react-native by itself. sentry-expo does a few things automatically for you in an attempt to make your life easier, but you’re by no means restricted to only using that in the bare workflow

1 Like

Hi, @charliecruzan. Thanks for the reply. Right now, I have the setup you described first – sentry-expo with @sentry/react-native installed. You can see my setup in my original message. In this case, then, is there a reason why issues are showing up with the Source code not found message? From what I can see, I’m doing things as suggested. Are there any other things I should look at? Thanks for your time. Have a nice day and weekend ahead.

Source code not found indicates you either haven’t uploaded sourcemaps, or you have uploaded them but they aren’t under the proper release and dist

Thanks, Charlie. Yeah, I figured there’s something going on but there’s clearly something wrong with my setup. From what I can see, I’ve followed all the steps in the Expo documentation. I was going to open an issue in the GitHub repository with all the following information but I see that you seem to handle things there as well so I’ll continue here.

Right now, new releases are automatically created in Sentry for me and they follow the {version_number} ({build_number}) pattern, e.g. I just created version 0.0.35 with build number 76 and in Sentry I see a release called 0.0.35 (76).

Example:

For all builds since 46, releases have had no artifacts. If I look what happened in the code for build 47, I started using import * as Sentry from '@sentry/react-native' instead of import { Native as Sentry } from 'sentry-expo', which I’ve since learned was wrong. I’ve reverted now that but I still no longer get source maps uploaded. Is there a manual step outside of building an archive and uploading to App Store Connect?

I’ve seen people talk about explicitly setting dist and release in their Sentry config? Is this required? If so, I can’t find it in the documentation as mandatory.

Just to be clear, so we don’t keep going around in circles, this is my setup and workflow. Please let me know if it looks like I’m missing something.

Configuration

App.tsx

import { Native as Sentry } from 'sentry-expo'

Sentry.init(sentryConfig)

// Sentry.captureException(error)

sentry.ts

import { Platform } from 'react-native'
import { Native as Sentry } from 'sentry-expo'

const SENTRY_DSN_IOS = 'xxx'
const SENTRY_DSN_ANDROID = 'xxx'

export const sentryConfig: Sentry.ReactNativeOptions = {
  dsn: Platform.OS === 'ios' ? SENTRY_DSN_IOS : SENTRY_DSN_ANDROID,
  enableAutoSessionTracking: true,
  debug: __DEV__ ? true : false,
  environment: __DEV__ ? 'development' : 'production',
}

Workflow

  • Make changes in code, test locally
  • Bump version and/or build number
    • See a new release in Sentry with that version/build if testing
  • Create a new archive in Xcode
  • Upload to App Store Connect
    • Note that the release in Sentry that matches the version/build has no artifacts and issues reported show the “Source code was not found” message.

Should I be running some manual publish step here as well?

At the top of the Sentry issue:

Tags in the Sentryissue:

I see that dist and release have been added automatically.

Thanks for your time, @charliecruzan. I really appreciate it. I know there’s a lot here but I wanted to give as much context as possible to save any unnecessary back and forth. Thanks! Have a nice day.

For all builds since 46, releases have had no artifacts

sourcemaps during a build are uploaded by Sentry’s own scripts, which should have been configured for you automatically after running the yarn sentry-wizard -i reactNative -p ios android command. It should be visible in your build scripts: try searching your project for “Upload Debug Symbols to Sentry” (that’s the iOS build phase step)

Otherwise, sourcemaps should be automatically uploaded when you run expo publish if you have configured your postPublishHooks in app.json

Hi, Charlie. Yes, I have the following postPublish hook in app.json.

"hooks": {
  "postPublish": [
    {
      "file": "sentry-expo/upload-sourcemaps",
      "config": {
        "organization": "xxx",
        "project": "xxx",
        "authToken": "xxx"
      }
    }
  ]
}

So, based on my (bare) workflow that I mentioned above, is the issue that I’m not manually running expo publish each time I create a new release (via archiving in Xcode, then uploading to App Store Connect)?

I did actually try randomly running expo publish a few builds back (between build 73 and 74) and noticed a different release show up in Sentry:

If that’s the case, I wasn’t aware that I should also be running expo publish still, after ejecting. Hopefully this is the issue.

Update

After running expo publish, I see:

➜  client git:(main) expo publish

- Release channel: default
- Workflow: Bare

- URL mismatch: No standalone app has been built with SDK 40.0.0 and release channel "default" for this project before.
  OTA updates only work for native projects that have the same SDK version and release channel. Learn more.
- Workflow target: This is a bare workflow project. The resulting publish will only run properly inside of a native build of your project. If you want to publish a version of your app that will run in Expo client, please use expo publish --target managed. You can skip this warning by explicitly running expo publish --target bare in the future.

Created release 0.0.35-r.QSgOX9UVC.

> Found 4 release files
> Analyzing 4 sources
> Rewriting sources
> Adding source map references
> Bundled 4 files for upload
> Uploaded release files to Sentry
> File upload complete (processing pending on server)

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

Finalized release 0.0.35-r.QSgOX9UVC.

You don’t have to run expo publish, but that’s an OTA Update which most people find really useful (we have docs covering that).

Sourcemaps should still be uploaded during your native builds- if they’re not, that’s a problem with the @sentry/react-native set up

1 Like

Thanks, Charlie. I’ve created an issue in the sentry-react-native repository so hopefully somebody there can point out the problem(s) with my setup. Thanks again.

1 Like