Skip to content

Support SENTRY_RELEASE and SENTRY_DIST env vars in build scripts for sentry.options.json #6069

@antonis

Description

@antonis

Problem

When using native auto-init (useNativeInit: true / RNSentrySDK.start()), the sentry.options.json file is copied into the app bundle at build time. The build scripts already support overriding the environment field via the SENTRY_ENVIRONMENT env var, but there is no equivalent support for SENTRY_RELEASE or SENTRY_DIST.

This means users who set a custom release in JS Sentry.init() (e.g. ios-1.0.0-42 instead of the default com.app@1.0.0+42) end up with two releases in Sentry — one from the native init (auto-detected or from the options file) and one from JS init. Pre-JS crashes are attributed to the native release, while post-JS events go to the JS release.

There is no build-time mechanism to align the release/dist values in sentry.options.json with what JS will use, short of manually generating the file.

Related: #6064

Proposed Solution

Add SENTRY_RELEASE and SENTRY_DIST env var injection to both build scripts, following the existing SENTRY_ENVIRONMENT pattern:

iOS — scripts/sentry-xcode.sh

After the existing SENTRY_ENVIRONMENT block (lines 108-119), add equivalent blocks for SENTRY_RELEASE and SENTRY_DIST.

Android — sentry.gradle

After the existing SENTRY_ENVIRONMENT block (lines 48-59 in copySentryJsonConfiguration), add equivalent blocks for SENTRY_RELEASE and SENTRY_DIST.

Impact

Users with custom release formats can set SENTRY_RELEASE and SENTRY_DIST in their build environment (Xcode, EAS, CI) to keep native and JS releases aligned without manually generating sentry.options.json.

Metadata

Metadata

Assignees

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions