From f0d98b7b15fb3e1ae8d30454be011dcb92095a73 Mon Sep 17 00:00:00 2001 From: Valere Date: Thu, 14 Mar 2024 17:19:16 +0100 Subject: [PATCH] Error: add timeToDecryptMillis and cryptoSDK --- schemas/Error.json | 14 +++++++++++++- types/kotlin/Error.kt | 15 +++++++++++++-- types/kotlin2/Error.kt | 27 ++++++++++++++++++++++++++- types/swift/Error.swift | 21 ++++++++++++++++++--- 4 files changed, 70 insertions(+), 7 deletions(-) diff --git a/schemas/Error.json b/schemas/Error.json index 0b50048..5956f2a 100644 --- a/schemas/Error.json +++ b/schemas/Error.json @@ -32,8 +32,20 @@ "description": "Context - client defined, can be used for debugging.", "type": "string" }, + "timeToDecryptMillis": { + "description": "UTDs can be permanent or temporary. If temporary, this field will contain the time it took to decrypt the message in milliseconds. If permanent should be -1", + "type": "integer" + }, + "cryptoSDK": { + "description": "Which crypto backend is the client currently using.", + "type": "string", + "oneOf": [ + {"const": "Legacy", "description": "Legacy crypto backend specific to each platform."}, + {"const": "Rust", "description": "Cross-platform crypto backend written in Rust."} + ] + }, "cryptoModule": { - "description": "Which crypto module is the client currently using.", + "description": "DEPRECATED: Which crypto module is the client currently using.", "type": "string", "oneOf": [ {"const": "Native", "description": "Native / legacy crypto module specific to each platform."}, diff --git a/types/kotlin/Error.kt b/types/kotlin/Error.kt index d5c1760..e81a8da 100644 --- a/types/kotlin/Error.kt +++ b/types/kotlin/Error.kt @@ -10,13 +10,24 @@ data class Error ( val context: String? = null, /** - * Which crypto module is the client currently using. + * DEPRECATED: Which crypto module is the client currently using. */ val cryptoModule: String? = null, + /** + * Which crypto backend is the client currently using. + */ + val cryptoSDK: String? = null, + val domain: Domain, val eventName: EventName, - val name: Name + val name: Name, + + /** + * UTDs can be permanent or temporary. If temporary, this field will contain the time it + * took to decrypt the message in milliseconds. If permanent should be -1 + */ + val timeToDecryptMillis: Long? = null ) enum class Domain { diff --git a/types/kotlin2/Error.kt b/types/kotlin2/Error.kt index 386c090..48e16e5 100644 --- a/types/kotlin2/Error.kt +++ b/types/kotlin2/Error.kt @@ -30,11 +30,21 @@ data class Error( */ val context: String? = null, /** - * Which crypto module is the client currently using. + * DEPRECATED: Which crypto module is the client currently using. */ val cryptoModule: CryptoModule? = null, + /** + * Which crypto backend is the client currently using. + */ + val cryptoSDK: CryptoSDK? = null, val domain: Domain, val name: Name, + /** + * UTDs can be permanent or temporary. If temporary, this field will + * contain the time it took to decrypt the message in milliseconds. If + * permanent should be -1 + */ + val timeToDecryptMillis: Int? = null, ) : VectorAnalyticsEvent { enum class Domain { @@ -56,6 +66,19 @@ data class Error( VoipUserMediaFailed, } + enum class CryptoSDK { + + /** + * Legacy crypto backend specific to each platform. + */ + Legacy, + + /** + * Cross-platform crypto backend written in Rust. + */ + Rust, + } + enum class CryptoModule { /** @@ -75,8 +98,10 @@ data class Error( return mutableMapOf().apply { context?.let { put("context", it) } cryptoModule?.let { put("cryptoModule", it.name) } + cryptoSDK?.let { put("cryptoSDK", it.name) } put("domain", domain.name) put("name", name.name) + timeToDecryptMillis?.let { put("timeToDecryptMillis", it) } }.takeIf { it.isNotEmpty() } } } diff --git a/types/swift/Error.swift b/types/swift/Error.swift index d585b2c..a00f4c3 100644 --- a/types/swift/Error.swift +++ b/types/swift/Error.swift @@ -26,16 +26,22 @@ extension AnalyticsEvent { /// Context - client defined, can be used for debugging. public let context: String? - /// Which crypto module is the client currently using. + /// DEPRECATED: Which crypto module is the client currently using. public let cryptoModule: CryptoModule? + /// Which crypto backend is the client currently using. + public let cryptoSDK: CryptoSDK? public let domain: Domain public let name: Name + /// UTDs can be permanent or temporary. If temporary, this field will contain the time it took to decrypt the message in milliseconds. If permanent should be -1 + public let timeToDecryptMillis: Int? - public init(context: String?, cryptoModule: CryptoModule?, domain: Domain, name: Name) { + public init(context: String?, cryptoModule: CryptoModule?, cryptoSDK: CryptoSDK?, domain: Domain, name: Name, timeToDecryptMillis: Int?) { self.context = context self.cryptoModule = cryptoModule + self.cryptoSDK = cryptoSDK self.domain = domain self.name = name + self.timeToDecryptMillis = timeToDecryptMillis } public enum Domain: String { @@ -57,6 +63,13 @@ extension AnalyticsEvent { case VoipUserMediaFailed } + public enum CryptoSDK: String { + /// Legacy crypto backend specific to each platform. + case Legacy + /// Cross-platform crypto backend written in Rust. + case Rust + } + public enum CryptoModule: String { /// Native / legacy crypto module specific to each platform. case Native @@ -68,8 +81,10 @@ extension AnalyticsEvent { return [ "context": context as Any, "cryptoModule": cryptoModule?.rawValue as Any, + "cryptoSDK": cryptoSDK?.rawValue as Any, "domain": domain.rawValue, - "name": name.rawValue + "name": name.rawValue, + "timeToDecryptMillis": timeToDecryptMillis as Any ] } }