Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How can we add wildcard to disable all sentry events in InAppExclude ? #3580

Answered by romtsn
kikmak42 asked this question in Q&A
Discussion options

I'm using sentry to capture errors but I want only for specified package and not from all packages and not even from activities from my app. Is this the correct way of doing it or should be done via some other configuration ?

SentryAndroid.init(this, options -> {
 options.addInAppExclude("*");
 options.addInAppInclude("com.example.lib.*");
});
You must be logged in to vote

hi, sorry I'm not sure I got your problem exactly - would you like to filter out some certain sentry events? inAppExclude is not meant for that, it's meant for marking some stackframes as in-app or not, but not really for filtering out the events.

If you would like some events to be dropped, you can use as mentioned here, but check for events from the lib that you'd like to capture:

SentryAndroid.init(context) { options ->
 options.beforeSend = SentryOptions.BeforeSendCallback { event, hint ->
 if (event.exceptions?.any { exception ->
 exception.stacktrace?.frames?.any { frame -> frame.module?.startsWith("com.example.lib") == true } == true
 } == true) {
 re...

Replies: 1 comment 2 replies

Comment options

hi, sorry I'm not sure I got your problem exactly - would you like to filter out some certain sentry events? inAppExclude is not meant for that, it's meant for marking some stackframes as in-app or not, but not really for filtering out the events.

If you would like some events to be dropped, you can use as mentioned here, but check for events from the lib that you'd like to capture:

SentryAndroid.init(context) { options ->
 options.beforeSend = SentryOptions.BeforeSendCallback { event, hint ->
 if (event.exceptions?.any { exception ->
 exception.stacktrace?.frames?.any { frame -> frame.module?.startsWith("com.example.lib") == true } == true
 } == true) {
 return@BeforeSendCallback event
 }
 null
 }
}
You must be logged in to vote
2 replies
Comment options

Sorry for the late reply but it took us some time in our end to test the code you provided, I think I wasn't clear what I wanted. I wanted to exclude all events from my app by default and wanted only events from a library I'm adding.

Also tried the above code and didn't work did the above code filter event which are produced in particular package ? we were getting all events in sentry

Comment options

@romtsn, hey good news, the code you provided worked perfectly, the issue was with auto-initialisation overriding this initialisation. Once we disabled auto-init this worked.

Answer selected by kikmak42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /