Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabled option in Sentry init does not avoid sending native events to Sentry in Dev mode #4247

Open
roni-castro opened this issue Nov 7, 2024 · 1 comment

Comments

@roni-castro
Copy link

roni-castro commented Nov 7, 2024

What React Native libraries do you use?

Expo (mobile only)

Are you using sentry.io or on-premise?

sentry.io (SaS)

@sentry/react-native SDK Version

6.1.0

How does your development environment look like?

expo-env-info 1.2.0 environment info:
System:
OS: macOS 14.6.1
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.3.0 - ~/.nvm/versions/node/v22.3.0/bin/node
Yarn: 1.22.22 - ~/.nvm/versions/node/v22.3.0/bin/yarn
npm: 10.8.1 - ~/.nvm/versions/node/v22.3.0/bin/npm
Watchman: 2024.10.07.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.15.2 - /Users/ronicastro/.rvm/rubies/ruby-3.1.0/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 23.5, iOS 17.5, macOS 14.5, tvOS 17.5, visionOS 1.2, watchOS 10.5
IDEs:
Android Studio: 2024.1 AI-241.15989.150.2411.11948838
Xcode: 15.4/15F31d - /usr/bin/xcodebuild
npmPackages:
expo: ~51.0.38 => 51.0.38
expo-router: ~3.5.23 => 3.5.23
react: 18.2.0 => 18.2.0
react-dom: 18.2.0 => 18.2.0
react-native: 0.74.5 => 0.74.5
react-native-web: ~0.19.10 => 0.19.12
npmGlobalPackages:
eas-cli: 12.6.2
Expo Workflow: bare

Sentry.init()

import * as Sentry from "@sentry/react-native";

const IS_NATIVE_BUILD =
  Constants.executionEnvironment === ExecutionEnvironment.StoreClient; // Only in native builds, not in Expo Go.

const navigationIntegration = Sentry.reactNavigationIntegration({
  enableTimeToInitialDisplay: IS_NATIVE_BUILD,
});

Sentry.init({
  enabled: !__DEV__,
  dsn: "https://1b27b8c56af5b5a47387fe0ecc726353@o4508241637146624.ingest.us.sentry.io/4508241637343232",
  tracesSampleRate: 1.0,
  // uncomment the line below to enable Spotlight (https://spotlightjs.com)
  // enableSpotlight: __DEV__,
  _experiments: {
    replaysSessionSampleRate: 1.0,
    replaysOnErrorSampleRate: 1.0,
  },
  integrations: [
    navigationIntegration,
    Sentry.httpClientIntegration(),
    Sentry.mobileReplayIntegration(),
  ],
  enableNativeFramesTracking: IS_NATIVE_BUILD,
});

Steps to Reproduce

  1. Set the enabled of Sentry.init to the value false or to !__DEV__ and also define the dsn to be a valid one, and run the app in dev mode.
  2. Comment any line in the integrations section of Sentry.init, and then uncomment it again with RN fast refresh activated.
  3. A native crash happens and the log is sent to Sentry in dev mode even with enabled: false

The app code can be downloaded here, and make sure to run the branch sentry-bug change

simulating_native_crash_debug_mode.mp4

Expected Result

The flag enabled: false to not send any error events to Sentry, including JS or native logs.
Or update the docs mentioning this just works for JS events, not for native one.

At the moment, it appears that this is the only available solution for this problem of disabling sentry events in dev mode, though it's not very thoroughly documented.

Sentry.init({
  dsn: __DEV__
    ? ""
    : "https://1b27b8c56af5b5a47387fe0ecc726353@o4508241637146624.ingest.us.sentry.io/4508241637343232",
})

Actual Result

The native log is unexpectedly sent to Sentry, although any JS error is not.
Sentry log

@github-project-automation github-project-automation bot moved this to Needs Discussion in Mobile & Cross Platform SDK Nov 7, 2024
@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Nov 7, 2024
@roni-castro roni-castro changed the title Enabled option in Sentry init does not avoid sending events to Sentry in Dev mode Enabled option in Sentry init does not avoid sending native events to Sentry in Dev mode Nov 7, 2024
@krystofwoldrich krystofwoldrich self-assigned this Nov 8, 2024
@krystofwoldrich krystofwoldrich moved this from Needs Discussion to Needs Investigation in Mobile & Cross Platform SDK Nov 8, 2024
@krystofwoldrich
Copy link
Member

Thank you for the report and the details @roni-castro,

I'm confirming this is a bug and the native events should also not be send when enabled: false.

@krystofwoldrich krystofwoldrich moved this from Needs Investigation to Needs Discussion in Mobile & Cross Platform SDK Nov 21, 2024
@krystofwoldrich krystofwoldrich moved this from Needs Discussion to Backlog in Mobile & Cross Platform SDK Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Status: Backlog
Development

No branches or pull requests

2 participants