Skip to content

Commit

Permalink
Merge pull request #1918 from Infomaniak/don't-log-FCM-exception-due-…
Browse files Browse the repository at this point in the history
…to-bad-connection

Do not log FCM exception SERVICE_NOT_AVAILABLE
  • Loading branch information
tevincent committed Jun 18, 2024
2 parents d4f0885 + b97b1e4 commit b865bae
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ class StandardPlayServicesUtils @Inject constructor(

FirebaseMessaging.getInstance().token.addOnCompleteListener { task ->
if (!task.isSuccessful) {
Sentry.withScope { scope ->
scope.setExtra("task.exception", task.exception.toString())
Sentry.captureMessage("Fetching FCM registration token failed", SentryLevel.ERROR)
if (task.exception?.message?.contains(SERVICE_NOT_AVAILABLE_EXCEPTION) != true) {
Sentry.withScope { scope ->
scope.setExtra("task.exception", task.exception.toString())
Sentry.captureMessage("Fetching FCM registration token failed", SentryLevel.ERROR)
}
}
SentryLog.w("firebase", "Fetching FCM registration token failed", task.exception)
return@addOnCompleteListener
Expand All @@ -92,4 +94,8 @@ class StandardPlayServicesUtils @Inject constructor(
registerUserDeviceWorkerScheduler.scheduleWork()
}
}

companion object {
const val SERVICE_NOT_AVAILABLE_EXCEPTION = "SERVICE_NOT_AVAILABLE"
}
}

0 comments on commit b865bae

Please sign in to comment.