29 lines
707 B
Swift
29 lines
707 B
Swift
import Combine
|
|
import Foundation
|
|
|
|
protocol AnalyticsTracking {
|
|
func track(_ event: String, attributes: [String: String])
|
|
}
|
|
|
|
struct HermesTrackedEvent: Identifiable, Equatable {
|
|
let id = UUID()
|
|
let event: String
|
|
let attributes: [String: String]
|
|
let timestamp: Date
|
|
}
|
|
|
|
@MainActor
|
|
final class HermesAnalyticsClient: ObservableObject, AnalyticsTracking {
|
|
@Published private(set) var trackedEvents: [HermesTrackedEvent] = []
|
|
|
|
func track(_ event: String, attributes: [String: String]) {
|
|
trackedEvents.append(
|
|
HermesTrackedEvent(
|
|
event: event,
|
|
attributes: attributes,
|
|
timestamp: Date()
|
|
)
|
|
)
|
|
}
|
|
}
|