All Downloads are FREE. Search and download functionalities are using the official Maven repository.

androidMain.io.github.landrynorris.analytiks.firebase.FirebaseAnalyticsLogger.kt Maven / Gradle / Ivy

There is a newer version: 0.1.0
Show newest version
package io.github.landrynorris.analytiks.firebase

import android.os.Bundle
import com.google.firebase.analytics.ktx.analytics
import com.google.firebase.analytics.ktx.logEvent
import com.google.firebase.ktx.Firebase
import io.github.landrynorris.analytiks.AnalytiksLogger

actual class FirebaseAnalyticsLogger: AnalytiksLogger {
    private val firebase by lazy {
        Firebase.analytics
    }

    actual override fun logEvent(name: String, extras: Map) {
        firebase.logEvent(name) {
            extras.entries.forEach {
                when(it.value) {
                    is Double -> param(it.key, it.value as Double)
                    is Long -> param(it.key, it.value as Long)
                    is Bundle -> param(it.key, it.value as Bundle)
                    else -> param(it.key, it.value.toString())
                }
            }
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy