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

Remove platformCodeName super property, and use existing appPlatform instead #106

Merged
merged 2 commits into from
May 29, 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 @@ -26,10 +26,9 @@ package im.vector.app.features.analytics.plan
*/
data class SuperProperties(
/**
* Used by web to identify the platform (Web Platform/Electron
* Platform).
* Used as a discriminant to breakdown usage per client.
*/
val appPlatform: String? = null,
val appPlatform: AppPlatform? = null,
/**
* Which crypto backend is the client currently using.
*/
Expand All @@ -38,10 +37,6 @@ 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(val rawValue: String) {
Expand All @@ -56,50 +51,49 @@ data class SuperProperties(
Rust("Rust"),
}

enum class PlatformCodeName(val rawValue: String) {

/**
* Element Desktop platform code.
*/
Desktop("Desktop"),
enum class AppPlatform(val rawValue: String) {

/**
* Element Android platform code.
* Element Android platform.
*/
EA("EA"),

/**
* Element iOS platform code.
* Element iOS platform.
*/
EI("EI"),

/**
* Element-X Android platform code.
* Element-X Android platform.
*/
EXA("EXA"),

/**
* Element-X iOS platform code.
* Element-X iOS platform.
*/
EXI("EXI"),

/**
* Other Platform code.
* Element Desktop platform.
*/
ElectronPlatform("Electron Platform"),

/**
* Other Platform.
*/
Other("Other"),

/**
* Element Web platform code.
* Element Web platform.
*/
Web("Web"),
WebPlatform("Web Platform"),
}

fun getProperties(): Map<String, Any>? {
return mutableMapOf<String, Any>().apply {
appPlatform?.let { put("appPlatform", it) }
appPlatform?.let { put("appPlatform", it.rawValue) }
cryptoSDK?.let { put("cryptoSDK", it.rawValue) }
cryptoSDKVersion?.let { put("cryptoSDKVersion", it) }
platformCodeName?.let { put("platformCodeName", it.rawValue) }
}.takeIf { it.isNotEmpty() }
}
}
19 changes: 7 additions & 12 deletions schemas/SuperProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,16 @@
"type": "string"
},
"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."}
{"const": "Web Platform", "description": "Element Web platform."},
{"const": "Electron Platform", "description": "Element Desktop platform."},
{"const": "EI", "description": "Element iOS platform."},
{"const": "EXI", "description": "Element-X iOS platform."},
{"const": "EA", "description": "Element Android platform."},
{"const": "EXA", "description": "Element-X Android platform."},
{"const": "Other", "description": "Other Platform."}
]
}
},
Expand Down
34 changes: 15 additions & 19 deletions types/swift/SuperProperties.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,17 @@ import Foundation
extension AnalyticsEvent {
public struct SuperProperties {

/// Used by web to identify the platform (Web Platform/Electron Platform).
public let appPlatform: String?
/// Used as a discriminant to breakdown usage per client.
public let appPlatform: AppPlatform?
/// Which crypto backend is the client currently using.
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?, platformCodeName: PlatformCodeName?) {
public init(appPlatform: AppPlatform?, cryptoSDK: CryptoSDK?, cryptoSDKVersion: String?) {
self.appPlatform = appPlatform
self.cryptoSDK = cryptoSDK
self.cryptoSDKVersion = cryptoSDKVersion
self.platformCodeName = platformCodeName
}

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

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

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