Skip to content

Instantly share code, notes, and snippets.

@AndSky90
Created November 16, 2019 13:44
Show Gist options
  • Save AndSky90/86b76068e60ac815142ffb01c70eda9a to your computer and use it in GitHub Desktop.
Save AndSky90/86b76068e60ac815142ffb01c70eda9a to your computer and use it in GitHub Desktop.
FirebaseAnalyticsProvider
object FirebaseAnalyticsProvider {
const val AUTH_EVENT = "AUTH_EVENT" //событие при авторизации
const val USER_EVENT = "USER_EVENT" //событие при запросе модели пользователя
const val TOKEN_EVENT = "TOKEN_EVENT" //событие при запросе токена
const val TENANT_EVENT = "TENANT_EVENT" // событие при работе с тенантоами
const val CONTENT_EVENT = "CONTENT_EVENT" // ошибка API получения данных
@Suppress("UNUSED")
const val PARAM_CANCELLED_BY_USER = "CANCELLED_BY_USER"
const val PARAM_MESSAGE = "MESSAGE"
const val PARAM_ERROR = "ERROR"
private var analytics: FirebaseAnalytics? = null
fun init(instance: FirebaseAnalytics){
analytics = instance
}
fun notify(
message: String, //message itself
param: String, //const val PARAM_*
event: String //const val EVENT_*
){
val bundle = Bundle()
bundle.putString(param, message)
analytics?.logEvent(event, bundle)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment