mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-12-25 17:12:38 +01:00
Merge pull request #5815 from vector-im/feature/aris/crypto_improve_UISI_exceptions
Enhance crypto posthog errors with more details
This commit is contained in:
commit
3d190bb2ac
@ -38,6 +38,7 @@ private data class DecryptionFailure(
|
||||
val failedEventId: String,
|
||||
val error: MXCryptoError.ErrorType
|
||||
)
|
||||
private typealias DetailedErrorName = Pair<String, Error.Name>
|
||||
|
||||
private const val GRACE_PERIOD_MILLIS = 4_000
|
||||
private const val CHECK_INTERVAL = 2_000L
|
||||
@ -112,7 +113,7 @@ class DecryptionFailureTracker @Inject constructor(
|
||||
|
||||
private fun checkFailures() {
|
||||
val now = clock.epochMillis()
|
||||
val aggregatedErrors: Map<Error.Name, List<String>>
|
||||
val aggregatedErrors: Map<DetailedErrorName, List<String>>
|
||||
synchronized(failures) {
|
||||
val toReport = mutableListOf<DecryptionFailure>()
|
||||
failures.removeAll { failure ->
|
||||
@ -136,20 +137,21 @@ class DecryptionFailureTracker @Inject constructor(
|
||||
// for now we ignore events already reported even if displayed again?
|
||||
.filter { alreadyReported.contains(it).not() }
|
||||
.forEach { failedEventId ->
|
||||
analyticsTracker.capture(Error(failedEventId, Error.Domain.E2EE, aggregation.key))
|
||||
analyticsTracker.capture(Error(aggregation.key.first, Error.Domain.E2EE, aggregation.key.second))
|
||||
alreadyReported.add(failedEventId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun MXCryptoError.ErrorType.toAnalyticsErrorName(): Error.Name {
|
||||
return when (this) {
|
||||
MXCryptoError.ErrorType.UNKNOWN_INBOUND_SESSION_ID -> Error.Name.OlmKeysNotSentError
|
||||
MXCryptoError.ErrorType.OLM -> {
|
||||
Error.Name.OlmUnspecifiedError
|
||||
}
|
||||
private fun MXCryptoError.ErrorType.toAnalyticsErrorName(): DetailedErrorName {
|
||||
val detailed = "$name | mxc_crypto_error_type"
|
||||
val errorName = when (this) {
|
||||
MXCryptoError.ErrorType.UNKNOWN_INBOUND_SESSION_ID,
|
||||
MXCryptoError.ErrorType.KEYS_WITHHELD -> Error.Name.OlmKeysNotSentError
|
||||
MXCryptoError.ErrorType.OLM -> Error.Name.OlmUnspecifiedError
|
||||
MXCryptoError.ErrorType.UNKNOWN_MESSAGE_INDEX -> Error.Name.OlmIndexError
|
||||
else -> Error.Name.UnknownError
|
||||
}
|
||||
return DetailedErrorName(detailed, errorName)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user