Skip to content

Support runtime environment changes via scope (sync to native Scope.setEnvironment) #6991

Open

Description

@antonis

Context

sentry-java 8.63.0 added Scope.setEnvironment/getEnvironment (sentry-java#5772, proposal sentry-java#5769). It is applied to events, the DSC, logs, metrics and profiles. sentry-cocoa already has -[SentryScope setEnvironment:], and sentry-native has sentry_set_environment.

Problem

In RN, environment can only be set at init (options.environment). That value goes to native once, in RNSentryStart and on iOS. If an app changes environment at runtime, native-captured events (native crashes, ANRs, app-exit/NDK events, native logs and profiles) keep the init-time value.

Blocker

JS @sentry/core's Scope has no environment API, so there's nothing on the JS side to sync over the bridge.

Proposal

  1. Upstream: ask sentry-javascript for a scope-level setEnvironment (or find out whether they plan one).
  2. Once that exists: sync it to native through the scope-sync path on both platforms (Android Scope.setEnvironment, iOS SentryScope setEnvironment:), on both architectures. This adds a bridge spec method, so it needs a fallback for older native binaries.

Until then, this is parked.

Activity

  1. linear-code commented on Nov 5, 2026

    @linear-code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions