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

Don't log NetworkException in Sentry #1853

Merged
merged 2 commits into from
May 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions app/src/main/java/com/infomaniak/mail/MainApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,14 @@ open class MainApplication : Application(), ImageLoaderFactory, DefaultLifecycle
SentryAndroid.init(this) { options: SentryAndroidOptions ->
// Register the callback as an option
options.beforeSend = SentryOptions.BeforeSendCallback { event: SentryEvent, _: Any? ->
// If the application is in debug mode, discard the events
if (!BuildConfig.DEBUG && localSettings.isSentryTrackingEnabled) event else null
val isNetworkException = event.exceptions?.any { it.type == "ApiController\$NetworkException" } ?: false
/**
* Reasons to discard Sentry events :
* - Application is in Debug mode
* - User deactivated Sentry tracking in DataManagement settings
* - The exception was a NetworkException, and we don't want to send them to Sentry
*/
if (!BuildConfig.DEBUG && localSettings.isSentryTrackingEnabled && !isNetworkException) event else null
}
options.addIntegration(
FragmentLifecycleIntegration(
Expand Down
Loading