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

Using Code Push along with enableNative set to false does not send errors from sdk. #2998

Closed
5 of 11 tasks
shubhamdeol opened this issue Apr 23, 2023 · 6 comments
Closed
5 of 11 tasks

Comments

@shubhamdeol
Copy link

shubhamdeol commented Apr 23, 2023

OS:

  • Windows
  • MacOS
  • Linux

Platform:

  • iOS
  • Android

SDK:

  • @sentry/react-native (>= 1.0.0)
  • react-native-sentry (<= 0.43.2)

SDK version: 4.9.0

react-native version: 0.68.5

Are you using Expo?

  • Yes
  • No

Are you using sentry.io or on-premise?

  • sentry.io (SaaS)
  • on-premise

Configuration:

(@sentry/react-native)

Sentry.init({
  dsn: 'xyz',
  enableNative: false,
  // other options
});

I have following issue:

I want to initialise the sdk on native side as soon as the App starts. Sometimes crash occurs when javascript is not initialized. To fix this I am following this doc.

In MainActivity

protected void onCreate(Bundle savedInstanceState) {
    SentryAndroid.init(this, options -> {
      options.setDsn("xyz");
      options.setEnvironment("nativeAndroid");
    });
      super.onCreate(null);
  }

Steps to reproduce:

  • Step 1: I added System.out.println(2/0); after SentryAndroid.init and successfully received the trace on sentry dashboard.
  • Step 2: I removed the System.out.println(2/0); from MainActivity and put logs inside javascript side using methods
    Sentry.nativeCrash() and throw new Error("Test Error")

Actual result:

when followed step 2. I was not able to see error on dashboard.
using debug flag logs error on console
Sentry Logger [warn]: Event was skipped as native SDK is not enabled.

Expected result:

errors triggered by Sentry.nativeCrash() and throw new Error("Test Error")
should be successfully reported to sentry Dashboard.

Related issue: #2006
closed because person who reported this issue turned enableNative to true which I can not do. Because I want to get errors on sentry even before js initialization.

@krystofwoldrich
Copy link
Member

krystofwoldrich commented Apr 24, 2023

Thank you for the message,
I think in your case you should use autoInitializeNativeSdk: false in the options as you are initializing the native SDKs manually. Does that work for you?

enableNative: false is intended for cases when you don't want to/can't use native at all (browse for example).

@shubhamdeol
Copy link
Author

okay. I have a doubt If I use autoInitializeNativeSdk as false.
Suppose a crash occurs at native side triggered by some javascript method.
Which rules will apply to it.
Will it report all the breadcrumbs from javascript side or It will ignore javascript config completely.
For example we manually add our analytics and screen visit events to breadcrumbs. Will they still be reported if crash happens native android side ?

@krystofwoldrich
Copy link
Member

If autoInitializeNativeSdk: false the RN JS SDK will send breadcrumbs to the native layers, so if a native error occurs JS breadcrumbs will be present.

Is that your desired behavior?

@shubhamdeol
Copy link
Author

yes, Thanks
I will test it out and close the issue.

@shubhamdeol
Copy link
Author

closing the issue. Getting desired behavior with autoInitializeNativeSdk: false

@krystofwoldrich
Copy link
Member

Happy to help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

2 participants