diff --git a/Stores/src/main/java/com/infomaniak/lib/stores/updaterequired/data/models/AppVersion.kt b/Stores/src/main/java/com/infomaniak/lib/stores/updaterequired/data/models/AppVersion.kt index f47b80cd..c12a92ab 100644 --- a/Stores/src/main/java/com/infomaniak/lib/stores/updaterequired/data/models/AppVersion.kt +++ b/Stores/src/main/java/com/infomaniak/lib/stores/updaterequired/data/models/AppVersion.kt @@ -47,11 +47,10 @@ data class AppVersion( return isMinimalVersionValid(minimalAcceptedVersionNumbers) && currentVersionNumbers.compareVersionTo(minimalAcceptedVersionNumbers) < 0 }.getOrElse { exception -> - Sentry.withScope { scope -> + Sentry.captureException(exception) { scope -> scope.level = SentryLevel.ERROR scope.setExtra("Version from API", minimalAcceptedVersion) scope.setExtra("Current Version", currentVersion) - Sentry.captureException(exception) } return false diff --git a/Stores/src/standard/java/com/infomaniak/lib/stores/AppUpdateScheduler.kt b/Stores/src/standard/java/com/infomaniak/lib/stores/AppUpdateScheduler.kt index 1639efd2..efb722b8 100644 --- a/Stores/src/standard/java/com/infomaniak/lib/stores/AppUpdateScheduler.kt +++ b/Stores/src/standard/java/com/infomaniak/lib/stores/AppUpdateScheduler.kt @@ -24,7 +24,6 @@ import com.google.common.util.concurrent.ListenableFuture import com.infomaniak.lib.core.utils.SentryLog import com.infomaniak.lib.stores.updatemanagers.WorkerUpdateManager import io.sentry.Sentry -import io.sentry.SentryLevel import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -79,9 +78,8 @@ class AppUpdateScheduler( updateManager.installDownloadedUpdate( onInstallSuccess = { completer.setResult(Result.success()) }, onInstallFailure = { exception -> - Sentry.withScope {scope -> + Sentry.captureMessage("AppUpdate throwed an exception") { scope -> scope.setTag("message", exception.message ?: "Unknown error") - Sentry.captureMessage("AppUpdate throwed an exception", SentryLevel.INFO) } completer.setResult(Result.failure()) }, diff --git a/src/main/java/com/infomaniak/lib/core/networking/AccessTokenUsageInterceptor.kt b/src/main/java/com/infomaniak/lib/core/networking/AccessTokenUsageInterceptor.kt index 86570101..d0291a92 100644 --- a/src/main/java/com/infomaniak/lib/core/networking/AccessTokenUsageInterceptor.kt +++ b/src/main/java/com/infomaniak/lib/core/networking/AccessTokenUsageInterceptor.kt @@ -55,21 +55,20 @@ class AccessTokenUsageInterceptor( return@runBlocking } - if (previousApiCall != null - && currentApiCall.accessToken == previousApiCall.accessToken - && currentApiCall.date < previousApiCall.date + ONE_YEAR + if (previousApiCall != null && + currentApiCall.accessToken == previousApiCall.accessToken && + currentApiCall.date < previousApiCall.date + ONE_YEAR ) { - Sentry.withScope { scope -> - scope.level = SentryLevel.FATAL - + Sentry.captureMessage( + "Got disconnected due to non-working access token but it's not been a year yet", + SentryLevel.FATAL, + ) { scope -> scope.setExtra("Last known api call date epoch", previousApiCall.date.toString()) scope.setExtra("Last known api call token", formatAccessTokenForSentry(previousApiCall.accessToken)) scope.setExtra("Last known api call response code", previousApiCall.responseCode.toString()) scope.setExtra("Current api call date epoch", currentApiCall.date.toString()) scope.setExtra("Current api call token", formatAccessTokenForSentry(currentApiCall.accessToken)) - - Sentry.captureMessage("Got disconnected due to non-working access token but it's not been a year yet") } } } diff --git a/src/main/java/com/infomaniak/lib/core/utils/MediaStoreUtils.kt b/src/main/java/com/infomaniak/lib/core/utils/MediaStoreUtils.kt index 77943665..76fe941b 100644 --- a/src/main/java/com/infomaniak/lib/core/utils/MediaStoreUtils.kt +++ b/src/main/java/com/infomaniak/lib/core/utils/MediaStoreUtils.kt @@ -52,18 +52,16 @@ fun Context.getFileNameAndSize(uri: Uri): Pair? { fileName to fileSize } else { - Sentry.withScope { scope -> + Sentry.captureMessage("$this has empty cursor") { scope -> scope.setExtra("available columns", cursor.columnNames.joinToString { it }) - Sentry.captureMessage("$this has empty cursor") } null } } }.getOrElse { exception -> uri.path?.substringBeforeLast("/")?.let { providerName -> - Sentry.withScope { scope -> + Sentry.captureException(exception) { scope -> scope.setExtra("uri", providerName) - Sentry.captureException(exception) } } null