Documentation

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:

AnalyticsLogController.shared.track("PageView - Home")

Log an analytics event with metadata:

AnalyticsLogController.shared.track("PageView - Home", properties: [
    "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.
    controllers.append(ExampleLogController())
    
    return controllers
}()