Skip to content

Commit

Permalink
chore(Sentry): Avoid logging NetworkException (#2208)
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianDevel authored Feb 28, 2025
2 parents b73879d + 1631b47 commit 6084dc3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
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

0 comments on commit 6084dc3

Please sign in to comment.