Skip to content

iOS - 6.19.0 release bundle is missing env vars from react-native-dotenv #5085

@jamesholcomb

Description

@jamesholcomb

What React Native libraries do you use?

RN New Architecture, Hermes, React Navigation

Are you using sentry.io or on-premise?

sentry.io (SaS)

@sentry/react-native SDK Version

6.19.0

How does your development environment look like?

⬇  Place the `npx react-native@latest info` output here. ⬇

info Fetching system and libraries information...
System:
  OS: macOS 15.6
  CPU: (10) arm64 Apple M1 Max
  Memory: 130.27 MB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 22.17.0
    path: ~/.nvm/versions/node/v22.17.0/bin/node
  Yarn:
    version: 3.8.3
    path: ~/.nvm/versions/node/v22.17.0/bin/yarn
  npm:
    version: 10.9.2
    path: ~/.nvm/versions/node/v22.17.0/bin/npm
  Watchman:
    version: 2025.06.23.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.5
      - iOS 18.5
      - macOS 15.5
      - tvOS 18.5
      - visionOS 2.5
      - watchOS 11.5
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.3 AI-243.24978.46.2431.13208083
  Xcode:
    version: 16.4/16F6
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.11
    path: /usr/bin/javac
  Ruby:
    version: 2.7.7
    path: /Users/jamesholcomb/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 18.0.0
    wanted: 18.0.0
  react:
    installed: 19.0.0
    wanted: 19.0.0
  react-native:
    installed: 0.79.4
    wanted: 0.79.4
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true


Sentry.init()

  const opts: Sentry.ReactNativeOptions = {
    dsn: __DEV__ ? undefined : SENTRY_URL,
    // Sentry uses {bundleid}-{version} for release names
    // https://github.com/getsentry/react-native-sentry/issues/516
    release: `${DeviceInfo.getBundleId()}@${DeviceInfo.getVersion()}+${DeviceInfo.getBuildNumber()}`,
    dist: DeviceInfo.getBuildNumber(),
    environment: __DEV__ ? "development" : new URL(SERVER_URL).hostname,
    enableNative: true,
    enableNativeCrashHandling: true,
    integrations: __DEV__
      ? []
      : [
          Sentry.breadcrumbsIntegration({
            console: true
          })
        ],
    beforeBreadcrumb(breadcrumb) {
      if (breadcrumb.category === "console") {
        if (breadcrumb.level === "debug" && !consoleDebugBreadcrumbs) {
          return null
        }
        // sentry does a poor job of serializing console logs, do it here
        breadcrumb.message = JSON.stringify(breadcrumb.data.arguments)
      }

      return breadcrumb
    },
    maxBreadcrumbs: 50
  }

  Sentry.init(opts)

Steps to Reproduce

On iOS only, after upgrading from react-native-sentry 6.15.0 to 6.19.0, the main.jsbundle output is missing the transformation applied by the react-native-dotenv plugin. According to the log, it occurs after the xcode "Bundle React Native code and images" phase has completed (I use the recommended docs value for that).

I can confirm that react-native-dotenv is transforming the output correctly (and this worked fine in 6.15.0).

metro.config.js

// @ts-check
/* eslint-disable @typescript-eslint/no-require-imports */
const { getDefaultConfig, mergeConfig } = require("@react-native/metro-config")
const {
  wrapWithReanimatedMetroConfig
} = require("react-native-reanimated/metro-config")
const { withSentryConfig } = require("@sentry/react-native/metro")
const path = require("path")
const defaultConfig = getDefaultConfig(__dirname)
const { assetExts, sourceExts } = defaultConfig.resolver

/**
 * Metro configuration
 * https://facebook.github.io/metro/docs/configuration
 *
 * @type {import('@react-native/metro-config').MetroConfig}
 */
const config = {
  cacheVersion: process.env.APP_ENV,
  transformer: {
    babelTransformerPath: require.resolve("react-native-svg-transformer")
  },
  resolver: {
    extraNodeModules: {
      "~": path.resolve(__dirname, "src")
    },
    assetExts: assetExts.filter((ext) => ext !== "svg"),
    sourceExts: [...sourceExts, "svg"]
  }
}

const baseConfig = mergeConfig(defaultConfig, config)

module.exports = withSentryConfig(wrapWithReanimatedMetroConfig(baseConfig))

Expected Result

The output bundle contains the transformed output from react-native-dotenv plugin.

Actual Result

The output bundle is missing the dotenv env vars from the plugin.

Metadata

Metadata

Assignees

Projects

Status

Waiting for: Community

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions