AnalyticsLogController
A Swift Controller Class that handles analytics reporting. Through this single interface you can report to all integrated analytics providers. Console and Mixpanel logging is supported by default.
Usage
Log an analytics event:
.shared.track("PageView - Home") AnalyticsLogController
Log an analytics event with metadata:
.shared.track("PageView - Home", properties: [
AnalyticsLogController"ab_test_cohort": "version_a"
])
Adding a new analytics logging provider:
// 1. Integrate a new consumer of AnalyticsLogging:
final class ExampleLogController: AnalyticsLogging {
func track(_ eventName: String) {
}
func track(_ eventName: String, properties: [String: Any]?) {
}
}
// 2. Add the new log controller to `AnalyticsLogController.controllers`:
private let controllers: [AnalyticsLogging] = {
var controllers = [AnalyticsLogging]()
// - Add the new controller here.
.append(ExampleLogController())
controllers
return controllers
}()