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

Sentry sends JavascriptException for Android obfuscated release build #755

Closed
3 of 7 tasks
zyvpeople opened this issue Feb 6, 2020 · 2 comments
Closed
3 of 7 tasks

Comments

@zyvpeople
Copy link

OS:

  • Windows
  • MacOS
  • Linux

Platform:

  • iOS
  • Android

SDK:

  • @sentry/react-native
  • react-native-sentry

react-native version: 0.61.5

Init Code:

Sentry.init({
  dsn: 'https://[email protected]/...'
});

I have following issue:
When my obfuscated Android application in release mode is crashed because of JS error I have 2 errors in Sentry instead of 1: the first one is original JS error that caused app to crash and the second one is JavascriptException. This JavascriptException has the same time as original JS error and also it contains not human readable stack trace. I don't want to see this JavascriptException in my error list.

Steps to reproduce:

  • Prepare Android obfuscated release build (def enableProguardInReleaseBuilds = true);
  • Run it on device or emulator;
  • Make JS code to throw error (throw Error('Fake error from JS'));
  • Open app again to make Sentry upload errors;
  • Open https://sentry.io in browser
  • Go to Issues section

Actual result:

  • I see 2 errors with the same timestamp

errorsDuplication

Expected result:

  • I want to see only 1 error (without JavascriptException)

Solution:
I debugged that JavascriptException is thrown by ExceptionsManagerModule from com.facebook.react.modules.core package. Also I see that you try to filter this exception (https://github.com/getsentry/sentry-react-native/blob/master/android/src/main/java/io/sentry/RNSentryModule.java#L108). But this approach does not work when I obfuscate my code because JavascriptException class is obfuscated too.
I fixed this bug by adding a rule to proguard.txt file:
-keep public class com.facebook.react.common.JavascriptException
But it is not very convenient because I should do the same in every project where I want to use Sentry.
So I recommend you 2 solutions:

  1. You can add the same proguard rule to proguard file of the library;
  2. Instead of hardcoded string you can use the name of appropriate class (com.facebook.react.common.JavascriptException);
@HazAT
Copy link
Member

HazAT commented Feb 12, 2020

Please upgrade to 1.3.0 this should be fixed there.
If not please feel free to post again and we will take a look.

@HazAT HazAT closed this as completed Feb 12, 2020
@listenzz
Copy link

@HazAT This problem recurred in 1.3.1

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

No branches or pull requests

3 participants