2026-06-16 17:39:23 +08:00
|
|
|
package com.xuqm.sdk.bugcollect
|
2026-06-16 12:10:58 +08:00
|
|
|
|
|
|
|
|
object FunnelTracker {
|
|
|
|
|
private val funnels = mutableMapOf<String, List<String>>()
|
|
|
|
|
private val progress = mutableMapOf<String, MutableList<String>>()
|
|
|
|
|
|
|
|
|
|
fun define(id: String, steps: List<String>) {
|
|
|
|
|
funnels[id] = steps
|
|
|
|
|
progress[id] = mutableListOf()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun track(eventName: String, @Suppress("UNUSED_PARAMETER") properties: Map<String, Any?>) {
|
|
|
|
|
for ((id, steps) in funnels) {
|
|
|
|
|
val done = progress[id] ?: continue
|
|
|
|
|
val next = steps.getOrNull(done.size) ?: continue
|
|
|
|
|
if (next == eventName) done.add(eventName)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|