Skip to content

Commit b7d9d42

Browse files
Add Sentry about empty Thread
1 parent 83bf803 commit b7d9d42

File tree

5 files changed

+20
-10
lines changed

5 files changed

+20
-10
lines changed

app/src/main/java/com/infomaniak/mail/data/models/thread/Thread.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,9 @@ class Thread : RealmObject {
228228

229229
}.getOrElse { throwable ->
230230
Sentry.withScope { scope ->
231-
scope.setExtra("thread.folder.role", "${folder.role?.name}")
231+
scope.setExtra("thread.folder.role", folder.role?.name.toString())
232232
scope.setExtra("thread.folder.id", folder.id)
233+
scope.setExtra("thread.folderId", folderId)
233234
scope.setExtra("thread.uid", uid)
234235
scope.setExtra("thread.messages.count", "${messages.count()}")
235236
scope.setExtra("thread.duplicates.count", "${duplicates.count()}")

app/src/main/java/com/infomaniak/mail/ui/main/folder/ThreadListAdapter.kt

+2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import com.infomaniak.mail.ui.main.folder.ThreadListAdapter.ThreadListViewHolder
6060
import com.infomaniak.mail.ui.main.thread.SubjectFormatter
6161
import com.infomaniak.mail.ui.main.thread.SubjectFormatter.TagColor
6262
import com.infomaniak.mail.utils.RealmChangesBinding
63+
import com.infomaniak.mail.utils.SentryDebug
6364
import com.infomaniak.mail.utils.Utils.runCatchingRealm
6465
import com.infomaniak.mail.utils.extensions.*
6566
import dagger.hilt.android.qualifiers.ActivityContext
@@ -196,6 +197,7 @@ class ThreadListAdapter @Inject constructor(
196197
// TODO: Find why we are sometimes displaying empty Threads, and fix it instead of just deleting them.
197198
// It's possibly because we are out of sync, and the situation will resolve itself shortly? ¯\_(ツ)_/¯
198199
threadListAdapterCallback?.deleteThreadInRealm?.invoke(thread.uid)
200+
SentryDebug.sendEmptyThread(thread, "No Message in the Thread when displaying it in ThreadList")
199201
return
200202
}
201203

app/src/main/java/com/infomaniak/mail/ui/main/folder/ThreadListFragment.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ class ThreadListFragment : TwoPaneFragment(), SwipeRefreshLayout.OnRefreshListen
717717
val currentFolder = mainViewModel.currentFolder.value
718718
Sentry.withScope { scope ->
719719
scope.setExtra("cursor", "$currentFolderCursor")
720-
scope.setExtra("folderRole", "${currentFolder?.role?.name}")
720+
scope.setExtra("folderRole", currentFolder?.role?.name.toString())
721721
scope.setExtra("folderThreadsCount", "${currentFolder?.threads?.count()}")
722722
Sentry.captureMessage(
723723
"Should display threads is true but there are no threads to display",

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ class ThreadViewModel @Inject constructor(
274274
appContext.trackUserInfo("nbMessagesInThread", nbMessages)
275275

276276
when (nbMessages) {
277-
0 -> SentryDebug.sendEmptyThread(thread)
277+
0 -> SentryDebug.sendEmptyThread(thread, "No Message in the Thread when opening it")
278278
1 -> appContext.trackUserInfo("oneMessagesInThread")
279279
else -> appContext.trackUserInfo("multipleMessagesInThread", nbMessages)
280280
}

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

+14-7
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,21 @@ object SentryDebug {
117117
//region Send Sentry
118118
// TODO: Added the 04/09/23. It's not supposed to be possible, but we never know…
119119
// If this doesn't trigger after a certain amount of time, you can remove it.
120-
fun sendEmptyThread(thread: Thread) {
120+
//
121+
// Also added in ThreadListAdapter the 31/05/24.
122+
fun sendEmptyThread(thread: Thread, message: String) = with(thread) {
121123
Sentry.withScope { scope ->
122-
scope.setExtra("currentUserId", "[${AccountUtils.currentUserId}]")
123-
scope.setExtra("currentMailboxEmail", "[${AccountUtils.currentMailboxEmail}]")
124-
scope.setExtra("folder.role", thread.folder.role?.name.toString())
125-
scope.setExtra("folder.id", thread.folder.id)
126-
scope.setExtra("thread.uid", "[${thread.uid}]")
127-
Sentry.captureMessage("No Message in the Thread when opening it", SentryLevel.ERROR)
124+
scope.setExtra("currentUserId", "${AccountUtils.currentUserId}")
125+
scope.setExtra("currentMailboxEmail", AccountUtils.currentMailboxEmail.toString())
126+
scope.setExtra("folderId", folderId)
127+
scope.setExtra("folder.id", folder.id)
128+
scope.setExtra("folder.role", folder.role?.name.toString())
129+
scope.setExtra("uid", uid)
130+
scope.setExtra("messages.count", "${messages.count()}")
131+
scope.setExtra("duplicates.count", "${duplicates.count()}")
132+
scope.setExtra("isFromSearch", "$isFromSearch")
133+
scope.setExtra("hasDrafts", "$hasDrafts")
134+
Sentry.captureMessage(message, SentryLevel.ERROR)
128135
}
129136
}
130137

0 commit comments

Comments
 (0)