Skip to content

Commit

Permalink
chore: add chucker for in app network activity logging
Browse files Browse the repository at this point in the history
  • Loading branch information
hyuwah committed Sep 19, 2023
1 parent d1da00a commit 56a9029
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ dependencies {

debugImplementation(libs.bundles.debug.compose)

debugImplementation(libs.chucker)
releaseImplementation(libs.chucker.noop)

testImplementation(libs.junit)
testImplementation(libs.mockk)
androidTestImplementation(libs.androidx.test.ext.junit)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package dev.hyuwah.imusic.core.common.di

import android.app.Application
import com.chuckerteam.chucker.api.ChuckerInterceptor
import com.skydoves.sandwich.adapters.ApiResponseCallAdapterFactory
import com.squareup.moshi.Moshi
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
Expand All @@ -21,13 +23,14 @@ class CommonProviderModule {

@Provides
@Singleton
fun provideOkHttpClient(): OkHttpClient {
fun provideOkHttpClient(app: Application): OkHttpClient {
return OkHttpClient.Builder().apply {
if (BuildConfig.DEBUG) {
addInterceptor(HttpLoggingInterceptor().apply {
setLevel(HttpLoggingInterceptor.Level.BODY)
})
}
addInterceptor(ChuckerInterceptor(app.applicationContext))
}.build()
}

Expand Down
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ activity-compose = "1.7.2"
agp = "8.1.1"
androidx-hilt = "1.0.0"
androidx-test-ext-junit = "1.1.5"
chucker = "4.0.0"
compose-bom = "2023.06.01"
compose-compiler = "1.5.2"
core-ktx = "1.10.1"
Expand Down Expand Up @@ -63,6 +64,8 @@ moshi = { module = "com.squareup.moshi:moshi-kotlin", version.ref = "moshi" }
okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
okhttp-logging-interceptor = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "okhttp" }
sandwhich = { module = "com.github.skydoves:sandwich", version.ref = "sandwhich" }
chucker = { module = "com.github.chuckerteam.chucker:library", version.ref = "chucker" }
chucker-noop = { module = "com.github.chuckerteam.chucker:library-no-op", version.ref = "chucker" }

mockk = { module = "io.mockk:mockk", version.ref = "mockk" }
junit = { group = "junit", name = "junit", version.ref = "junit" }
Expand Down

0 comments on commit 56a9029

Please sign in to comment.