From 79ea115b41b112bbd86fbe7827ea93c4d94bb1f6 Mon Sep 17 00:00:00 2001 From: DatLag Date: Sat, 25 May 2024 20:06:56 +0200 Subject: [PATCH] added crashlytics logging --- .../datlag/aniflow/common/ExtendComponent.kt | 10 +++++++- .../datlag/aniflow/common/ExtendFirebase.kt | 24 +++++++++++++++++++ gradle/libs.versions.toml | 2 +- .../datlag/aniflow/model/PlatformExtendAny.kt | 5 ++++ .../aniflow/model/PlatformExtendAny.js.kt | 6 +++++ .../aniflow/model/PlatformExtendAny.jvm.kt | 8 +++++++ .../aniflow/model/PlatformExtendAny.native.kt | 6 +++++ 7 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 composeApp/src/commonMain/kotlin/dev/datlag/aniflow/common/ExtendFirebase.kt create mode 100644 model/src/commonMain/kotlin/dev/datlag/aniflow/model/PlatformExtendAny.kt create mode 100644 model/src/jsMain/kotlin/dev/datlag/aniflow/model/PlatformExtendAny.js.kt create mode 100644 model/src/jvmMain/kotlin/dev/datlag/aniflow/model/PlatformExtendAny.jvm.kt create mode 100644 model/src/nativeMain/kotlin/dev/datlag/aniflow/model/PlatformExtendAny.native.kt diff --git a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/common/ExtendComponent.kt b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/common/ExtendComponent.kt index 0cb01d9..f65db05 100644 --- a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/common/ExtendComponent.kt +++ b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/common/ExtendComponent.kt @@ -6,6 +6,7 @@ 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 @@ -13,6 +14,8 @@ 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 @@ -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() + bs?.let { + nullableFirebaseInstance()?.crashlytics?.bs(it) + } } } diff --git a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/common/ExtendFirebase.kt b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/common/ExtendFirebase.kt new file mode 100644 index 0000000..da6012a --- /dev/null +++ b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/common/ExtendFirebase.kt @@ -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 +) \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index bf3deff..d1a6dbc 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -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" diff --git a/model/src/commonMain/kotlin/dev/datlag/aniflow/model/PlatformExtendAny.kt b/model/src/commonMain/kotlin/dev/datlag/aniflow/model/PlatformExtendAny.kt new file mode 100644 index 0000000..3df64f4 --- /dev/null +++ b/model/src/commonMain/kotlin/dev/datlag/aniflow/model/PlatformExtendAny.kt @@ -0,0 +1,5 @@ +package dev.datlag.aniflow.model + +import kotlin.reflect.KClass + +expect val KClass<*>.name: String \ No newline at end of file diff --git a/model/src/jsMain/kotlin/dev/datlag/aniflow/model/PlatformExtendAny.js.kt b/model/src/jsMain/kotlin/dev/datlag/aniflow/model/PlatformExtendAny.js.kt new file mode 100644 index 0000000..bd77358 --- /dev/null +++ b/model/src/jsMain/kotlin/dev/datlag/aniflow/model/PlatformExtendAny.js.kt @@ -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() \ No newline at end of file diff --git a/model/src/jvmMain/kotlin/dev/datlag/aniflow/model/PlatformExtendAny.jvm.kt b/model/src/jvmMain/kotlin/dev/datlag/aniflow/model/PlatformExtendAny.jvm.kt new file mode 100644 index 0000000..338d677 --- /dev/null +++ b/model/src/jvmMain/kotlin/dev/datlag/aniflow/model/PlatformExtendAny.jvm.kt @@ -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() \ No newline at end of file diff --git a/model/src/nativeMain/kotlin/dev/datlag/aniflow/model/PlatformExtendAny.native.kt b/model/src/nativeMain/kotlin/dev/datlag/aniflow/model/PlatformExtendAny.native.kt new file mode 100644 index 0000000..2e2202f --- /dev/null +++ b/model/src/nativeMain/kotlin/dev/datlag/aniflow/model/PlatformExtendAny.native.kt @@ -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() \ No newline at end of file