@@ -169,12 +169,20 @@ open class MainApplication : Application(), ImageLoaderFactory, DefaultLifecycle
169169 // Register the callback as an option
170170 options.beforeSend = SentryOptions .BeforeSendCallback { event: SentryEvent , _: Any? ->
171171 val exception = event.throwable
172- return @BeforeSendCallback when {
173- BuildConfig .DEBUG -> null // Sentry events are discarded if the app is in Debug mode
174- ! localSettings.isSentryTrackingEnabled -> null // Sentry events are discarded if the user deactivated Sentry tracking in DataManagement settings
175- exception is ApiController .NetworkException -> null // Network exceptions are discarded
176- exception is ApiErrorException && exception.errorCode == ErrorCode .ACCESS_DENIED -> null // AccessDenied exceptions are discarded
177- exception is ApiErrorException && exception.errorCode == ErrorCode .NOT_AUTHORIZED -> null // NotAuthorized exceptions are discarded
172+ /* *
173+ * Reasons to discard Sentry events :
174+ * - Application is in Debug mode
175+ * - User deactivated Sentry tracking in DataManagement settings
176+ * - The exception was an [ApiController.NetworkException], and we don't want to send them to Sentry
177+ * - The exception was an [ApiErrorException] with an [ErrorCode.ACCESS_DENIED] or
178+ * [ErrorCode.NOT_AUTHORIZED] error code, and we don't want to send them to Sentry
179+ */
180+ when {
181+ BuildConfig .DEBUG -> null
182+ ! localSettings.isSentryTrackingEnabled -> null
183+ exception is ApiController .NetworkException -> null
184+ exception is ApiErrorException && exception.errorCode == ErrorCode .ACCESS_DENIED -> null
185+ exception is ApiErrorException && exception.errorCode == ErrorCode .NOT_AUTHORIZED -> null
178186 else -> event
179187 }
180188 }
0 commit comments