nativescript-community / sentry

A cross-platform application monitoring tool, with a focus on error reporting.
Apache License 2.0
13 stars 6 forks source link

Can't set other options in init #22

Open jerbob92 opened 2 weeks ago

jerbob92 commented 2 weeks ago

When setting other options in the init, the code fails with:

  JS: CONSOLE ERROR: Error starting Sentry Error: Cannot convert boolean to Ljava/lang/Boolean; at index 0 Error: Cannot convert boolean to Ljava/lang/Boolean; at index 0
  JS:     at file: src/webpack:/MobileApp/node_modules/@nativescript-community/sentry/wrapper.android.js:346:55

For example in the following code:

Sentry.init({
    dsn: "dsnhere",
    enableAutoPerformanceTracking: true,
    enableTracing: true,
    tracesSampleRate: 1,
});

The error relates to the following line: https://github.com/nativescript-community/sentry/blob/master/src/sentry/wrapper.android.ts#L385

Perhaps a case for booleans need to be added as well?

Edit: looks like it's specifically enableTracing.

farfromrefug commented 2 weeks ago

@jerbob92 just released a new version which should fix it

jerbob92 commented 2 weeks ago

@farfromrefug awesome, thanks! Will try it out!

jerbob92 commented 2 weeks ago

@farfromrefug that did not fully fix it it seems:

  JS: CONSOLE ERROR: Error starting Sentry Error: JNI Exception occurred (SIGABRT).
  JS: =======
  JS: Check the 'adb logcat' for additional information about the error.
  JS: =======
  JS:  Error: JNI Exception occurred (SIGABRT).
  JS: =======
  JS: Check the 'adb logcat' for additional information about the error.
  JS: =======
  JS:
  JS:     at file: src/webpack:/MobileApp/node_modules/@nativescript-community/sentry/wrapper.android.js:346:55
  JS:     at Array.forEach (<anonymous>)
  JS:     at io.sentry.Sentry.OptionsConfiguration.configure (file: src/webpack:/MobileApp/node_modules/@nativescript-community/sentry/wrapper.android.js:338:50)
  JS:     at Object.<anonymous> (file: src/webpack:/MobileApp/node_modules/@nativescript-community/sentry/wrapper.android.js:328:49)

logcat says:

.......
  at com.tns.gen.io.sentry.Sentry_OptionsConfiguration.configure(Sentry_OptionsConfiguration.java:19)
  at io.sentry.android.core.SentryAndroid.lambda$init$1(SentryAndroid.java:123)
  at io.sentry.android.core.SentryAndroid$$ExternalSyntheticLambda0.configure(unavailable:8)
  at io.sentry.Sentry.applyOptionsConfiguration(Sentry.java:194)
  at io.sentry.Sentry.init(Sentry.java:164)
  at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:87)
  - locked <0x0135e1b3> (a java.lang.Class<io.sentry.android.core.SentryAndroid>)
  at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:70)
.....

JNI DETECTED ERROR IN APPLICATION: unexpected jboolean value: 7
   in call to CallVoidMethodA
   from java.lang.Object com.tns.Runtime.callJSMethodNative(int, int, java.lang.String, int, boolean, java.lang.Object[])
jerbob92 commented 2 weeks ago

@farfromrefug it looks like change this broke more than it fixed. Before, most boolean options would work, but now most of them don't, and since there are some options in there by default, I can't init the client at all anymore.

It looks like the only options that did not work before your change are the ones marked as @Nullable Boolean (like enableTracing), and not as boolean (like attachStacktrace). https://github.com/getsentry/sentry-java/blob/main/sentry/src/main/java/io/sentry/SentryOptions.java

farfromrefug commented 2 weeks ago

@jerbob92 ok i see! they use both :s and i have no way to "discover" it. Ok will add a special check EDIT: now i actually see more that would fail with numbers :s

farfromrefug commented 2 weeks ago

@jerbob92 published another version. Can you try?

jerbob92 commented 2 weeks ago

@farfromrefug yes, works! Only one that's failing now is tracePropagationTargets, it's an array of strings.

farfromrefug commented 2 weeks ago

@jerbob92 Ok might add support for this in the future