From cf0d1355b5844665085687761037a28645530b41 Mon Sep 17 00:00:00 2001 From: Jeff Boek Date: Tue, 26 Mar 2019 09:13:59 -0700 Subject: [PATCH] Fixes #1187 - account for enum value change --- .../fenix/components/metrics/GleanMetricsService.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt index 6d0efa6181..9e64818c3b 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt @@ -16,9 +16,15 @@ private class EventWrapper>( private val event: EventMetricType, 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 }