Search code examples
androidsentry

Can I filter certain events out from Sentry reporting on Android?


I would like to not sent 400s or certain Exception types to Sentry. Is that possible? The documentation doesn't make it clear how.


Solution

  • In the link you shared there's this snippet:

    SentryAndroid.init(this, options -> {
      options.setBeforeSend((event, hint) -> {
        if (event.getThrowable() instanceof SQLiteException) {
          event.setFingerprints(Arrays.asList("database-connection-error"));
        }
        return event;
      });
    });
    

    Here you can drop events that were created with the exception type SQLiteException.

    If you want to send 1 and drop the rest, you'd need to write some code. Like hold a hashmap of Type and add the exceptions to it as they go through this callback. And if it's a hit, you drop the event.