mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-05-03 22:56:57 +02:00
Use matrix-analytics-events generated stubs (locally for now).
Track screens, removing any that aren't part of the schema.
This commit is contained in:
@@ -16,27 +16,28 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
protocol DictionaryConvertible {
|
||||
protocol DictionaryConvertible: Encodable {
|
||||
var dictionary: [String: Any] { get }
|
||||
}
|
||||
|
||||
extension DictionaryConvertible {
|
||||
var dictionary: [String: Any] {
|
||||
let mirror = Mirror(reflecting: self)
|
||||
let dict: [String: Any] = Dictionary(uniqueKeysWithValues: mirror.children
|
||||
.compactMap { (label: String?, value: Any) in
|
||||
guard let label = label else { return nil }
|
||||
|
||||
if let value = value as? NSCoding {
|
||||
return (label, value)
|
||||
}
|
||||
|
||||
if let value = value as? CustomStringConvertible {
|
||||
return (label, value.description)
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
let dict: [String: Any] = Dictionary(uniqueKeysWithValues: mirror.children.compactMap { (label: String?, value: Any) in
|
||||
guard let label = label else { return nil }
|
||||
|
||||
// Handle standard types such as String/Int/Bool
|
||||
if let value = value as? NSCoding {
|
||||
return (label, value)
|
||||
}
|
||||
|
||||
// AnalyticsEvent enums
|
||||
if let value = value as? CustomStringConvertible {
|
||||
return (label, value.description)
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
return dict
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user