mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-09 19:10:42 +00:00
Fixes #1187 - account for enum value change
This commit is contained in:
parent
edb197d10b
commit
cf0d1355b5
@ -16,9 +16,15 @@ private class EventWrapper<T : Enum<T>>(
|
||||
private val event: EventMetricType<T>,
|
||||
private val keyMapper: ((String) -> T)? = null
|
||||
) {
|
||||
private val String.asCamelCase: String
|
||||
get() = this.split("_").reduceIndexed { index, acc, s ->
|
||||
if (index == 0) acc + s
|
||||
else acc + s.capitalize()
|
||||
}
|
||||
|
||||
fun track(event: Event) {
|
||||
val extras = if (keyMapper != null) {
|
||||
event.extras?.mapKeys { keyMapper.invoke(it.key) }
|
||||
event.extras?.mapKeys { keyMapper.invoke(it.key.asCamelCase) }
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user