Don't send crash reports as json (#84)

This is a workaround for jellyfin/jellyfin-web#7267 to ensure the client
logs are not valid JSON and can be rendered on the `10.11.x` web UI.

Related to #82
This commit is contained in:
damontecres 2025-10-27 21:22:44 -04:00 committed by GitHub
parent f1f6b729aa
commit af0e853c21
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -15,7 +15,9 @@ import org.jellyfin.sdk.Jellyfin
import org.jellyfin.sdk.api.client.extensions.clientLogApi
import org.jellyfin.sdk.api.okhttp.OkHttpFactory
import org.jellyfin.sdk.createJellyfin
import org.json.JSONObject
import timber.log.Timber
import java.util.Date
@AutoService(ReportSenderFactory::class)
class CrashReportSenderFactory : ReportSenderFactory {
@ -53,11 +55,22 @@ class CrashReportSender : ReportSender {
minimumServerVersion = Jellyfin.minimumVersion
}.createApi(baseUrl = serverUrl, accessToken = accessToken)
val obj = JSONObject()
for ((key, value) in errorContent.toMap()) {
obj.put(key, value)
}
val jsonStr = obj.toString(2)
runBlocking {
val filename =
api.clientLogApi
.logFile(errorContent.toJSON())
.content.fileName
.logFile(
"""
---
Date: ${Date()}
---
""".trimIndent() + jsonStr,
).content.fileName
Timber.i("Sent report to $serverUrl, filename=$filename")
}
} catch (ex: Exception) {