feat: Attach thread dumps to Sentry events

Also: add exception messages (like "Access is allowed from event dispatch thread only")
This commit is contained in:
Jakub Blach 2025-07-01 16:12:32 +02:00
parent 79668ebb00
commit 8fb7a3fa19

View file

@ -8,6 +8,8 @@ import com.intellij.openapi.diagnostic.SubmittedReportInfo
import com.intellij.openapi.diagnostic.SubmittedReportInfo.SubmissionStatus
import com.intellij.ui.jcef.JBCefApp
import com.intellij.util.Consumer
import io.sentry.Attachment
import io.sentry.Hint
import io.sentry.Sentry
import io.sentry.SentryEvent
import io.sentry.protocol.Message
@ -34,12 +36,9 @@ class ContinueErrorSubmitter : ErrorReportSubmitter() {
consumer: Consumer<in SubmittedReportInfo>
): Boolean {
try {
val event = events.filterIsInstance<IdeaReportingEvent>().firstOrNull() ?: return false
val sentryEvent = SentryEvent()
sentryEvent.throwable = event.data.throwable
sentryEvent.message = Message().apply { message = additionalInfo }
sentryEvent.setTag("plugin_version", event.plugin?.version)
Sentry.captureEvent(sentryEvent)
val event = events.filterIsInstance<IdeaReportingEvent>()
.firstOrNull() ?: return false
reportToSentry(event, additionalInfo)
} catch (_: Exception) {
consumer.consume(SubmittedReportInfo(SubmissionStatus.FAILED))
return false
@ -48,8 +47,18 @@ class ContinueErrorSubmitter : ErrorReportSubmitter() {
return true
}
private fun reportToSentry(event: IdeaReportingEvent, additionalInfo: String?) {
val sentryEvent = SentryEvent()
sentryEvent.throwable = event.data.throwable
sentryEvent.message = Message().apply { message = additionalInfo ?: event.data.message }
val hint = Hint.withAttachments(event.data.allAttachments.map { Attachment(it.bytes, it.path) })
sentryEvent.setTag("plugin_version", event.plugin?.version)
Sentry.captureEvent(sentryEvent, hint)
}
private companion object {
private const val SENTRY_DSN = "https://fe99934dcdc537d84209893a3f96a196@o4505462064283648.ingest.us.sentry.io/4508184596054016"
private const val SENTRY_DSN =
"https://fe99934dcdc537d84209893a3f96a196@o4505462064283648.ingest.us.sentry.io/4508184596054016"
}
}