Giter VIP home page Giter VIP logo

sentry-android's Introduction

[Deprecated] Sentry-Android - Sentry Client for Android

⚠️ Please use official raven-java library - https://github.com/getsentry/sentry-java

It does what every Sentry client needs to do

Below is an example of how to register Sentry-Android to handle uncaught exceptions

<!-- REQUIRED to send captures to Sentry -->
<uses-permission android:name="android.permission.INTERNET" />

<!-- OPTIONAL but makes Sentry-Android smarter -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
import com.joshdholtz.sentry.Sentry;

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Sentry will look for uncaught exceptions from previous runs and send them
        Sentry.init(this, "YOUR-SENTRY-DSN");
    }
}

Features

Sentry-Android has two features that make it easy to use.

First, Sentry-Android will, by default, install an uncaught exception handler that will catch and report any uncaught exceptions (crashes) in your app. You only need to add a single line of code to set up Sentry-Android.

Second, since Sentry-Android is written specifically for Android, we can automatically associate device and OS information to error-reports. The table below shows an example of what the data will look like in Sentry.

DEVICE
Familygoogle
Modelbullhead (Nexus 5X)
Architectureaarch64
Orientationportrait
screen_resolution1794x1080
OPERATING SYSTEM
NameAndroid
Version7.0 (24)
Kernel Version3.10.73-g76d746e
PACKAGE
namecom.example.package
version_code210
version_name2.1

Crash Report Behavior

Sentry-Android will attempt to send all crash reports when the app starts back up. If something fails to upload, Sentry-Android will attempt to send again on next start. If you would like to manually attempt to send crash reports, please use the following call in your app 😊 Sentry.sendAllCachedCapturedEvents()

Updates

Version Changes
1.6.2 Now able to set the environment of the app #123
1.6.1 Fix bug in release version setting - the built-in package version was overriding the user-specified one. #120
1.6.0 Increase breadcrumb limit to 100 to match other Sentry clients, allow runtime configuration. #117.
Removed org.apache HTTP library 116.
1.5.4 Ensure that breadcrumbs are added to all exceptions. #115.
1.5.3 Fix thread-safety bug when serializing breadcrumbs. #110 (thanks to fab1an).
1.5.2 Send stack-frames to Sentry in the correct order. #95.
Use the versionName, rather than versionCode, as the default value for the release field of events (thanks to FelixBondarenko).
1.5.1 Revert accidental API removal of captureException(Throwable, SentryEventLevel).
1.5.0 Add Breadcrumb support #70.
Add release tracking by default #78.
Add the ability to attach a stack-trace to any event #81.
Use a fixed-size thread-pool for sending events #80.
Make it easier to add a message when capturing an exception #77.
Added helper methods for addExtra and addTag #74.
(thanks to marcomorain)
1.4.4 Sends up device, app, and OS context by default (thanks to marcomorain)
1.4.3 Fixes for a Google Play warning and added option to not use crash reporting (thanks to ZeroStride)
1.4.1 Fixes for a potential memory leak and a crash (thanks to Syhids and woostrowski)
1.4.0 Fixes issues when using self-hosted Sentry server
1.2.1 Sends up data to Sentry as UTF-8
1.2.0 Added support for Android version 23 and made library avaiable to install via gradle
1.1.4 Added support for verify_ssl on DSN (thanks Kras4ooo)
1.1.3 Exceptions appear super mega awesome in Sentry now (thanks doapp-jeremiah)
1.1.2 Bug fixed - Setting a captureListener was required to send a report (thanks mathzol)
1.1.1 Uncaught exception handler now calls SentryEventCaptureListener
1.1.0 Saves requests that were captured offline or failed and tries to resend them when it can
1.0.0 Removed dependency to Protocol; allows capture of message from background thread
0.1.0 Initial release

How To Get Started

Gradle

Available in jCenter

compile 'com.joshdholtz.sentry:sentry-android:1.6.0'

Manual

JAR can be downloaded here

This Is How We Do It

Permissions in manifest

The AndroidManifest.xml requires the permission android.permission.INTERNET and would like the permission android.permission.ACCESS_NETWORK_STATE even though optional.

<!-- REQUIRED to send captures to Sentry -->
<uses-permission android:name="android.permission.INTERNET" />

<!-- OPTIONAL but makes Sentry-Android smarter -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Capture a message

Sentry.captureMessage("Something significant may have happened");

Capture a caught exception

try {
	JSONObject obj = new JSONObject();
} catch (JSONException e) {
	Sentry.captureException(e);
}

Capture custom event

Sentry.captureEvent(new Sentry.SentryEventBuilder()
	.setMessage("Being awesome")
	.setCulprit("Josh Holtz")
	.setTimestamp(System.currentTimeMillis())
);

Capture Breadcrumbs

You can record breadcrumbs to track what happened in your application leading up to an error.

There are 3 ways to log a breadcrumb.

// Record that a user sent a HTTP POST to example.com and it was successful.
Sentry.addHttpBreadcrumb("http://example.com", "POST", 200);

// Record the fact that user clicked a button to go from the main menu to the
// settings menu.
Sentry.addNavigationBreadcrumb("user.click", "main menu", "settings");

// Record a general,  application specific event
Sentry.addBreadcrumb("user.state_change", "logged in");

Release Tracking

The SDK will automatically tag events with a release. The release is set to the app's versionName by default. You can override the release easily by using the setRelease(String release) function from inside a SentryEventCaptureListener.

Set a listener to intercept the SentryEventBuilder before each capture

// CALL THIS BEFORE CALLING Sentry.init
// Sets a listener to intercept the SentryEventBuilder before
// each capture to set values that could change state
Sentry.setCaptureListener(new SentryEventCaptureListener() {

    @Override
    public SentryEventBuilder beforeCapture(SentryEventBuilder builder) {

        // Needs permission - <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
        ConnectivityManager connManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
        NetworkInfo mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);

        // Sets extra key if wifi is connected
        return builder
            .addExtra("wifi", String.valueOf(mWifi.isConnected()))
            .addTag("tag_1", "value_1");
    }
});

Contact

Email: [email protected]
Twitter: @joshdholtz

License

Sentry-Android is available under the MIT license.

sentry-android's People

Contributors

caseyh avatar ddello32 avatar felixbondarenko avatar friederbluemle avatar grabbou avatar laurenceputra avatar m1 avatar marcomorain avatar markspolakovs avatar mathzol avatar ruudk avatar syhids avatar woostrowski avatar zerostride avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sentry-android's Issues

Exception when capturing exception on background thread

When a exception is being caught on thread other than main (i.e. AsyncTask), sentry throws its own exception:

    java.lang.RuntimeException: An error occured while executing doInBackground()
    at android.os.AsyncTask$3.done(AsyncTask.java:299)
    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
    at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
    at java.util.concurrent.FutureTask.run(FutureTask.java:239)
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
    at java.lang.Thread.run(Thread.java:856)
    Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
    at android.os.Handler.<init>(Handler.java:197)
    at android.os.Handler.<init>(Handler.java:111)
    at com.joshdholtz.protocol.lib.ProtocolClient$ProtocolTask.<init>(ProtocolClient.java:503)
    at com.joshdholtz.protocol.lib.ProtocolClient.doPost(ProtocolClient.java:281)
    at com.joshdholtz.sentry.Sentry.captureEvent(Sentry.java:182)
    at com.joshdholtz.sentry.Sentry.captureException(Sentry.java:142)
    at com.joshdholtz.sentry.Sentry.captureException(Sentry.java:136)
    at com.foo.core.activities.SplashActivity$InitTask.doInBackground(SplashActivity.java:52)
    at com.foo.core.activities.SplashActivity$InitTask.doInBackground(SplashActivity.java:42)
    at android.os.AsyncTask$2.call(AsyncTask.java:287)
    at java.util.concurrent.FutureTask.run(FutureTask.java:234)

It seems to be an issue with your Protocol library (handler not initiated with Looper.getMainLooper()).

Can't capture messages

Hi, I'm trying to use this library with my own sentry instance. when i try to capture message, it shows me errors and no any message won't be sent to server.

Sentry.init(this, "http://3f716bd225404bfd93e9970a39921d91:[email protected]/2");

Sentry.captureMessage("Hello sentry");

08-01 16:25:19.348 20202-20202/com.example.test D/Sentry: Sending up 0 cached response(s)
08-01 16:25:19.354 20202-20202/com.example.test D/Sentry: Request - {"platform":"java","timestamp":"2016-08-01T11:55:19","message":"Hello sentry","event_id":"a73c072c8d9e4f5f9b295c07476606bf","level":"info"}
08-01 16:25:19.358 20202-20656/com.example.test D/Sentry: Sending to URL - http://37.48.xx.xxx/api/2/store/
08-01 16:25:19.358 20202-20656/com.example.test D/Sentry: Using http client
08-01 16:25:19.359 20202-20656/com.example.test W/System.err:     at com.joshdholtz.sentry.Sentry.createXSentryAuthHeader(Sentry.java:176)
08-01 16:25:19.359 20202-20656/com.example.test W/System.err:     at com.joshdholtz.sentry.Sentry.access$800(Sentry.java:84)
08-01 16:25:19.359 20202-20656/com.example.test W/System.err:     at com.joshdholtz.sentry.Sentry$4.doInBackground(Sentry.java:440)
08-01 16:25:19.359 20202-20656/com.example.test W/System.err:     at com.joshdholtz.sentry.Sentry$4.doInBackground(Sentry.java:409)
08-01 16:25:19.359 20202-20656/com.example.test D/Sentry: Adding request - c324bc06-9cae-4820-95be-5cc188806767

Too large request

There seems to be a limit to how big the requests can be
Is there a way to limit the data ?

D/Sentry  (10193): SendEvent - 413 <html>
D/Sentry  (10193): <head><title>413 Request Entity Too Large</title></head>
D/Sentry  (10193): <body bgcolor="white">
D/Sentry  (10193): <center><h1>413 Request Entity Too Large</h1></center>
D/Sentry  (10193): <hr><center>nginx</center>
D/Sentry  (10193): </body>
D/Sentry  (10193): </html>

Android VersionName or VersionCode?

Android apps have a versionName string as in "1.2.3", which should be included in an event json sent to sentry.

At the moment, in

Sentry.captureEvent(SentryEventBuilder builder)

only

builder.setRelease(Integer.toString(sentry.appInfo.versionCode));

is called, but probably something like

builder.setRelease(sentry.appInfo.versionName);

were more helpful.

The sentry webinterface shows the property 'release' as filterable property, while in an event's details, versionName is also shown. Filtering by versionName would be more helpful, imho.

Thanks for your work!!!

Always get a Invalid project_id response

I've integrated the library in my app, but whenever it tries to send an error report it fails and logs the following line:

08-16 16:16:17.749: DEBUG/Sentry(14262): SendEvent - 400 Invalid project_id: u'4'

I've copied and pasted the sentry dsn from my sentry settings so I know it's valid.

I'm using sentry 6.0.4.

no Message, no Stacktrace logged

I just started playing with this library (with a selfhosted Sentry). To test it I simply created a NullPointer exception. An event is logged to Sentry correctly, but it is missing crucial information:

sentry

As you can see, all I get is the class name and line number where the original error occurred. But neither the exception's message nor the stacktrace is available. Is this simply not supported or did I do something wrong? (I didn't add anything beyond the Sentry.init() call).

ConcurrentModificationException in Sentry.init()

java.lang.RuntimeException: Unable to create application com.android.tools.fd.runtime.BootstrapApplication: java.util.ConcurrentModificationException
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4643)
at android.app.ActivityThread.access$1300(ActivityThread.java:165)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1433)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5370)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.util.ConcurrentModificationException
at java.util.ArrayList$ArrayListIterator.next(ArrayList.java:569)
at com.joshdholtz.sentry.Sentry.sendAllCachedCapturedEvents(Sentry.java:192)
at com.joshdholtz.sentry.Sentry.setupUncaughtExceptionHandler(Sentry.java:158)
at com.joshdholtz.sentry.Sentry.init(Sentry.java:121)

[Feature Request] Support for Stacktrace

Hi,
thanks for this awesome library! It works very well and is really easy to set up.
It would be great to add support for capturing stacktraces without capturing an exception.
I believe the stacktrace is always important to gain some knowledge about the context of an issue, but attaching an artificial to an event is a possible workaround, but not the best option since every event is then shown with title "Throwable" and the actual message is only displayed in the subtitle in Sentry.
I've seen an example of the stacktrace object here: https://gist.github.com/umurkontaci/9270201

Of course, I could just extend the SentryEventBuilder, but since the event is private, this does not seem like a viable option just for adding an additional field. Making the event protected should allow to extend the SentryEventBuilder quite easily, so this would already be helpful I guess.

Kind regards
Johannes

Application in the manifest and minSdkVersion 15 makes it difficult to import the lib.

By setting the minSdkVersion to 15 in the build.gradle file with no need, you limit the backwards compatibility of the lib. If you remove the unused appCompat dependency you can drop the minSdkVersion to 3.

Also the application tag in the lib's manifest file makes manifest merger harder. There's no need to declare an application tag, it tries to declare the allowBackup and label fields for the importing application this way.

Automatically set events' release field to package release

As of 1.4.4, this should be pretty trivial:

Sentry.setCaptureListener(new Sentry.SentryEventCaptureListener() {
  @Override
  public Sentry.SentryEventBuilder beforeCapture(Sentry.SentryEventBuilder builder) {
    try {
      builder.setRelease(
        Integer.toString(
          context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode
        )
      );
    } catch (PackageManager.NameNotFoundException e) {
      Log.e("Couldn't find package version: " + e);
    }

    return builder;
  }
});

Disable on Debug

Is there a way to prevent Sentry-Android from anything when BuildConfig.DEBUG == true?

Google Developer Warning

Hello,
I just received an email from google which reads as follows:

Hello Google Play Developer,

We detected that your app(s) listed at the end of this email are potentially leaking credentials used to make network requests (HTTP and FTP).

Please check for cases where you use url-encoded basic access authentication, for example a URL such as https://username:[email protected]/. We recommend that you immediately change the credentials and redesign your app to avoid including them.

Next steps

Sign in to your Developer Console and submit the updated version of your app.
Check back after five hours - we’ll show a warning message if the app hasn’t been updated correctly.

Exposed developer credentials can allow an attacker to compromise your systems which puts user data at risk. For other technical questions about the vulnerability, you can post to Stack Overflow and use the tag “android-security.”

We’re here to help

If you feel we have sent this warning in error, you can contact our developer support team.

Regards,

The Google Play Team

This email is for adding sentry in my project. I think that's the type of connection dsn.

Any idea or solution?
Thank you very much

Cache exceptions if the device is offline

If the device is offline when an exception occurs, the current code will immediately try to push that exception to Sentry. Obviously, that will fail because the device is offline so Sentry is unreachable.

It would be very helpful if the client can cache exceptions and stacktraces locally if submitting the event to Sentry fails (either because the device is offline or another problem occurs -- the request times out for example). Then it can submit the cache when the device is back online.

Exception init Sentry

init my sentry client:

 public void onCreate() {
     super.onCreate();
     Sentry.init(this, SentryLogger.BASE_URL,
     SentryLogger.DSN);
  }
Debugged  D  current handler class=com.android.internal.os.RuntimeInit$UncaughtHandler
                Sentry  D  Send all Cached Capture events!
            System.err  W  java.io.FileNotFoundException: /data/data/co.com.aranda.afls.onsite/files/unsent_requests: open failed: ENOENT (No such fil
                           e or directory)
                        W      at libcore.io.IoBridge.open(IoBridge.java:456)
                        W      at java.io.FileInputStream.<init>(FileInputStream.java:76)
                        W      at android.app.ContextImpl.openFileInput(ContextImpl.java:955)
                        W      at android.content.ContextWrapper.openFileInput(ContextWrapper.java:175)
                        W      at com.joshdholtz.sentry.Sentry$InternalStorage.readObject(Sentry.java:438)
                        W      at com.joshdholtz.sentry.Sentry$InternalStorage.<init>(Sentry.java:394)
                        W      at com.joshdholtz.sentry.Sentry$InternalStorage.<init>(Sentry.java:380)
                        W      at com.joshdholtz.sentry.Sentry$InternalStorage$LazyHolder.<clinit>(Sentry.java:390)
                        W      at com.joshdholtz.sentry.Sentry$InternalStorage.getInstance(Sentry.java:386)
                        W      at com.joshdholtz.sentry.Sentry$InternalStorage.access$200(Sentry.java:380)
                        W      at com.joshdholtz.sentry.Sentry.sendAllCachedCapturedEvents(Sentry.java:141)
                        W      at com.joshdholtz.sentry.Sentry.setupUncaughtExceptionHandler(Sentry.java:109)
                        W      at com.joshdholtz.sentry.Sentry.init(Sentry.java:92)
                        W      at co.com.aranda.afls.onsite.common.context.FieldServiceApp.onCreate(FieldServiceApp.java:95)
                        W      at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1011)
                        W      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4518)
                        W      at android.app.ActivityThread.access$1500(ActivityThread.java:144)
                        W      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1339)
                        W      at android.os.Handler.dispatchMessage(Handler.java:102)
                        W      at android.os.Looper.loop(Looper.java:135)
                        W      at android.app.ActivityThread.main(ActivityThread.java:5221)
                        W      at java.lang.reflect.Method.invoke(Native Method)
                        W      at java.lang.reflect.Method.invoke(Method.java:372)
                        W      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
                        W      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
                        W  Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
                        W      at libcore.io.Posix.open(Native Method)
                        W      at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
                        W      at libcore.io.IoBridge.open(IoBridge.java:442)
                        W      ... 24 more
                Sentry  D  Sending up 0 cached response(s)

anyone has a similar problem?

Unicode Decode errors

Some events aren't getting sent from my android app, possibly because there are strings in Icelandic in the app?

SendEvent - 403 Bad data reconstructing object (UnicodeDecodeError, 'utf8' codec can't decode byte 0xf3 in position 5: invalid continuation

The Ruby client seems to have had similar problems. I will look into this, just wanted to let you know :)
Btw fantastic work on the client.

Discarded invalid parameter 'contexts'

We are using the 1.5.0 version of sentry-android with a 8.1.2 local sentry instance. I got this error while logging a debug level log. Do you have any idea on what went wrong here?

Discarded invalid parameter 'contexts'
{
"name": "contexts"
}

how to add tag in unhandler exception.

I have found the tag in capture Exception. But I cannot find this feature in unhandler exception sending. Can I add tags when app crash(unhandler Exception) use your library?

Publish the library in a Gradle repository

Working with JAR files is too hard when managing lots of apps at the same time. Is there any plans to add the library to some central Maven repository, such as jCenter or MVN Repository?

Tks!

Capture Forced Close

Hi,

Is it possible to capture all Forced Close that occurs in the application?

Thanks for a great plugin.

Improvements from PR 56

In PR #56 there a lot of great changes that we should make to the client.

  • Allow more than one Sentry instance to exist.
  • Use an executor service for sending events to limit resources used .
  • The Apache HTTP client is deprecated. Allow apps to use alternate HTTP clients.
  • Use JSON for internal storage

Add some Android device details by default to Events

Hi @joshdholtz,

I'm using code like this to build up a default set of device data to send along with crashes.

private static Map<String, String> readDeviceData(Context context) {
  final Map<String, String> deviceData = new HashMap<>();
  try {
    deviceData.put("Device", Build.DEVICE);
    deviceData.put("Brand", Build.BRAND);
    deviceData.put("Model", Build.MODEL);
    deviceData.put("Android Version", Build.VERSION.RELEASE);
    //deviceData.put("Android SDK", Build.VERSION.SDK); // Android 3
    deviceData.put("Android SDK", Integer.toString(Build.VERSION.SDK_INT)); // Android 4+
    deviceData.put("Manufacturer", Build.MANUFACTURER); // Android 4+

    // Read package information
    final String packageName = context.getPackageName();
    final PackageInfo packageInfo = context.getPackageManager().getPackageInfo(packageName, 0);
    deviceData.put("Package Name", packageName);
    deviceData.put("Package Version Name", packageInfo.versionName);
    deviceData.put("Package Version Code", Integer.toString(packageInfo.versionCode));

    // Read screen resolution in the format "800x600"
    // Normalised to have wider side first.
    final Object windowManager = context.getSystemService(Context.WINDOW_SERVICE);
    if (windowManager != null && windowManager instanceof WindowManager) {
        final DisplayMetrics metrics = new DisplayMetrics();
        ((WindowManager)windowManager).getDefaultDisplay().getMetrics(metrics);
        deviceData.put("ScreenResolution",
                        String.format("%sx%s",
                                Math.max(metrics.widthPixels, metrics.heightPixels),
                                Math.min(metrics.widthPixels, metrics.heightPixels)));
            }

    } catch (Exception e) {
      Log.d("Sentry", "Error reading device data", e);
    }
    return deviceData;
}

I use a SentryEventCaptureListener to add this Map to the SentryEventBuilder before capture.

I thought you might be able to add something like this to all events by default, or to create a function like

class Sentry {
   ... // snip

  public static SentryEventCaptureListener CreateDeviceDataCaptureListener() {
    final Map<String, String> deviceData = readDeviceData(context);
    return new Sentry.SentryEventCaptureListener() {
            @Override
            public Sentry.SentryEventBuilder beforeCapture(Sentry.SentryEventBuilder builder) {
                return builder.setExtra(deviceData);
            }
        }
  }
}

Data in Sentry:

sentry

Send full stack trace

I added your library to my project and now I receive errors, but there is not enough information. How can I configure library for sending full stack trace?

Proguard handling

Does somebody manage to see de-obfuscated stacktrace on Sentry when the Android app source is obfuscated with Proguard ?

ConcurrentModificationException in Sentry.currentBreadcrumbs

I'm getting this error now and then:

java.util.ConcurrentModificationException: null
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at java.lang.reflect.Method.invoke(Method.java)
    at android.app.ActivityThread.main(ActivityThread.java:5593)
    at android.os.Looper.loop(Looper.java:135)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Handler.handleCallback(Handler.java:739)
    at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(ExecutorCallAdapterFactory.java:68)
    at mypackage.RequestAdapter$enqueue$1.onResponse(NetworkManager.kt:166)
    at mypackage.SentryLog.captureFailedRetrofitResponse(SentryLog.kt:99)
    at com.joshdholtz.sentry.Sentry.captureEvent(Sentry.java:310)
    at com.joshdholtz.sentry.Sentry.currentBreadcrumbs(Sentry.java:735)
    at java.util.LinkedList$LinkIterator.next(LinkedList.java:124)

captureFailedRetrofitResponse looks just like this:

Sentry.captureEvent(SentryEventBuilder()
    .setMessage(message)
    .setExtra(mapOf(
         "errorBody" to "string"
    )))

Add addTag / addExtra to the builder API

Pretty much anything that is needed to keep a fluent API is already done but if I need to add a tag or a meta, it breaks.

The builder should expose 2 methods such as:

addTag(String key, String value)
addMeta(String key, String value)

Catch exception from SyncAdapter

I'm trying to catch exceptions from Android SyncAdapter but I get an error because Context is not present. Can you please try to look into this issue.

Stack trace

File "android.content.AbstractThreadedSyncAdapter$SyncThread", line 259, in run
File "haygot.togyah.app.backgroundsync.SyncAdapter", line 123, in onPerformSync
File "com.joshdholtz.sentry.Sentry", line 129, in captureException
File "com.joshdholtz.sentry.Sentry", line 135, in captureException
File "com.joshdholtz.sentry.Sentry", line 174, in captureEvent
File "com.joshdholtz.protocol.lib.ProtocolClient", line 281, in doPost
File "com.joshdholtz.protocol.lib.ProtocolClient$ProtocolTask", line 503, in
File "android.os.Handler", line 114, in
File "android.os.Handler", line 200, in
File "Caused by: java.lang.RuntimeException ("Can't create handler inside thread that has not called Looper.prepare()")", line -1

Support for API 23

org.apache.http.client.HttpClient and other are classes are depreciated with API 23. How should this be handled? Currently I am using OKHttp to make Sentry work with API 23.

minSdkVersion of library

I have an issue: When add Sentry-Android to build.gradle, it show error minSDK of Sentry-Android is 15 and minSDK of my module is 14.

As I see in https://github.com/joshdholtz/Sentry-Android/blob/master/sentry-android/build.gradle, the minSdkVersion is 3, i don't know why Android studio show this error. Maybe the cause is when you deploy Sentry-Android, it take minSDKVersion from here https://github.com/joshdholtz/Sentry-Android/blob/master/app/build.gradle

So please configure library to resolve this issue. Thanks in advance.

Contexts is serialized to wrong json type in API < 19

At SentryEventRequest, we use new JSONObject(builder.event).toString() to get the JSON string.

It is worked well in API 19, I have reformatted the result to make itself clear.

{
    "contexts": {
        "os": {
            "type": "os",
            "build": "19",
            "kernel_version": "3.10.35+",
            "name": "Android",
            "version": "4.4.2"
        }
    }
}

but in API 17, the contexts member has been serialized to a String, not a JSONArray.

{
    "contexts": "{ os={ build=17, type=os, kernel_version=3.4.5, version=4.2.2, name=Android } }"
}

Validate SENTRY-DSN

Good work doing this wrapper, congrats!

I think you should add a function to validate the structure of the SENTRY-DSN (before init()), because if it is bad formed, "Sentry.init" is throwing and exception but you really don't know the context of that exception.

Kind regards!

I get SendEvent - 400 {"error":"Invalid project_id: u'3'"}

note: it is a possible duplicate of #1
I changed my DNS/DSN (redeployed on a new server with sentry 8.3.2)
while python/raven works on my new instance. SentryAndroid log this issue:

D/Sentry: URI - http://x:[email protected]_domain.net/3
I/System.out: AsyncTask #5 calls detatch()
D/Sentry: SendEvent - 400 {"error":"Invalid project_id: u'3'"}
D/Sentry: Adding request - UUID

My init is the common:
Sentry.init(ctx, ctx.getString(R.string.sentry_dsn));

I used to init with also base domain but currently it return a CSRF failure.

(I tryed to recreate the project in multi organisation as I saw it worked for some persons, the sentry server works well with my django app (raven client))

Uncaught exceptions don't contain device & os metadata

Overview

Uncaught exceptions should have the same metadata as manually-reported exceptions.

Steps to reproduce

  1. Raise an uncaught exception

Expected results

Event is annotated with OS, device, and app information. For example, here's an exception I sent manually:

image

Actual results

Only manually-set information via captureListener is sent:

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.