diff --git a/README.md b/README.md index 790d1be..b20fe7d 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ The Kotlin SDK for TelemetryDeck is available from Maven Central and can be used ```groovy dependencies { - implementation 'com.telemetrydeck:kotlin-sdk:3.0.1' + implementation 'com.telemetrydeck:kotlin-sdk:3.0.3' } ``` diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index bfcbb13..349ad53 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -9,7 +9,6 @@ lifecycleRuntimeKtx = "2.8.6" activityCompose = "1.9.3" composeBom = "2024.10.00" ktor = "3.0.0" -logback = "1.5.6" kotlinx = "1.7.3" coroutines = "1.9.0" vanniktech-publish = "0.30.0" @@ -25,22 +24,17 @@ androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" } androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" } androidx-lifecycle-process = { group = "androidx.lifecycle", name = "lifecycle-process", version.ref = "lifecycleRuntimeKtx" } -androidx-lifecycle-extensions = { group = "androidx.lifecycle", name = "lifecycle-extensions", version.ref = "lifecycleRuntimeKtx" } androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" } androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" } -androidx-ui = { group = "androidx.compose.ui", name = "ui" } -androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" } androidx-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" } -androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" } androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" } androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" } -androidx-material3 = { group = "androidx.compose.material3", name = "material3" } androidx-arch-core = {group = "androidx.arch.core", name = "core-testing", version = "2.2.0" } ktor-client-core = { group = "io.ktor", name = "ktor-client-core", version.ref = "ktor" } ktor-client-okhttp = { group = "io.ktor", name = "ktor-client-okhttp", version.ref = "ktor" } +ktor-client-logging = { group = "io.ktor", name = "ktor-client-logging", version.ref = "ktor" } ktor-content-negotiation = { group = "io.ktor", name = "ktor-client-content-negotiation", version.ref = "ktor" } ktor-serialization-kotlinx-json = { group = "io.ktor", name = "ktor-serialization-kotlinx-json", version.ref = "ktor" } -logback = { group = "ch.qos.logback", name = "logback-classic", version.ref = "logback" } kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinx" } kotlinx-serialization-properties = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-properties", version.ref = "kotlinx" } kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "coroutines" } diff --git a/lib/build.gradle.kts b/lib/build.gradle.kts index 71cdd91..e682944 100644 --- a/lib/build.gradle.kts +++ b/lib/build.gradle.kts @@ -81,6 +81,7 @@ dependencies { implementation(libs.ktor.client.okhttp) implementation(libs.kotlinx.serialization.json) implementation(libs.kotlinx.serialization.properties) + implementation(libs.ktor.client.logging) testImplementation(libs.junit) @@ -100,7 +101,7 @@ dependencies { } mavenPublishing { - coordinates("com.telemetrydeck", "kotlin-sdk", "3.0.2") + coordinates("com.telemetrydeck", "kotlin-sdk", "3.0.3") pom { name = "TelemetryDeck SDK" diff --git a/lib/src/main/java/com/telemetrydeck/sdk/TelemetryClient.kt b/lib/src/main/java/com/telemetrydeck/sdk/TelemetryClient.kt index 3508235..3c96101 100644 --- a/lib/src/main/java/com/telemetrydeck/sdk/TelemetryClient.kt +++ b/lib/src/main/java/com/telemetrydeck/sdk/TelemetryClient.kt @@ -4,6 +4,9 @@ import io.ktor.client.HttpClient import io.ktor.client.engine.okhttp.OkHttp import io.ktor.client.plugins.DefaultRequest import io.ktor.client.plugins.contentnegotiation.ContentNegotiation +import io.ktor.client.plugins.logging.LogLevel +import io.ktor.client.plugins.logging.Logger +import io.ktor.client.plugins.logging.Logging import io.ktor.client.request.header import io.ktor.client.request.post import io.ktor.client.request.setBody @@ -11,7 +14,6 @@ import io.ktor.http.ContentType import io.ktor.http.HttpHeaders import io.ktor.serialization.kotlinx.json.json import java.net.URL -import java.util.UUID /** * The HTTP client to communicate with TelemetryDeck's API @@ -25,6 +27,17 @@ internal class TelemetryClient( install(ContentNegotiation) { json() } + if (showDebugLogs && debugLogger != null) { + install(Logging) { + logger = object : Logger { + override fun log(message: String) { + debugLogger.debug(message) + } + } + level = LogLevel.ALL // Log request, response, headers, and body + } + } + install(DefaultRequest) { header(HttpHeaders.ContentType, ContentType.Application.Json) header(HttpHeaders.Accept, ContentType.Application.Json)