getsentry / sentry-react-native

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

ExpoKit, native errors #720

Closed dreamchasersuon closed 4 years ago

dreamchasersuon commented 4 years ago

OS: Ubuntu 18.04.3 LTS

Platform: Android

SDK: @sentry/react-native

react-native version: https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz

Init Code:

Sentry.init({
  dsn: 'https://...@sentry.io/...'
});

I have following issue:

Hi guys, I have a problem with ExpoKit and Sentry setup. Found out that not only me stuck with this kind of issue. Hope that someone can point me. The problem is Sentry don't handle Native Errors, while JS Errors handling works fine.

Steps to reproduce:

  1. Install minimal expo project: mkdir expokit-sentry && cd expokit-sentry && expo init;
  2. I choose minimal setup to got fast results: expo project with navigation;
  3. Ejecting to ExpoKit: expo eject;
  4. Install Sentry: yarn add @sentry/react-native or npm i --save @sentry/react-native;
  5. Link native dependencies: react-native link @sentry/react-native;
  6. Run packager: expo start;
  7. Make build: open Android Studio, then -> Sync Project, then -> Build APK;
  8. Install on device and try to run Fire native error and Fire JS error links.

I made a sample project here.

Actual result:

Expected result:

dnlsilva commented 4 years ago

Same here... Any solution?

dreamchasersuon commented 4 years ago

Same here... Any solution?

Unfortunately, not...

dnlsilva commented 4 years ago

Same here... Any solution?

Unfortunately, not...

I was able to make it work by combining with another library: react-native-exception-handler

My code:

import * as Sentry from '@sentry/react-native';
import {setNativeExceptionHandler} from 'react-native-exception-handler';

export default function sentryInit() {
  if (!__DEV__) {
    Sentry.init({
      dsn: '...',
    });

    setNativeExceptionHandler(exceptionString => {
      Sentry.captureException(exceptionString);
    });
  }
}
HazAT commented 4 years ago

I am closing this issue in order for that to work, Expo would need to embed our native SDKs in their package. Not sure if this is ever going to happen. If you want to that you need to eject your project or raise an issue in their tracker. Cheers

dnlsilva commented 4 years ago

ExpoKit projects is a ejected projects... Only diference is use expo version of react native, but native code is the same. react-native link etc...

HazAT commented 4 years ago

I am not sure what ExpoKit is doing under the hood but if @sentry/react-native is correctly linked in a simple react-native project, native tracking works just fine. So either it's not just an ejected project or linking did fail. Because if you just start with react-native init AwesomeProject then there is no issue.