diff --git a/analytics/build.gradle.kts b/analytics/build.gradle.kts
index 45061d96b..48ed08fbf 100644
--- a/analytics/build.gradle.kts
+++ b/analytics/build.gradle.kts
@@ -8,7 +8,8 @@ android {
}
kotlin {
- sourceSets.commonMain.dependencies {
- implementation(libs.gitlive.firebase.analytics)
+ sourceSets.androidMain.dependencies {
+ implementation(dependencies.platform(libs.google.firebase.bom))
+ implementation(libs.google.firebase.analytics)
}
}
diff --git a/analytics/src/androidMain/kotlin/io/ashdavies/analytics/FirebaseAnalytics.android.kt b/analytics/src/androidMain/kotlin/io/ashdavies/analytics/FirebaseAnalytics.android.kt
new file mode 100644
index 000000000..7d56e5348
--- /dev/null
+++ b/analytics/src/androidMain/kotlin/io/ashdavies/analytics/FirebaseAnalytics.android.kt
@@ -0,0 +1,9 @@
+package io.ashdavies.analytics
+
+import com.google.firebase.analytics.ktx.analytics
+import com.google.firebase.analytics.logEvent
+import com.google.firebase.ktx.Firebase
+
+internal actual val firebaseAnalytics = RemoteAnalytics { name, block ->
+ Firebase.analytics.logEvent(name) { block(ParametersBuilder(::param)) }
+}
diff --git a/analytics/src/androidMain/kotlin/io/ashdavies/analytics/FirebaseAnalytics.kt b/analytics/src/androidMain/kotlin/io/ashdavies/analytics/FirebaseAnalytics.kt
deleted file mode 100644
index a6b1f715b..000000000
--- a/analytics/src/androidMain/kotlin/io/ashdavies/analytics/FirebaseAnalytics.kt
+++ /dev/null
@@ -1,8 +0,0 @@
-package io.ashdavies.analytics
-
-import dev.gitlive.firebase.Firebase
-import dev.gitlive.firebase.analytics.analytics
-
-internal actual val firebaseAnalytics = RemoteAnalytics { name, parameters ->
- Firebase.analytics.logEvent(name, parameters)
-}
diff --git a/analytics/src/commonMain/kotlin/io/ashdavies/analytics/ClickListener.kt b/analytics/src/commonMain/kotlin/io/ashdavies/analytics/ClickListener.kt
index 036a9e03b..50f748b3a 100644
--- a/analytics/src/commonMain/kotlin/io/ashdavies/analytics/ClickListener.kt
+++ b/analytics/src/commonMain/kotlin/io/ashdavies/analytics/ClickListener.kt
@@ -27,3 +27,12 @@ public fun
OnClickWith(
analytics.logEvent(name, parameters)
action(it)
}
+
+private fun RemoteAnalytics.logEvent(
+ name: String,
+ parameters: Map?,
+) = logEvent(name) {
+ parameters?.forEach { (key, value) ->
+ param(key, value.toString())
+ }
+}
diff --git a/analytics/src/commonMain/kotlin/io/ashdavies/analytics/LocalAnalytics.kt b/analytics/src/commonMain/kotlin/io/ashdavies/analytics/LocalAnalytics.kt
index 79fc90fa4..d6de8394b 100644
--- a/analytics/src/commonMain/kotlin/io/ashdavies/analytics/LocalAnalytics.kt
+++ b/analytics/src/commonMain/kotlin/io/ashdavies/analytics/LocalAnalytics.kt
@@ -3,6 +3,5 @@ package io.ashdavies.analytics
import androidx.compose.runtime.ProvidableCompositionLocal
import androidx.compose.runtime.staticCompositionLocalOf
-public val LocalAnalytics: ProvidableCompositionLocal = staticCompositionLocalOf {
- RemoteAnalytics { name, parameters -> firebaseAnalytics.logEvent(name, parameters) }
-}
+public val LocalAnalytics: ProvidableCompositionLocal =
+ staticCompositionLocalOf { firebaseAnalytics }
diff --git a/analytics/src/commonMain/kotlin/io/ashdavies/analytics/RemoteAnalytics.kt b/analytics/src/commonMain/kotlin/io/ashdavies/analytics/RemoteAnalytics.kt
index a37c10564..ebf41b9fe 100644
--- a/analytics/src/commonMain/kotlin/io/ashdavies/analytics/RemoteAnalytics.kt
+++ b/analytics/src/commonMain/kotlin/io/ashdavies/analytics/RemoteAnalytics.kt
@@ -1,5 +1,9 @@
package io.ashdavies.analytics
public fun interface RemoteAnalytics {
- public fun logEvent(name: String, parameters: Map?)
+ public fun logEvent(name: String, block: ParametersBuilder.() -> Unit)
+}
+
+public fun interface ParametersBuilder {
+ public fun param(key: String, value: String)
}
diff --git a/analytics/src/jvmMain/kotlin/io/ashdavies/analytics/FirebaseAnalytics.kt b/analytics/src/jvmMain/kotlin/io/ashdavies/analytics/FirebaseAnalytics.jvm.kt
similarity index 100%
rename from analytics/src/jvmMain/kotlin/io/ashdavies/analytics/FirebaseAnalytics.kt
rename to analytics/src/jvmMain/kotlin/io/ashdavies/analytics/FirebaseAnalytics.jvm.kt
diff --git a/conferences-app/build.gradle.kts b/conferences-app/build.gradle.kts
index 391cf194e..599d1eecd 100644
--- a/conferences-app/build.gradle.kts
+++ b/conferences-app/build.gradle.kts
@@ -63,10 +63,6 @@ android {
}
}
- compileOptions {
- isCoreLibraryDesugaringEnabled = true
- }
-
defaultConfig {
val versionCode by stringProperty { _, value ->
versionCode = value?.toInt() ?: 1
@@ -76,8 +72,6 @@ android {
}
dependencies {
- coreLibraryDesugaring(libs.android.tools.desugarjdk)
-
screenshotTestImplementation(compose.material3)
screenshotTestImplementation(compose.uiTooling)
@@ -148,8 +142,6 @@ kotlin {
implementation(libs.compose.adaptive.layout)
implementation(libs.compose.adaptive.navigation)
implementation(libs.compose.window.size)
- implementation(libs.gitlive.firebase.app)
- implementation(libs.gitlive.firebase.config)
implementation(libs.kotlinx.collections.immutable)
implementation(libs.kotlinx.datetime)
implementation(libs.kotlinx.serialization.core)
diff --git a/conferences-app/src/jvmMain/kotlin/io/ashdavies/party/Main.kt b/conferences-app/src/jvmMain/kotlin/io/ashdavies/party/Main.kt
index d57aa3154..c9bbd1b3e 100644
--- a/conferences-app/src/jvmMain/kotlin/io/ashdavies/party/Main.kt
+++ b/conferences-app/src/jvmMain/kotlin/io/ashdavies/party/Main.kt
@@ -15,7 +15,7 @@ import com.slack.circuit.overlay.ContentWithOverlays
import io.ashdavies.analytics.LocalAnalytics
import io.ashdavies.analytics.RemoteAnalytics
import io.ashdavies.check.ProvideAppCheckToken
-import io.ashdavies.config.LocalConfigValue
+import io.ashdavies.config.Default
import io.ashdavies.config.LocalRemoteConfig
import io.ashdavies.config.RemoteConfig
import io.ashdavies.content.PlatformContext
@@ -24,7 +24,6 @@ import io.ashdavies.http.publicStorage
import io.ashdavies.io.resolveCacheDir
import io.ashdavies.material.dynamicColorScheme
import io.ashdavies.party.config.rememberCircuit
-import io.ashdavies.party.firebase.EmptyLocalConfigValue
import io.ashdavies.party.home.HomeScreen
import io.ashdavies.party.material.ProvideLocalWindowSizeClass
import io.ashdavies.playground.BuildConfig
@@ -106,12 +105,7 @@ private fun ConferencesApp(
private fun ProvideRemoteLocals(content: @Composable () -> Unit) {
CompositionLocalProvider(
LocalAnalytics provides RemoteAnalytics { _, _ -> },
- LocalRemoteConfig provides object : RemoteConfig {
- override suspend fun getValue(
- key: String,
- transform: (LocalConfigValue) -> T,
- ): T = transform(EmptyLocalConfigValue)
- },
+ LocalRemoteConfig provides RemoteConfig.Default,
content = content,
)
}
diff --git a/conferences-app/src/jvmMain/kotlin/io/ashdavies/party/firebase/EmptyLocalConfigValue.kt b/conferences-app/src/jvmMain/kotlin/io/ashdavies/party/firebase/EmptyLocalConfigValue.kt
deleted file mode 100644
index b0b5cffa0..000000000
--- a/conferences-app/src/jvmMain/kotlin/io/ashdavies/party/firebase/EmptyLocalConfigValue.kt
+++ /dev/null
@@ -1,11 +0,0 @@
-package io.ashdavies.party.firebase
-
-import io.ashdavies.config.LocalConfigValue
-
-internal object EmptyLocalConfigValue : LocalConfigValue {
- override fun asLong() = 0L
- override fun asDouble() = 0.0
- override fun asString() = ""
- override fun asByteArray() = byteArrayOf()
- override fun asBoolean() = false
-}
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index fb3062474..1a8622ffe 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -7,7 +7,6 @@ cash-sqldelight = "2.0.2"
coil-kt = "3.0.4"
compose-adaptive = "1.0.1"
compose-plugin = "1.7.1"
-gitlive-firebase = "2.1.0"
google-accompanist = "0.36.0"
google-android = "8.7.3"
google-maps-compose = "4.3.2"
@@ -22,7 +21,6 @@ slack-circuit = "0.25.0"
[libraries]
ajalt-clikt = "com.github.ajalt.clikt:clikt:5.0.2"
-android-tools-desugarjdk = "com.android.tools:desugar_jdk_libs:2.1.3"
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity" }
androidx-annotation = "androidx.annotation:annotation:1.9.1"
@@ -45,10 +43,6 @@ compose-window-size = { module = "org.jetbrains.compose.material3:material3-wind
detekt-compose = "io.nlopez.compose.rules:detekt:0.4.22"
fusesource-jansi = "org.fusesource.jansi:jansi:2.4.1"
-gitlive-firebase-analytics = { module = "dev.gitlive:firebase-analytics", version.ref = "gitlive-firebase" }
-gitlive-firebase-app = { module = "dev.gitlive:firebase-app", version.ref = "gitlive-firebase" }
-gitlive-firebase-config = { module = "dev.gitlive:firebase-config", version.ref = "gitlive-firebase" }
-
google-accompanist-flowlayout = { module = "com.google.accompanist:accompanist-flowlayout", version.ref = "google-accompanist" }
google-accompanist-permissions = { module = "com.google.accompanist:accompanist-permissions", version.ref = "google-accompanist" }
@@ -60,7 +54,9 @@ google-auth-http = "com.google.auth:google-auth-library-oauth2-http:1.30.0"
google-firebase-admin = "com.google.firebase:firebase-admin:9.4.2"
google-firebase-appcheck-playintegrity = { module = "com.google.firebase:firebase-appcheck-playintegrity" }
+google-firebase-analytics = { module = "com.google.firebase:firebase-analytics" }
google-firebase-bom = "com.google.firebase:firebase-bom:33.7.0"
+google-firebase-config = { module = "com.google.firebase:firebase-config" }
google-firebase-crashlytics = { module = "com.google.firebase:firebase-crashlytics" }
google-guava-jre = "com.google.guava:guava:33.3.1-jre"
diff --git a/remote-config/build.gradle.kts b/remote-config/build.gradle.kts
index 4319bcc34..d1a711c4b 100644
--- a/remote-config/build.gradle.kts
+++ b/remote-config/build.gradle.kts
@@ -4,19 +4,12 @@ plugins {
}
android {
- compileOptions {
- isCoreLibraryDesugaringEnabled = true
- }
-
- dependencies {
- coreLibraryDesugaring(libs.android.tools.desugarjdk)
- }
-
namespace = "io.ashdavies.config"
}
kotlin {
- sourceSets.commonMain.dependencies {
- implementation(libs.gitlive.firebase.config)
+ sourceSets.androidMain.dependencies {
+ implementation(dependencies.platform(libs.google.firebase.bom))
+ implementation(libs.google.firebase.config)
}
}
diff --git a/remote-config/src/androidMain/kotlin/io/ashdavies/config/FirebaseRemoteConfig.android.kt b/remote-config/src/androidMain/kotlin/io/ashdavies/config/FirebaseRemoteConfig.android.kt
new file mode 100644
index 000000000..81503c084
--- /dev/null
+++ b/remote-config/src/androidMain/kotlin/io/ashdavies/config/FirebaseRemoteConfig.android.kt
@@ -0,0 +1,34 @@
+package io.ashdavies.config
+
+import com.google.firebase.ktx.Firebase
+import com.google.firebase.remoteconfig.FirebaseRemoteConfigValue
+import com.google.firebase.remoteconfig.ktx.remoteConfig
+import com.google.firebase.remoteconfig.ktx.remoteConfigSettings
+
+private const val ONE_MINUTE_IN_SECONDS = 3600L
+
+@Suppress("ObjectPropertyName")
+private val _firebaseRemoteConfig by lazy {
+ Firebase.remoteConfig.apply {
+ val configSettings = remoteConfigSettings {
+ minimumFetchIntervalInSeconds = ONE_MINUTE_IN_SECONDS
+ }
+
+ setConfigSettingsAsync(configSettings)
+ fetchAndActivate()
+ }
+}
+
+internal actual val firebaseRemoteConfig = object : RemoteConfig {
+ override suspend fun getValue(key: String, transform: (RemoteConfigValue) -> T): T {
+ return transform(remoteConfigValue(_firebaseRemoteConfig.getValue(key)))
+ }
+}
+
+private fun remoteConfigValue(value: FirebaseRemoteConfigValue) = object : RemoteConfigValue {
+ override fun asLong(): Long = value.asLong()
+ override fun asDouble(): Double = value.asDouble()
+ override fun asString(): String = value.asString()
+ override fun asByteArray(): ByteArray = value.asByteArray()
+ override fun asBoolean(): Boolean = value.asBoolean()
+}
diff --git a/remote-config/src/commonMain/kotlin/io/ashdavies/config/FirebaseRemoteConfig.kt b/remote-config/src/commonMain/kotlin/io/ashdavies/config/FirebaseRemoteConfig.kt
new file mode 100644
index 000000000..d04e1e9d6
--- /dev/null
+++ b/remote-config/src/commonMain/kotlin/io/ashdavies/config/FirebaseRemoteConfig.kt
@@ -0,0 +1,3 @@
+package io.ashdavies.config
+
+internal expect val firebaseRemoteConfig: RemoteConfig
diff --git a/remote-config/src/commonMain/kotlin/io/ashdavies/config/LazyRemoteConfig.kt b/remote-config/src/commonMain/kotlin/io/ashdavies/config/LazyRemoteConfig.kt
deleted file mode 100644
index 05932048d..000000000
--- a/remote-config/src/commonMain/kotlin/io/ashdavies/config/LazyRemoteConfig.kt
+++ /dev/null
@@ -1,19 +0,0 @@
-package io.ashdavies.config
-
-import dev.gitlive.firebase.Firebase
-import dev.gitlive.firebase.remoteconfig.FirebaseRemoteConfig
-import dev.gitlive.firebase.remoteconfig.FirebaseRemoteConfigValue
-import dev.gitlive.firebase.remoteconfig.remoteConfig
-
-private val FirebaseRemoteConfig by lazy { Firebase.remoteConfig }
-
-internal class LazyRemoteConfig : RemoteConfig {
- override suspend fun getValue(key: String, transform: (LocalConfigValue) -> T): T {
- return transform(LocalConfigValue(FirebaseRemoteConfig.getInitializedValue(key)))
- }
-}
-
-private suspend fun FirebaseRemoteConfig.getInitializedValue(key: String): FirebaseRemoteConfigValue {
- ensureInitialized()
- return getValue(key)
-}
diff --git a/remote-config/src/commonMain/kotlin/io/ashdavies/config/LocalConfigValue.kt b/remote-config/src/commonMain/kotlin/io/ashdavies/config/LocalConfigValue.kt
deleted file mode 100644
index e7d6eb477..000000000
--- a/remote-config/src/commonMain/kotlin/io/ashdavies/config/LocalConfigValue.kt
+++ /dev/null
@@ -1,21 +0,0 @@
-package io.ashdavies.config
-
-import dev.gitlive.firebase.remoteconfig.FirebaseRemoteConfigValue
-
-public interface LocalConfigValue {
- public fun asLong(): Long
- public fun asDouble(): Double
- public fun asString(): String
- public fun asByteArray(): ByteArray
- public fun asBoolean(): Boolean
-}
-
-internal fun LocalConfigValue(value: FirebaseRemoteConfigValue): LocalConfigValue {
- return object : LocalConfigValue {
- override fun asLong(): Long = value.asLong()
- override fun asDouble(): Double = value.asDouble()
- override fun asString(): String = value.asString()
- override fun asByteArray(): ByteArray = value.asByteArray()
- override fun asBoolean(): Boolean = value.asBoolean()
- }
-}
diff --git a/remote-config/src/commonMain/kotlin/io/ashdavies/config/LocalRemoteConfig.kt b/remote-config/src/commonMain/kotlin/io/ashdavies/config/LocalRemoteConfig.kt
index 9bd3867b9..43c3e76b7 100644
--- a/remote-config/src/commonMain/kotlin/io/ashdavies/config/LocalRemoteConfig.kt
+++ b/remote-config/src/commonMain/kotlin/io/ashdavies/config/LocalRemoteConfig.kt
@@ -4,5 +4,5 @@ import androidx.compose.runtime.ProvidableCompositionLocal
import androidx.compose.runtime.staticCompositionLocalOf
public val LocalRemoteConfig: ProvidableCompositionLocal = staticCompositionLocalOf {
- LazyRemoteConfig()
+ firebaseRemoteConfig
}
diff --git a/remote-config/src/commonMain/kotlin/io/ashdavies/config/RemoteConfig.kt b/remote-config/src/commonMain/kotlin/io/ashdavies/config/RemoteConfig.kt
index 0c5a982fe..e8eaba1b2 100644
--- a/remote-config/src/commonMain/kotlin/io/ashdavies/config/RemoteConfig.kt
+++ b/remote-config/src/commonMain/kotlin/io/ashdavies/config/RemoteConfig.kt
@@ -1,7 +1,8 @@
package io.ashdavies.config
public interface RemoteConfig {
- public suspend fun getValue(key: String, transform: (LocalConfigValue) -> T): T
+ public suspend fun getValue(key: String, transform: (RemoteConfigValue) -> T): T
+ public companion object
}
public suspend fun RemoteConfig.getBoolean(key: String): Boolean {
diff --git a/remote-config/src/commonMain/kotlin/io/ashdavies/config/RemoteConfigValue.kt b/remote-config/src/commonMain/kotlin/io/ashdavies/config/RemoteConfigValue.kt
new file mode 100644
index 000000000..564b108f1
--- /dev/null
+++ b/remote-config/src/commonMain/kotlin/io/ashdavies/config/RemoteConfigValue.kt
@@ -0,0 +1,9 @@
+package io.ashdavies.config
+
+public interface RemoteConfigValue {
+ public fun asLong(): Long
+ public fun asDouble(): Double
+ public fun asString(): String
+ public fun asByteArray(): ByteArray
+ public fun asBoolean(): Boolean
+}
diff --git a/remote-config/src/jvmMain/kotlin/io/ashdavies/config/FirebaseRemoteConfig.jvm.kt b/remote-config/src/jvmMain/kotlin/io/ashdavies/config/FirebaseRemoteConfig.jvm.kt
new file mode 100644
index 000000000..af05509d8
--- /dev/null
+++ b/remote-config/src/jvmMain/kotlin/io/ashdavies/config/FirebaseRemoteConfig.jvm.kt
@@ -0,0 +1,7 @@
+package io.ashdavies.config
+
+internal actual val firebaseRemoteConfig = object : RemoteConfig {
+ override suspend fun getValue(key: String, transform: (RemoteConfigValue) -> T): T {
+ TODO("Not yet implemented")
+ }
+}
diff --git a/remote-config/src/jvmMain/kotlin/io/ashdavies/config/RemoteConfig.jvm.kt b/remote-config/src/jvmMain/kotlin/io/ashdavies/config/RemoteConfig.jvm.kt
new file mode 100644
index 000000000..2ca6196eb
--- /dev/null
+++ b/remote-config/src/jvmMain/kotlin/io/ashdavies/config/RemoteConfig.jvm.kt
@@ -0,0 +1,18 @@
+package io.ashdavies.config
+
+public val RemoteConfig.Companion.Default: RemoteConfig
+ get() = emptyRemoteConfig
+
+private val emptyRemoteConfig = object : RemoteConfig {
+ override suspend fun getValue(key: String, transform: (RemoteConfigValue) -> T): T {
+ return transform(EmptyLocalConfigValue)
+ }
+}
+
+private object EmptyLocalConfigValue : RemoteConfigValue {
+ override fun asLong() = 0L
+ override fun asDouble() = 0.0
+ override fun asString() = ""
+ override fun asByteArray() = byteArrayOf()
+ override fun asBoolean() = false
+}