Skip to content

Commit 52afa00

Browse files
Onelined some Sentry scopes
1 parent 3964c42 commit 52afa00

File tree

7 files changed

+17
-57
lines changed

7 files changed

+17
-57
lines changed

app/src/main/java/com/infomaniak/mail/data/models/message/Message.kt

+1-4
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,7 @@ class Message : RealmObject {
182182
}
183183
}
184184
}
185-
Sentry.captureMessage(
186-
sentryMessage,
187-
SentryLevel.ERROR,
188-
) { scope ->
185+
Sentry.captureMessage(sentryMessage, SentryLevel.ERROR) { scope ->
189186
scope.setExtra("messageUid", uid)
190187
scope.setExtra("email", AccountUtils.currentMailboxEmail.toString())
191188
scope.setExtra("folders", "${_folders.map { "role:[${it.role?.name}] (id:[${it.id}])" }}")

app/src/main/java/com/infomaniak/mail/ui/MainViewModel.kt

+1-4
Original file line numberDiff line numberDiff line change
@@ -910,10 +910,7 @@ class MainViewModel @Inject constructor(
910910

911911
val filename = UUID.randomUUID().toString()
912912
val emlAttachment = Attachment(response.body?.bytes(), filename, EML_CONTENT_TYPE)
913-
Sentry.captureMessage(
914-
"Message display problem reported",
915-
SentryLevel.ERROR,
916-
) { scope ->
913+
Sentry.captureMessage("Message display problem reported", SentryLevel.ERROR) { scope ->
917914
scope.addAttachment(emlAttachment)
918915
}
919916

app/src/main/java/com/infomaniak/mail/ui/main/thread/ThreadAdapter.kt

+1-4
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,7 @@ class ThreadAdapter(
304304

305305
private fun isThemeTheSameForMessageUid(messageUid: String) = threadAdapterState.isThemeTheSameMap[messageUid] ?: run {
306306
// TODO: Find the cause. The bug probably affects other parts of the code that do not crash
307-
Sentry.captureMessage(
308-
"Missing message uid inside isThemeTheSameMap",
309-
SentryLevel.ERROR,
310-
) { scope ->
307+
Sentry.captureMessage("Missing message uid inside isThemeTheSameMap", SentryLevel.ERROR) { scope ->
311308
val mapStringRepresentation = threadAdapterState.isThemeTheSameMap
312309
.map { (key, value) -> "($key -> $value)" }
313310
.joinToString(prefix = "[", postfix = "]")

app/src/main/java/com/infomaniak/mail/utils/MessageBodyUtils.kt

+1-4
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,7 @@ object MessageBodyUtils {
7878
if (quotes.isEmpty() || quotes.all { it.isBlank() }) SplitBody(bodyContent) else SplitBody(content, bodyContent)
7979
},
8080
onTimeout = {
81-
Sentry.captureMessage(
82-
"Timeout reached while displaying a Message's body",
83-
SentryLevel.WARNING,
84-
) { scope ->
81+
Sentry.captureMessage("Timeout reached while displaying a Message's body", SentryLevel.WARNING) { scope ->
8582
scope.setExtra("body size", "${bodyContent.toByteArray().size} bytes")
8683
scope.setExtra("email", AccountUtils.currentMailboxEmail.toString())
8784
}

app/src/main/java/com/infomaniak/mail/utils/SentryDebug.kt

+11-33
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,7 @@ object SentryDebug {
173173
//
174174
// Also added in ThreadListAdapter & ThreadController the 04/06/24.
175175
fun sendEmptyThread(thread: Thread, message: String) = with(thread) {
176-
Sentry.captureMessage(
177-
message,
178-
SentryLevel.ERROR,
179-
) { scope ->
176+
Sentry.captureMessage(message, SentryLevel.ERROR) { scope ->
180177
scope.setExtra("currentUserId", "${AccountUtils.currentUserId}")
181178
scope.setExtra("currentMailboxEmail", AccountUtils.currentMailboxEmail.toString())
182179
scope.setExtra("folderId", folderId)
@@ -199,10 +196,7 @@ object SentryDebug {
199196
mailbox: Mailbox? = null,
200197
throwable: Throwable? = null,
201198
) {
202-
Sentry.captureMessage(
203-
"Failed Notif : $reason",
204-
sentryLevel,
205-
) { scope ->
199+
Sentry.captureMessage("Failed Notif : $reason", sentryLevel) { scope ->
206200
scope.setExtra("userId", "${userId?.toString()}")
207201
scope.setExtra("currentUserId", "[${AccountUtils.currentUserId}]")
208202
scope.setExtra("mailboxId", "${mailboxId?.toString()}")
@@ -232,10 +226,7 @@ object SentryDebug {
232226
fun sendOrphanMessages(previousCursor: String?, folder: Folder): List<Message> {
233227
val orphanMessages = folder.messages.filter { it.isOrphan() }
234228
if (orphanMessages.isNotEmpty()) {
235-
Sentry.captureMessage(
236-
"We found some orphan Messages.",
237-
SentryLevel.ERROR,
238-
) { scope ->
229+
Sentry.captureMessage("We found some orphan Messages.", SentryLevel.ERROR) { scope ->
239230
scope.setExtra("orphanMessages", "${orphanMessages.map { it.uid }}")
240231
scope.setExtra("number of Messages", "${orphanMessages.count()}")
241232
scope.setExtra("previousCursor", "$previousCursor")
@@ -249,10 +240,7 @@ object SentryDebug {
249240
fun sendOrphanThreads(previousCursor: String?, folder: Folder, realm: TypedRealm): RealmResults<Thread> {
250241
val orphanThreads = ThreadController.getOrphanThreads(realm)
251242
if (orphanThreads.isNotEmpty()) {
252-
Sentry.captureMessage(
253-
"We found some orphan Threads.",
254-
SentryLevel.ERROR,
255-
) { scope ->
243+
Sentry.captureMessage("We found some orphan Threads.", SentryLevel.ERROR) { scope ->
256244
scope.setExtra("orphanThreads", "${orphanThreads.map { it.uid }}")
257245
scope.setExtra("number of Threads", "${orphanThreads.count()}")
258246
scope.setExtra("number of Messages", "${orphanThreads.map { it.messages.count() }}")
@@ -266,10 +254,7 @@ object SentryDebug {
266254

267255
fun sendOrphanDrafts(orphans: List<Draft>) {
268256
if (orphans.isNotEmpty()) {
269-
Sentry.captureMessage(
270-
"We found some orphan Drafts.",
271-
SentryLevel.ERROR,
272-
) { scope ->
257+
Sentry.captureMessage("We found some orphan Drafts.", SentryLevel.ERROR) { scope ->
273258
scope.setExtra(
274259
"orphanDrafts",
275260
orphans.joinToString {
@@ -285,21 +270,15 @@ object SentryDebug {
285270
}
286271

287272
fun sendOverScrolledMessage(clientWidth: Int, scrollWidth: Int, messageUid: String) {
288-
Sentry.captureMessage(
289-
"When resizing the mail with js, after zooming, it can still scroll.",
290-
SentryLevel.ERROR,
291-
) { scope ->
273+
Sentry.captureMessage("When resizing the mail with js, after zooming, it can still scroll.", SentryLevel.ERROR) { scope ->
292274
scope.setTag("messageUid", messageUid)
293275
scope.setExtra("clientWidth", "$clientWidth")
294276
scope.setExtra("scrollWidth", "$scrollWidth")
295277
}
296278
}
297279

298280
fun sendJavaScriptError(errorName: String, errorMessage: String, errorStack: String, messageUid: String) {
299-
Sentry.captureMessage(
300-
"JavaScript returned an error when displaying an email.",
301-
SentryLevel.ERROR,
302-
) { scope ->
281+
Sentry.captureMessage("JavaScript returned an error when displaying an email.", SentryLevel.ERROR) { scope ->
303282
scope.setTag("messageUid", messageUid)
304283
scope.setExtra("errorName", errorName)
305284
scope.setExtra("errorMessage", errorMessage)
@@ -315,10 +294,7 @@ object SentryDebug {
315294
}
316295

317296
fun sendCredentialsIssue(infomaniakLogin: String?, infomaniakPassword: String) {
318-
Sentry.captureMessage(
319-
"Credentials issue when trying to auto-sync user",
320-
SentryLevel.ERROR,
321-
) { scope ->
297+
Sentry.captureMessage("Credentials issue when trying to auto-sync user", SentryLevel.ERROR) { scope ->
322298
scope.setExtra("email", "${AccountUtils.currentUser?.email}")
323299
val loginStatus = when {
324300
infomaniakLogin == null -> "is null"
@@ -337,7 +313,9 @@ object SentryDebug {
337313
}
338314

339315
fun sendWebViewVersionName(webViewPackageName: String?, webViewVersionName: String?, majorVersion: Int) {
340-
Sentry.captureMessage("WebView version name might be null on some devices. Checking that the version name is ok.") { scope ->
316+
Sentry.captureMessage(
317+
"WebView version name might be null on some devices. Checking that the version name is ok.",
318+
) { scope ->
341319
scope.setTag("webViewPackageName", "$webViewPackageName")
342320
scope.setTag("webViewVersionName", "$webViewVersionName")
343321
scope.setTag("majorVersion", "$majorVersion")

app/src/main/java/com/infomaniak/mail/workers/DraftsActionsWorker.kt

+1-4
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,7 @@ class DraftsActionsWorker @AssistedInject constructor(
328328
}
329329
error?.exception is SerializationException -> {
330330
realmActionOnDraft = deleteDraftCallback(draft)
331-
Sentry.captureMessage(
332-
"Return JSON for SendDraft API call was modified",
333-
SentryLevel.ERROR,
334-
) { scope ->
331+
Sentry.captureMessage("Return JSON for SendDraft API call was modified", SentryLevel.ERROR) { scope ->
335332
scope.setExtra("Is data null ?", "${data == null}")
336333
scope.setExtra("Error code", error?.code.toString())
337334
scope.setExtra("Error description", error?.description.toString())

app/src/standard/java/com/infomaniak/mail/StandardPlayServicesUtils.kt

+1-4
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,7 @@ class StandardPlayServicesUtils @Inject constructor(
7373
FirebaseMessaging.getInstance().token.addOnCompleteListener { task ->
7474
if (!task.isSuccessful) {
7575
if (task.exception?.message?.contains(SERVICE_NOT_AVAILABLE_EXCEPTION) != true) {
76-
Sentry.captureMessage(
77-
"Fetching FCM registration token failed",
78-
SentryLevel.ERROR,
79-
) { scope ->
76+
Sentry.captureMessage("Fetching FCM registration token failed", SentryLevel.ERROR) { scope ->
8077
scope.setExtra("task.exception", task.exception.toString())
8178
}
8279
}

0 commit comments

Comments
 (0)