sentry-react-native icon indicating copy to clipboard operation
sentry-react-native copied to clipboard

`SENTRY_DIST` env var not supported when using `sentry-expo-upload-sourcemaps` util

Open estrattonbailey opened this issue 10 months ago • 4 comments

What React Native libraries do you use?

React Native Web, React Navigation

Are you using sentry.io or on-premise?

sentry.io (SaS)

@sentry/react-native SDK Version

6.9.0

How does your development environment look like?

OS: macOS 14.4.1 Node: 20.18.3 Yarn: 1.22.21 Expo SDK: 52.0.19 react: 18.2.0 react-native: 0.76.6 hermesEnabled: true newArchEnabled: false

Sentry.init()

import {init} from '@sentry/react-native'

import {version} from '#/../package.json'

/**
 * Examples:
 * - `dev`
 * - `1.99.0`
 */
const release = process.env.SENTRY_RELEASE || version

/**
 * The latest deployed commit hash
 */
const dist = process.env.SENTRY_DIST || 'dev'

init({
  enabled: !__DEV__,
  autoSessionTracking: false,
  dsn: '...',
  debug: false,
  environment: process.env.NODE_ENV,
  dist,
  release,
  ignoreErrors: [...],
})

Steps to Reproduce

It seems that SENTRY_DIST env var is ignored by the sentry-expo-upload-sourcemaps script. Defining SENTRY_RELEASE works as expected, but the only way to inject a custom dist value that I've found is to use the --dist flag directly. See diff below for an example.

I also tested the existing pattern below by appending SENTRY_DIST: 'test' to the env: {...} property as well, and verified that it appears not to be used.

diff --git a/node_modules/@sentry/react-native/scripts/expo-upload-sourcemaps.js b/node_modules/@sentry/react-native/scripts/expo-upload-sourcemaps.js
index c282ade..8777755 100755
--- a/node_modules/@sentry/react-native/scripts/expo-upload-sourcemaps.js
+++ b/node_modules/@sentry/react-native/scripts/expo-upload-sourcemaps.js
@@ -215,7 +215,7 @@ for (const [assetGroupName, assets] of Object.entries(groupedAssets)) {
 
   const isHermes = assets.find(asset => asset.endsWith('.hbc'));
   const windowsCallback = process.platform === "win32" ? 'node ' : '';
-  execSync(`${windowsCallback}${sentryCliBin} sourcemaps upload ${isHermes ? '--debug-id-reference' : ''} ${assets.join(' ')}`, {
+  execSync(`${windowsCallback}${sentryCliBin} sourcemaps upload ${isHermes ? '--debug-id-reference' : ''} ${assets.join(' ')} --dist ${process.env.SENTRY_DIST}`, {
     env: {
       ...process.env,
       [SENTRY_PROJECT]: sentryProject,

Expected Result

I think since SENTRY_RELEASE and SENTRY_DIST are well documented elsewhere as (I think) the canonical way to customize these values, they should both probably work here too.

Alternatively, since this script reads from the Expo config file for some values, it could be nice to support defining the values in the app.config.js, which I believe sentry-expo used to support.

Actual Result

Included above: SENTRY_DIST is not used by this util script, so I need to pass it in manually using patch-package or similar solution.

estrattonbailey avatar Mar 07 '25 21:03 estrattonbailey

@estrattonbailey thanks for the detailed feedback and for already proposing a solution. Yeah, I think it makes a lot of sense to have support for dist!

sentry-cli docs

  -d, --dist <DISTRIBUTION>
          Optional distribution identifier for the sourcemaps.

markushi avatar Mar 10 '25 08:03 markushi

We should fix/add this directly in the Sentry CLI.

Related CLI Command: https://github.com/getsentry/sentry-cli/blob/5708458bbee53c0b0ce4726c95af50b848a55481/src/commands/sourcemaps/upload.rs#L49

krystofwoldrich avatar Mar 10 '25 10:03 krystofwoldrich

Has this been fixed? We're still having issues with SENTRY_DIST not applying in 7.2.0

federicogomezlara avatar Dec 10 '25 09:12 federicogomezlara

Thank you for bumping this issue. It is in our backlog back we do not have a specific ETA yet.

antonis avatar Dec 11 '25 13:12 antonis