Duration KPI (v5.5+)
The SDK provides a way to create a "duration kpi" to record the duration from time A to time B
The main use case is to record the time spent on a view
Start the timer in viewDidLoad()
override func viewDidLoad() {
    StatsManager.shared.startDurationKpi(tag: "your_screen")
}You can optionally provide a context param, which is a [String: AnyCodable]
StatsManager.shared.startDurationKpi(tag: "your_screen", context: ["user_id": 5])And end the timer in viewDidDisappear(_:)
override func viewDidDisappear(_ animated: Bool) {
    StatsManager.shared.endDurationKpi(tag: "your_screen")
}You can also end all timers at the same time
StatsManager.shared.endAllDurationKpis()Updated 5 months ago