Skip to content

Commit e34d954

Browse files
authored
Merge pull request #21 from kkostov/some-upgrades
Ktor Client and Gradle Plugin Updates
2 parents f5c6a46 + 21090b0 commit e34d954

File tree

5 files changed

+25
-17
lines changed

5 files changed

+25
-17
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ buildscript {
66
maven { url 'https://jitpack.io' }
77
}
88
dependencies {
9-
classpath 'com.android.tools.build:gradle:7.4.2'
10-
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21'
9+
classpath 'com.android.tools.build:gradle:8.2.2'
10+
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.22'
1111

1212
// NOTE: Do not place your application dependencies here; they belong
1313
// in the individual module build.gradle files

gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ android.enableJetifier=true
2121
kotlin.code.style=official
2222

2323
-Dorg.gradle.warning.mode=all
24+
android.defaults.buildfeatures.buildconfig=true
25+
android.nonTransitiveRClass=false
26+
android.nonFinalResIds=false
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

lib/build.gradle

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ plugins {
66
}
77

88
android {
9-
compileSdk 31
9+
compileSdk 33
1010

1111
defaultConfig {
1212
minSdk 21
13-
targetSdk 31
13+
targetSdk 33
1414

1515
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1616
consumerProguardFiles "consumer-rules.pro"
@@ -37,7 +37,7 @@ android {
3737
namespace 'com.telemetrydeck.sdk'
3838
}
3939

40-
def ktor_version = '1.6.7'
40+
def ktor_version = '2.3.7'
4141
def logback_version = '1.2.10'
4242
def kotlinx_coroutines_version = '1.6.0'
4343
dependencies {
@@ -50,8 +50,10 @@ dependencies {
5050
implementation "io.ktor:ktor-client-cio:$ktor_version"
5151
// HTTP Serialization
5252
implementation "io.ktor:ktor-client-serialization:$ktor_version"
53-
implementation "org.jetbrains.kotlinx:kotlinx-serialization-properties:1.3.2"
54-
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2"
53+
implementation "io.ktor:ktor-client-content-negotiation:$ktor_version"
54+
implementation "io.ktor:ktor-serialization-kotlinx-json:$ktor_version"
55+
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1"
56+
implementation "org.jetbrains.kotlinx:kotlinx-serialization-properties:1.5.1"
5557
// HTTP Logging
5658
implementation "ch.qos.logback:logback-classic:$logback_version"
5759
implementation "io.ktor:ktor-client-logging:$ktor_version"

lib/src/main/java/com/telemetrydeck/sdk/TelemetryClient.kt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ package com.telemetrydeck.sdk
22

33
import io.ktor.client.*
44
import io.ktor.client.engine.cio.*
5-
import io.ktor.client.features.*
6-
import io.ktor.client.features.json.*
7-
import io.ktor.client.features.logging.*
5+
import io.ktor.client.plugins.DefaultRequest
6+
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
7+
import io.ktor.client.plugins.logging.DEFAULT
8+
import io.ktor.client.plugins.logging.LogLevel
9+
import io.ktor.client.plugins.logging.Logger
10+
import io.ktor.client.plugins.logging.Logging
811
import io.ktor.client.request.*
9-
import io.ktor.client.statement.*
1012
import io.ktor.http.*
13+
import io.ktor.serialization.kotlinx.json.json
1114
import java.net.URL
1215
import java.util.*
1316

@@ -16,7 +19,9 @@ import java.util.*
1619
*/
1720
internal class TelemetryClient(private val telemetryAppID: UUID, private val apiBaseURL: URL, private val showDebugLogs: Boolean, private val debugLogger: DebugLogger?) {
1821
private val client: HttpClient = HttpClient(CIO) {
19-
install(JsonFeature)
22+
install(ContentNegotiation) {
23+
json()
24+
}
2025
if (showDebugLogs && debugLogger != null) {
2126
install(Logging) {
2227
logger = Logger.DEFAULT
@@ -32,10 +37,8 @@ internal class TelemetryClient(private val telemetryAppID: UUID, private val api
3237
suspend fun send(
3338
signals: List<Signal>
3439
) {
35-
val response: HttpResponse = client.request {
36-
method = HttpMethod.Post
37-
url(getServiceUrl())
38-
body = signals
40+
val response = client.post(getServiceUrl()) {
41+
setBody(signals)
3942
}
4043
println(response.status)
4144
client.close()

0 commit comments

Comments
 (0)