Skip to content

Commit

Permalink
added crashlytics logging
Browse files Browse the repository at this point in the history
  • Loading branch information
DatL4g committed May 25, 2024
1 parent 6402213 commit 79ea115
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ import com.arkivanov.essenty.lifecycle.Lifecycle
import com.arkivanov.essenty.lifecycle.LifecycleOwner
import com.kmpalette.DominantColorState
import dev.datlag.aniflow.LocalDI
import dev.datlag.aniflow.other.BurningSeriesResolver
import dev.datlag.aniflow.ui.navigation.Component
import dev.datlag.aniflow.ui.theme.SchemeTheme
import dev.datlag.tooling.decompose.lifecycle.LocalLifecycleOwner
import dev.datlag.tooling.decompose.lifecycle.collectAsStateWithLifecycle
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.map
import org.kodein.di.instance
import org.kodein.di.instanceOrNull

/**
* Can be placed in the Component interface again when
Expand All @@ -30,7 +33,12 @@ fun Component.onRender(content: @Composable () -> Unit) {
content()
}
SideEffect {
// ToDo: di.nullableFirebaseInstance()?.crashlytics?.screen(this)
nullableFirebaseInstance()?.crashlytics?.screen(this)

val bs by instanceOrNull<BurningSeriesResolver>()
bs?.let {
nullableFirebaseInstance()?.crashlytics?.bs(it)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package dev.datlag.aniflow.common

import dev.datlag.aniflow.firebase.FirebaseFactory
import dev.datlag.aniflow.model.name
import dev.datlag.aniflow.other.BurningSeriesResolver
import dev.datlag.aniflow.ui.navigation.Component

fun FirebaseFactory.Crashlytics.screen(value: Component) {
this.customKey("Screen", value::class.name)
}

fun FirebaseFactory.Crashlytics.bs(available: Boolean, versionCode: Int, versionName: String?) {
this.customKey("BS Availability", available)
if (available) {
this.customKey("BS Version Code", versionCode)
this.customKey("BS Version Name", versionName.toString())
}
}

fun FirebaseFactory.Crashlytics.bs(resolver: BurningSeriesResolver) = bs(
available = resolver.isAvailable,
versionCode = resolver.versionCode,
versionName = resolver.versionName
)
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
app = "1.1.1"
app = "1.0.0"
aboutlibraries = "11.1.4"
activity = "1.9.0"
android = "8.2.2"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package dev.datlag.aniflow.model

import kotlin.reflect.KClass

expect val KClass<*>.name: String
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package dev.datlag.aniflow.model

import kotlin.reflect.KClass

actual val KClass<*>.name: String
get() = this.simpleName?.ifBlank { null } ?: this.js.name.ifBlank { null } ?: this.toString()
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package dev.datlag.aniflow.model

import kotlin.reflect.KClass

actual val KClass<*>.name: String
get() = this.qualifiedName?.ifBlank { null }
?: this.simpleName?.ifBlank { null }
?: this.java.canonicalName?.ifBlank { null } ?: this.java.name.ifBlank { null } ?: this.toString()
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package dev.datlag.aniflow.model

import kotlin.reflect.KClass

actual val KClass<*>.name: String
get() = this.qualifiedName?.ifBlank { null } ?: this.simpleName?.ifBlank { null } ?: this.toString()

0 comments on commit 79ea115

Please sign in to comment.