20 行
626 B
Kotlin
20 行
626 B
Kotlin
|
|
package com.xuqm.sdk.log
|
||
|
|
|
||
|
|
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)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|