getsentry / sentry-react-native

Official Sentry SDK for React Native
https://sentry.io
MIT License
1.59k stars 337 forks source link

[Android] ReferenceError not being captured by Sentry #4321

Open shanmukhdontuTWM opened 4 days ago

shanmukhdontuTWM commented 4 days ago

What React Native libraries do you use?

React Navigation, Hermes

Are you using sentry.io or on-premise?

sentry.io (SaS)

@sentry/react-native SDK Version

5.33.1

How does your development environment look like?

System:
  OS: macOS 14.7.1
  CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  Memory: 1.37 GB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.20.4
    path: ~/.nvm/versions/node/v18.20.4/bin/node
  Yarn:
    version: 1.22.19
    path: /usr/local/bin/yarn
  npm:
    version: 10.7.0
    path: ~/.nvm/versions/node/v18.20.4/bin/npm
  Watchman:
    version: 2024.01.22.00
    path: /usr/local/bin/watchman
Managers:
  CocoaPods: Not Found
SDKs:
  iOS SDK: Not Found
  Android SDK: Not Found
IDEs:
  Android Studio: 2022.3 AI-223.8836.35.2231.10811636
  Xcode:
    version: /undefined
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 11.0.21
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.5
    wanted: 0.72.5
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: false
  newArchEnabled: Not found

Sentry.init()

Sentry.init({
      dsn: String(getConfig().SENTRY_DSN),
      environment: String(getConfig().SENTRY_ENVIRONMENT || 'Development'),
      enableUserInteractionTracing: false,
      enableAppStartTracking: false,
      attachScreenshot: false,
      integrations: [
        reactNativeTracingIntegration({
          routingInstrumentation: routingInstrumentation,
        }),
      ],
      debug: false,
      release: deviceInfoModule.getVersion(),
      dist:
        deviceInfoModule.getBundleId() + '-' + deviceInfoModule.getVersion(),
      enabled: true,
    });

Steps to Reproduce

The app is getting initialized with sentry without any issue, and also the sentry crash test is working. In a component inside the App, it does not have a function imported and is called, which is throwing a ReferenceError locally but the same issue is not populated in sentry. When i converted the function to async, it did the trick. The app is within the sentry error boundary and we were expecting the crash to show up, even for synchronous functions but thats not the case. Can someone help look into this?

Expected Result

The event should be logged on sentry dashboard, sentry should capture one.

Actual Result

Sentry not able to capture ReferenceError crashes inside a React native component

lucas-zimerman commented 2 days ago

Hi and thank you for opening this issue!, Could you share the logs from Sentry when debug is set to true? Also, could you try checking if the problem persists on version 5.34.0?

Lastly, could you share a snippet on how you are calling this function? Thank you for your patience.