Skip to content

Commit

Permalink
Merge pull request #92 from matrix-org/valere/update_utd_error
Browse files Browse the repository at this point in the history
Update Error schema to support the new timeToDecryptMillis and cryptoSDK
  • Loading branch information
BillCarsonFr authored Mar 14, 2024
2 parents facce63 + f0d98b7 commit f756bf0
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 7 deletions.
14 changes: 13 additions & 1 deletion schemas/Error.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."},
Expand Down
15 changes: 13 additions & 2 deletions types/kotlin/Error.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
27 changes: 26 additions & 1 deletion types/kotlin2/Error.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {

/**
Expand All @@ -75,8 +98,10 @@ data class Error(
return mutableMapOf<String, Any>().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() }
}
}
21 changes: 18 additions & 3 deletions types/swift/Error.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand All @@ -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
]
}
}
Expand Down

0 comments on commit f756bf0

Please sign in to comment.