Swiftgram/TelegramCore/SplitTest.swift
Ilya Laktyushin 008ecf61a1 Added json app configuration fetch
Added app log events synchronization
Added A/B test API
2018-12-04 22:27:51 +04:00

30 lines
854 B
Swift

import Foundation
import Postbox
public protocol SplitTestEvent: RawRepresentable where RawValue == String {
}
public protocol SplitTestConfiguration {
static var defaultValue: Self { get }
}
public protocol SplitTest {
associatedtype Configuration: SplitTestConfiguration
associatedtype Event: SplitTestEvent
var postbox: Postbox { get }
var bucket: String? { get }
var configuration: Configuration { get }
init(postbox: Postbox, bucket: String?, configuration: Configuration)
}
extension SplitTest {
public func addEvent(_ event: Self.Event, data: JSON = []) {
if let bucket = self.bucket {
//TODO: merge additional data
addAppLogEvent(postbox: self.postbox, time: Date().timeIntervalSince1970, type: event.rawValue, peerId: nil, data: ["bucket": bucket])
}
}
}