Skip to content

Commit

Permalink
Merge pull request #97 from matrix-org/valere/utd_new_properties
Browse files Browse the repository at this point in the history
Add new properties to UTD errors
  • Loading branch information
BillCarsonFr authored Mar 26, 2024
2 parents 77b059c + b3ca076 commit ea0e987
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 3 deletions.
20 changes: 20 additions & 0 deletions schemas/Error.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,26 @@
{"const": "Native", "description": "Native / legacy crypto module specific to each platform."},
{"const": "Rust", "description": "Shared / cross-platform crypto module written in Rust."}
]
},
"eventLocalAgeMillis": {
"description": "An heuristic based on event origin_server_ts and the current device creation time (origin_server_ts - device_ts). This would be used to get the source of the event scroll-back/live/initialSync.",
"type": "integer"
},
"userTrustsOwnIdentity": {
"description": "true if the current user trusts their own identity (verified session) at time of decryption.",
"type": "boolean"
},
"isMatrixDotOrg": {
"description": "true if the current user is using matrix.org",
"type": "boolean"
},
"isFederated": {
"description": "true if userDomain != senderDomain.",
"type": "boolean"
},
"wasVisibleToUser": {
"description": "true if that unable to decrypt error was visible to the user",
"type": "boolean"
}
},
"required": ["domain", "name", "eventName"],
Expand Down
32 changes: 31 additions & 1 deletion types/kotlin/Error.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,44 @@ data class Error (
val cryptoSDK: String? = null,

val domain: Domain,

/**
* An heuristic based on event origin_server_ts and the current device creation time
* (origin_server_ts - device_ts). This would be used to get the source of the event
* scroll-back/live/initialSync.
*/
val eventLocalAgeMillis: Long? = null,

val eventName: EventName,

/**
* true if userDomain != senderDomain.
*/
val isFederated: Boolean? = null,

/**
* true if the current user is using matrix.org
*/
val isMatrixDotOrg: Boolean? = null,

val name: String,

/**
* 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
val timeToDecryptMillis: Long? = null,

/**
* true if the current user trusts their own identity (verified session) at time of
* decryption.
*/
val userTrustsOwnIdentity: Boolean? = null,

/**
* true if that unable to decrypt error was visible to the user
*/
val wasVisibleToUser: Boolean? = null
)

enum class Domain {
Expand Down
28 changes: 28 additions & 0 deletions types/kotlin2/Error.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,36 @@ data class Error(
*/
val cryptoSDK: CryptoSDK? = null,
val domain: Domain,
/**
* An heuristic based on event origin_server_ts and the current device
* creation time (origin_server_ts - device_ts). This would be used to
* get the source of the event scroll-back/live/initialSync.
*/
val eventLocalAgeMillis: Int? = null,
/**
* true if userDomain != senderDomain.
*/
val isFederated: Boolean? = null,
/**
* true if the current user is using matrix.org
*/
val isMatrixDotOrg: Boolean? = null,
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,
/**
* true if the current user trusts their own identity (verified session)
* at time of decryption.
*/
val userTrustsOwnIdentity: Boolean? = null,
/**
* true if that unable to decrypt error was visible to the user
*/
val wasVisibleToUser: Boolean? = null,
) : VectorAnalyticsEvent {

enum class Domain {
Expand Down Expand Up @@ -148,8 +171,13 @@ data class Error(
cryptoModule?.let { put("cryptoModule", it.name) }
cryptoSDK?.let { put("cryptoSDK", it.name) }
put("domain", domain.name)
eventLocalAgeMillis?.let { put("eventLocalAgeMillis", it) }
isFederated?.let { put("isFederated", it) }
isMatrixDotOrg?.let { put("isMatrixDotOrg", it) }
put("name", name.name)
timeToDecryptMillis?.let { put("timeToDecryptMillis", it) }
userTrustsOwnIdentity?.let { put("userTrustsOwnIdentity", it) }
wasVisibleToUser?.let { put("wasVisibleToUser", it) }
}.takeIf { it.isNotEmpty() }
}
}
24 changes: 22 additions & 2 deletions types/swift/Error.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,32 @@ extension AnalyticsEvent {
/// Which crypto backend is the client currently using.
public let cryptoSDK: CryptoSDK?
public let domain: Domain
/// An heuristic based on event origin_server_ts and the current device creation time (origin_server_ts - device_ts). This would be used to get the source of the event scroll-back/live/initialSync.
public let eventLocalAgeMillis: Int?
/// true if userDomain != senderDomain.
public let isFederated: Bool?
/// true if the current user is using matrix.org
public let isMatrixDotOrg: Bool?
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?
/// true if the current user trusts their own identity (verified session) at time of decryption.
public let userTrustsOwnIdentity: Bool?
/// true if that unable to decrypt error was visible to the user
public let wasVisibleToUser: Bool?

public init(context: String?, cryptoModule: CryptoModule?, cryptoSDK: CryptoSDK?, domain: Domain, name: Name, timeToDecryptMillis: Int?) {
public init(context: String?, cryptoModule: CryptoModule?, cryptoSDK: CryptoSDK?, domain: Domain, eventLocalAgeMillis: Int?, isFederated: Bool?, isMatrixDotOrg: Bool?, name: Name, timeToDecryptMillis: Int?, userTrustsOwnIdentity: Bool?, wasVisibleToUser: Bool?) {
self.context = context
self.cryptoModule = cryptoModule
self.cryptoSDK = cryptoSDK
self.domain = domain
self.eventLocalAgeMillis = eventLocalAgeMillis
self.isFederated = isFederated
self.isMatrixDotOrg = isMatrixDotOrg
self.name = name
self.timeToDecryptMillis = timeToDecryptMillis
self.userTrustsOwnIdentity = userTrustsOwnIdentity
self.wasVisibleToUser = wasVisibleToUser
}

public enum Domain: String {
Expand Down Expand Up @@ -95,8 +110,13 @@ extension AnalyticsEvent {
"cryptoModule": cryptoModule?.rawValue as Any,
"cryptoSDK": cryptoSDK?.rawValue as Any,
"domain": domain.rawValue,
"eventLocalAgeMillis": eventLocalAgeMillis as Any,
"isFederated": isFederated as Any,
"isMatrixDotOrg": isMatrixDotOrg as Any,
"name": name.rawValue,
"timeToDecryptMillis": timeToDecryptMillis as Any
"timeToDecryptMillis": timeToDecryptMillis as Any,
"userTrustsOwnIdentity": userTrustsOwnIdentity as Any,
"wasVisibleToUser": wasVisibleToUser as Any
]
}
}
Expand Down

0 comments on commit ea0e987

Please sign in to comment.