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

chore(Sentry): Avoid logging NetworkException #2208

Merged
merged 3 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions app/src/main/java/com/infomaniak/mail/MainApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ open class MainApplication : Application(), ImageLoaderFactory, DefaultLifecycle
shouldLog.add(isSentryTrackingEnabled)

// Network exceptions are discarded
// TODO: It doesn't work anymore :(
val isNetworkException = event.exceptions?.any { it.type == "ApiController\$NetworkException" } ?: false
shouldLog.add(!isNetworkException)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ object MyKSuiteDataUtils : MyKSuiteDataManager() {
} else {
@OptIn(ExperimentalSerializationApi::class)
apiResponse.error?.exception?.let {
if (it is MissingFieldException || it.message?.contains("Unexpected JSON token") == true) {
SentryLog.e(TAG, "Error decoding the api result MyKSuiteObject", it)
}
if (it is MissingFieldException) SentryLog.e(TAG, "Error decoding the api result MyKSuiteObject", it)
}
}

Expand Down
5 changes: 4 additions & 1 deletion app/src/main/java/com/infomaniak/mail/utils/SharedUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package com.infomaniak.mail.utils

import androidx.fragment.app.Fragment
import com.infomaniak.lib.core.api.ApiController
import com.infomaniak.mail.MatomoMail.trackEvent
import com.infomaniak.mail.R
import com.infomaniak.mail.data.LocalSettings
Expand Down Expand Up @@ -184,7 +185,9 @@ class SharedUtils @Inject constructor(
null
} else {
val apiException = getApiException()
Sentry.captureException(SignatureException(apiException.message, apiException))
if (apiException !is ApiController.NetworkException) {
Sentry.captureException(SignatureException(apiException.message, apiException))
}
translatedError
}
}
Expand Down
Loading