Skip to content

Commit

Permalink
Merge pull request #104 from matrix-org/valere/more_super_platform
Browse files Browse the repository at this point in the history
Add a new platform code super property
  • Loading branch information
BillCarsonFr authored May 27, 2024
2 parents fd0fe78 + 0fb6f84 commit 53b2e89
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ data class SuperProperties(
* Version of the crypto backend.
*/
val cryptoSDKVersion: String? = null,
/**
* Used as a discriminant to breakdown usage per client.
*/
val platformCodeName: PlatformCodeName? = null,
) {

enum class CryptoSDK {
Expand All @@ -52,11 +56,50 @@ data class SuperProperties(
Rust,
}

enum class PlatformCodeName {

/**
* Element Desktop platform code.
*/
Desktop,

/**
* Element Android platform code.
*/
EA,

/**
* Element iOS platform code.
*/
EI,

/**
* Element-X Android platform code.
*/
EXA,

/**
* Element-X iOS platform code.
*/
EXI,

/**
* Other Platform code.
*/
Other,

/**
* Element Web platform code.
*/
Web,
}

fun getProperties(): Map<String, Any>? {
return mutableMapOf<String, Any>().apply {
appPlatform?.let { put("appPlatform", it) }
cryptoSDK?.let { put("cryptoSDK", it.name) }
cryptoSDKVersion?.let { put("cryptoSDKVersion", it) }
platformCodeName?.let { put("platformCodeName", it.name) }
}.takeIf { it.isNotEmpty() }
}
}
14 changes: 14 additions & 0 deletions schemas/SuperProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@
"appPlatform": {
"description": "Used by web to identify the platform (Web Platform/Electron Platform).",
"type": "string"
},

"platformCodeName": {
"description": "Used as a discriminant to breakdown usage per client.",
"type": "string",
"oneOf": [
{"const": "Web", "description": "Element Web platform code."},
{"const": "Desktop", "description": "Element Desktop platform code."},
{"const": "EI", "description": "Element iOS platform code."},
{"const": "EXI", "description": "Element-X iOS platform code."},
{"const": "EA", "description": "Element Android platform code."},
{"const": "EXA", "description": "Element-X Android platform code."},
{"const": "Other", "description": "Other Platform code."}
]
}
},
"required": [],
Expand Down
25 changes: 23 additions & 2 deletions types/swift/SuperProperties.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ extension AnalyticsEvent {
public let cryptoSDK: CryptoSDK?
/// Version of the crypto backend.
public let cryptoSDKVersion: String?
/// Used as a discriminant to breakdown usage per client.
public let platformCodeName: PlatformCodeName?

public init(appPlatform: String?, cryptoSDK: CryptoSDK?, cryptoSDKVersion: String?) {
public init(appPlatform: String?, cryptoSDK: CryptoSDK?, cryptoSDKVersion: String?, platformCodeName: PlatformCodeName?) {
self.appPlatform = appPlatform
self.cryptoSDK = cryptoSDK
self.cryptoSDKVersion = cryptoSDKVersion
self.platformCodeName = platformCodeName
}

public enum CryptoSDK: String {
Expand All @@ -43,11 +46,29 @@ extension AnalyticsEvent {
case Rust
}

public enum PlatformCodeName: String {
/// Element Desktop platform code.
case Desktop
/// Element Android platform code.
case EA
/// Element iOS platform code.
case EI
/// Element-X Android platform code.
case EXA
/// Element-X iOS platform code.
case EXI
/// Other Platform code.
case Other
/// Element Web platform code.
case Web
}

public var properties: [String: Any?] {
return [
"appPlatform": appPlatform,
"cryptoSDK": cryptoSDK?.rawValue,
"cryptoSDKVersion": cryptoSDKVersion
"cryptoSDKVersion": cryptoSDKVersion,
"platformCodeName": platformCodeName?.rawValue
]
}
}
Expand Down

0 comments on commit 53b2e89

Please sign in to comment.