Skip to content

Commit

Permalink
Merge pull request #95 from matrix-org/valere/super_properties
Browse files Browse the repository at this point in the history
Define a new SuperProperties Object
  • Loading branch information
BillCarsonFr authored Mar 26, 2024
2 parents 19994c3 + b13c14a commit 446c42e
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 0 deletions.
24 changes: 24 additions & 0 deletions schemas/SuperProperties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"type": "object",
"description": "Super Properties are properties associated with events that are sent with every capture call, be it a $pageview, an autocaptured button click, or anything else.",
"properties": {
"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."}
]
},
"cryptoSDKVersion": {
"description": "Version of the crypto backend.",
"type": "string"
},
"appPlatform": {
"description": "Used by web to identify the platform (Web Platform/Electron Platform)",
"type": "string"
}
},
"required": [],
"additionalProperties": false
}
22 changes: 22 additions & 0 deletions types/kotlin/SuperProperties.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package quicktype

/**
* Super Properties are properties associated with events that are sent with every capture
* call, be it a $pageview, an autocaptured button click, or anything else.
*/
data class SuperProperties (
/**
* Used by web to identify the platform (Web Platform/Electron Platform)
*/
val appPlatform: String? = null,

/**
* Which crypto backend is the client currently using.
*/
val cryptoSDK: String? = null,

/**
* Version of the crypto backend.
*/
val cryptoSDKVersion: String? = null
)
61 changes: 61 additions & 0 deletions types/kotlin2/SuperProperties.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright (c) 2021 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package im.vector.app.features.analytics.plan

// GENERATED FILE, DO NOT EDIT. FOR MORE INFORMATION VISIT
// https://github.com/matrix-org/matrix-analytics-events/

/**
* Super Properties are properties associated with events that are sent with
* every capture call, be it a $pageview, an autocaptured button click, or
* anything else.
*/
data class SuperProperties(
/**
* Used by web to identify the platform (Web Platform/Electron Platform)
*/
val appPlatform: String? = null,
/**
* Which crypto backend is the client currently using.
*/
val cryptoSDK: CryptoSDK? = null,
/**
* Version of the crypto backend.
*/
val cryptoSDKVersion: String? = null,
) {

enum class CryptoSDK {
/**
* Legacy crypto backend specific to each platform.
*/
Legacy,

/**
* Cross-platform crypto backend written in Rust.
*/
Rust,
}

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) }
}.takeIf { it.isNotEmpty() }
}
}
54 changes: 54 additions & 0 deletions types/swift/SuperProperties.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation

// GENERATED FILE, DO NOT EDIT. FOR MORE INFORMATION VISIT
// https://github.com/matrix-org/matrix-analytics-events/

/// Super Properties are properties associated with events that are sent with every capture call, be it a $pageview, an autocaptured button click, or anything else.
extension AnalyticsEvent {
public struct SuperProperties {

/// Used by web to identify the platform (Web Platform/Electron Platform)
public let appPlatform: String?
/// Which crypto backend is the client currently using.
public let cryptoSDK: CryptoSDK?
/// Version of the crypto backend.
public let cryptoSDKVersion: String?

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

public enum CryptoSDK: String {
/// Legacy crypto backend specific to each platform.
case Legacy
/// Cross-platform crypto backend written in Rust.
case Rust
}

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

0 comments on commit 446c42e

Please sign in to comment.