![JAR search and dependency download from the Maven repository](/logo.png)
com.samuelbirocchi.chatbase.ChatbaseClient.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of chatbase-sdk Show documentation
Show all versions of chatbase-sdk Show documentation
A SDK made in Kotlin to send analytics to chatbase
The newest version!
package com.samuelbirocchi.chatbase
import com.samuelbirocchi.chatbase.model.ChatbaseRequest
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.github.kittinunf.fuel.httpPost
import mu.KotlinLogging
class ChatbaseClient {
private val logger = KotlinLogging.logger { }
private val objectMapper = jacksonObjectMapper()
fun sendAnalytics(chatbaseRequest: ChatbaseRequest) {
logger.debug { "Chatbase analytics body: $chatbaseRequest" }
"https://chatbase.com/api/messages".httpPost()
.body(objectMapper.writeValueAsBytes(chatbaseRequest))
.responseString { _, _, result ->
result.fold({
logger.info { "Analytic sent to Chatbase" }
}, {
logger.error(it.exception) { "Error sending analytic to chatbase: ${String(it.errorData)}" }
})
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy