Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new platform code super property #104

Merged
merged 1 commit into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

break down

*/
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
Loading