Skip to content

Commit

Permalink
Fix: Crashing when listing the speed values on edit monster (#244)
Browse files Browse the repository at this point in the history
* Improve monster edit save analytics

* Fix: Crashing when listing the speed values on edit monster
  • Loading branch information
alexandregpereira authored Feb 10, 2024
1 parent 7241ff5 commit 936de1e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ internal fun SpeedWithValuesEntity.toDomain(): Speed {
}

internal fun List<SpeedValueEntity>.toDomain(): List<SpeedValue> {
return this.map {
return this.mapIndexed { index, speedValueEntity ->
SpeedValue(
type = SpeedType.valueOf(it.type),
valueFormatted = it.valueFormatted
type = SpeedType.valueOf(speedValueEntity.type),
valueFormatted = speedValueEntity.valueFormatted,
index = "${speedValueEntity.speedId}-${speedValueEntity.type}-$index"
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package br.alexandregpereira.hunter.monster.registration

import br.alexandregpereira.hunter.analytics.Analytics
import br.alexandregpereira.hunter.domain.model.Monster

internal fun Analytics.trackMonsterRegistrationOpened(monsterIndex: String) {
track(
Expand All @@ -20,11 +21,12 @@ internal fun Analytics.trackMonsterRegistrationClosed(monsterIndex: String) {
)
}

internal fun Analytics.trackMonsterRegistrationSaved(monsterIndex: String) {
internal fun Analytics.trackMonsterRegistrationSaved(monster: Monster) {
track(
eventName = "MonsterRegistration - saved",
params = mapOf(
"monsterIndex" to monsterIndex,
"monsterIndex" to monster.index,
"monster" to monster.toString(),
),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class MonsterRegistrationStateHolder internal constructor(
}

override fun onSaved() {
analytics.trackMonsterRegistrationSaved(state.value.monster.index)
analytics.trackMonsterRegistrationSaved(state.value.monster)
normalizeMonster(state.value.monster)
.flatMapConcat { monster ->
saveMonsters(monsters = listOf(monster))
Expand Down

0 comments on commit 936de1e

Please sign in to comment.