Updated on 2026-08-14
This commit is contained in:
commit
03aa966c1d
10 changed files with 39 additions and 38 deletions
|
|
@ -120,13 +120,6 @@ dependencies {
|
||||||
implementation(deps.appsflyer)
|
implementation(deps.appsflyer)
|
||||||
implementation(deps.amplitude)
|
implementation(deps.amplitude)
|
||||||
implementation(deps.kotsonGson)
|
implementation(deps.kotsonGson)
|
||||||
//TODO: refactoring: remove it when all network services moved to the datasource module
|
|
||||||
implementation(deps.retrofit)
|
|
||||||
implementation(deps.retrofit.moshi)
|
|
||||||
implementation(deps.moshi)
|
|
||||||
implementation(deps.moshi.kotlin)
|
|
||||||
implementation(deps.okHttp)
|
|
||||||
implementation(deps.okHttp.logging)
|
|
||||||
implementation(deps.zendesk.chat)
|
implementation(deps.zendesk.chat)
|
||||||
implementation(deps.zendesk.messaging)
|
implementation(deps.zendesk.messaging)
|
||||||
implementation(deps.spongecastle.core)
|
implementation(deps.spongecastle.core)
|
||||||
|
|
@ -145,6 +138,7 @@ dependencies {
|
||||||
implementation(deps.kotlin.serialization)
|
implementation(deps.kotlin.serialization)
|
||||||
implementation(deps.walletConnectCore)
|
implementation(deps.walletConnectCore)
|
||||||
implementation(deps.walletConnectWeb3)
|
implementation(deps.walletConnectWeb3)
|
||||||
|
implementation(deps.prettyLogger)
|
||||||
|
|
||||||
/** Testing libraries */
|
/** Testing libraries */
|
||||||
testImplementation(deps.test.junit)
|
testImplementation(deps.test.junit)
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import android.content.Context
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import coil.ImageLoader
|
import coil.ImageLoader
|
||||||
import coil.ImageLoaderFactory
|
import coil.ImageLoaderFactory
|
||||||
|
import com.orhanobut.logger.Logger
|
||||||
import com.tangem.Log
|
import com.tangem.Log
|
||||||
import com.tangem.LogFormat
|
import com.tangem.LogFormat
|
||||||
import com.tangem.blockchain.common.BlockchainSdkConfig
|
import com.tangem.blockchain.common.BlockchainSdkConfig
|
||||||
|
|
@ -14,6 +15,7 @@ import com.tangem.core.analytics.Analytics
|
||||||
import com.tangem.core.featuretoggle.manager.FeatureTogglesManager
|
import com.tangem.core.featuretoggle.manager.FeatureTogglesManager
|
||||||
import com.tangem.data.source.preferences.PreferencesDataSource
|
import com.tangem.data.source.preferences.PreferencesDataSource
|
||||||
import com.tangem.datasource.api.common.MoshiConverter
|
import com.tangem.datasource.api.common.MoshiConverter
|
||||||
|
import com.tangem.datasource.api.common.createNetworkLoggingInterceptor
|
||||||
import com.tangem.datasource.asset.AssetReader
|
import com.tangem.datasource.asset.AssetReader
|
||||||
import com.tangem.datasource.config.ConfigManager
|
import com.tangem.datasource.config.ConfigManager
|
||||||
import com.tangem.datasource.config.FeaturesLocalLoader
|
import com.tangem.datasource.config.FeaturesLocalLoader
|
||||||
|
|
@ -59,7 +61,6 @@ import com.tangem.tap.proxy.redux.DaggerGraphState
|
||||||
import com.tangem.wallet.BuildConfig
|
import com.tangem.wallet.BuildConfig
|
||||||
import dagger.hilt.android.HiltAndroidApp
|
import dagger.hilt.android.HiltAndroidApp
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import okhttp3.logging.HttpLoggingInterceptor
|
|
||||||
import org.rekotlin.Store
|
import org.rekotlin.Store
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
@ -173,7 +174,13 @@ class TapApplication : Application(), ImageLoaderFactory {
|
||||||
)
|
)
|
||||||
|
|
||||||
if (BuildConfig.DEBUG) {
|
if (BuildConfig.DEBUG) {
|
||||||
Timber.plant(Timber.DebugTree())
|
Timber.plant(
|
||||||
|
object : Timber.DebugTree() {
|
||||||
|
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
|
||||||
|
Logger.log(priority, tag, message, t)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
foregroundActivityObserver = ForegroundActivityObserver()
|
foregroundActivityObserver = ForegroundActivityObserver()
|
||||||
|
|
@ -192,7 +199,7 @@ class TapApplication : Application(), ImageLoaderFactory {
|
||||||
|
|
||||||
if (LogConfig.network.blockchainSdkNetwork) {
|
if (LogConfig.network.blockchainSdkNetwork) {
|
||||||
BlockchainSdkRetrofitBuilder.interceptors = listOf(
|
BlockchainSdkRetrofitBuilder.interceptors = listOf(
|
||||||
HttpLoggingInterceptor().apply { level = HttpLoggingInterceptor.Level.BODY },
|
createNetworkLoggingInterceptor(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@ import android.content.Context
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import coil.ImageLoader
|
import coil.ImageLoader
|
||||||
import coil.util.Logger
|
import coil.util.Logger
|
||||||
|
import com.tangem.datasource.api.common.createNetworkLoggingInterceptor
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import okhttp3.logging.HttpLoggingInterceptor
|
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
|
||||||
private const val COIL_LOG_TAG = "COIL"
|
private const val COIL_LOG_TAG = "COIL"
|
||||||
|
|
@ -18,14 +18,7 @@ fun createCoilImageLoader(context: Context, logEnabled: Boolean = false): ImageL
|
||||||
logger(CoilTimberLogger())
|
logger(CoilTimberLogger())
|
||||||
okHttpClient {
|
okHttpClient {
|
||||||
OkHttpClient.Builder()
|
OkHttpClient.Builder()
|
||||||
.addNetworkInterceptor(
|
.addNetworkInterceptor(createNetworkLoggingInterceptor())
|
||||||
HttpLoggingInterceptor { message ->
|
|
||||||
Timber.tag(COIL_LOG_TAG).d(message)
|
|
||||||
}
|
|
||||||
.apply {
|
|
||||||
level = HttpLoggingInterceptor.Level.BODY
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import com.tangem.blockchain.common.Blockchain
|
||||||
import com.tangem.common.card.EllipticCurve
|
import com.tangem.common.card.EllipticCurve
|
||||||
import com.tangem.common.extensions.guard
|
import com.tangem.common.extensions.guard
|
||||||
import com.tangem.core.analytics.Analytics
|
import com.tangem.core.analytics.Analytics
|
||||||
|
import com.tangem.datasource.api.common.createNetworkLoggingInterceptor
|
||||||
import com.tangem.domain.common.extensions.toNetworkId
|
import com.tangem.domain.common.extensions.toNetworkId
|
||||||
import com.tangem.domain.models.scan.ScanResponse
|
import com.tangem.domain.models.scan.ScanResponse
|
||||||
import com.tangem.tap.common.analytics.events.WalletConnect
|
import com.tangem.tap.common.analytics.events.WalletConnect
|
||||||
|
|
@ -36,7 +37,6 @@ import okhttp3.Interceptor
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okhttp3.logging.HttpLoggingInterceptor
|
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
@ -56,8 +56,9 @@ class WalletConnectManager {
|
||||||
.addInterceptor(RetryInterceptor())
|
.addInterceptor(RetryInterceptor())
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
private val interceptor by lazy {
|
private val interceptor by lazy {
|
||||||
HttpLoggingInterceptor().apply { level = HttpLoggingInterceptor.Level.BODY }
|
createNetworkLoggingInterceptor()
|
||||||
}
|
}
|
||||||
|
|
||||||
private var sessions: MutableMap<Topic, WalletConnectActiveData> = mutableMapOf()
|
private var sessions: MutableMap<Topic, WalletConnectActiveData> = mutableMapOf()
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ dependencies {
|
||||||
implementation(deps.moshi)
|
implementation(deps.moshi)
|
||||||
implementation(deps.moshi.kotlin)
|
implementation(deps.moshi.kotlin)
|
||||||
implementation(deps.okHttp)
|
implementation(deps.okHttp)
|
||||||
implementation(deps.okHttp.logging)
|
implementation(deps.okHttp.prettyLogging)
|
||||||
implementation(deps.retrofit)
|
implementation(deps.retrofit)
|
||||||
implementation(deps.retrofit.moshi)
|
implementation(deps.retrofit.moshi)
|
||||||
implementation(deps.reactive.network)
|
implementation(deps.reactive.network)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
package com.tangem.datasource.api.common
|
package com.tangem.datasource.api.common
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
|
import com.ihsanbal.logging.Level
|
||||||
|
import com.ihsanbal.logging.LoggingInterceptor
|
||||||
import okhttp3.Interceptor
|
import okhttp3.Interceptor
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import okhttp3.logging.HttpLoggingInterceptor
|
|
||||||
import retrofit2.Retrofit
|
import retrofit2.Retrofit
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
|
|
@ -22,7 +24,7 @@ fun createRetrofitInstance(
|
||||||
}
|
}
|
||||||
interceptors.forEach { okHttpBuilder.addInterceptor(it) }
|
interceptors.forEach { okHttpBuilder.addInterceptor(it) }
|
||||||
|
|
||||||
if (logEnabled) okHttpBuilder.addInterceptor(createHttpLoggingInterceptor())
|
if (logEnabled) okHttpBuilder.addInterceptor(createNetworkLoggingInterceptor())
|
||||||
|
|
||||||
return Retrofit.Builder()
|
return Retrofit.Builder()
|
||||||
.baseUrl(baseUrl)
|
.baseUrl(baseUrl)
|
||||||
|
|
@ -31,6 +33,9 @@ fun createRetrofitInstance(
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createHttpLoggingInterceptor(): HttpLoggingInterceptor = HttpLoggingInterceptor().apply {
|
fun createNetworkLoggingInterceptor(): Interceptor {
|
||||||
level = HttpLoggingInterceptor.Level.BODY
|
return LoggingInterceptor.Builder()
|
||||||
|
.setLevel(Level.BODY)
|
||||||
|
.log(Log.VERBOSE)
|
||||||
|
.build()
|
||||||
}
|
}
|
||||||
|
|
@ -63,9 +63,7 @@ class NetworkModule {
|
||||||
@PromotionOneInch
|
@PromotionOneInch
|
||||||
fun providePromotionOneInchApi(authProvider: AuthProvider, @NetworkMoshi moshi: Moshi): PromotionApi {
|
fun providePromotionOneInchApi(authProvider: AuthProvider, @NetworkMoshi moshi: Moshi): PromotionApi {
|
||||||
val okClient = OkHttpClient.Builder()
|
val okClient = OkHttpClient.Builder()
|
||||||
.addHeaders(
|
.addHeaders(AuthenticationHeader(authProvider))
|
||||||
AuthenticationHeader(authProvider),
|
|
||||||
)
|
|
||||||
.allowLogging()
|
.allowLogging()
|
||||||
.callTimeout(API_ONE_INCH_TIMEOUT_MS, TimeUnit.MILLISECONDS)
|
.callTimeout(API_ONE_INCH_TIMEOUT_MS, TimeUnit.MILLISECONDS)
|
||||||
.connectTimeout(API_ONE_INCH_TIMEOUT_MS, TimeUnit.MILLISECONDS)
|
.connectTimeout(API_ONE_INCH_TIMEOUT_MS, TimeUnit.MILLISECONDS)
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
package com.tangem.datasource.utils
|
package com.tangem.datasource.utils
|
||||||
|
|
||||||
import com.tangem.datasource.BuildConfig
|
import com.tangem.datasource.BuildConfig
|
||||||
|
import com.tangem.datasource.api.common.createNetworkLoggingInterceptor
|
||||||
import okhttp3.Interceptor
|
import okhttp3.Interceptor
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import okhttp3.logging.HttpLoggingInterceptor
|
|
||||||
import okhttp3.logging.HttpLoggingInterceptor.Level
|
|
||||||
|
|
||||||
/** Extension for adding headers [requestHeaders] to every [OkHttpClient] request */
|
/** Extension for adding headers [requestHeaders] to every [OkHttpClient] request */
|
||||||
internal fun OkHttpClient.Builder.addHeaders(vararg requestHeaders: RequestHeader): OkHttpClient.Builder {
|
internal fun OkHttpClient.Builder.addHeaders(vararg requestHeaders: RequestHeader): OkHttpClient.Builder {
|
||||||
|
|
@ -26,5 +25,10 @@ internal fun OkHttpClient.Builder.addHeaders(vararg requestHeaders: RequestHeade
|
||||||
*
|
*
|
||||||
* @param level logging level. By default, only the request body.
|
* @param level logging level. By default, only the request body.
|
||||||
*/
|
*/
|
||||||
internal fun OkHttpClient.Builder.allowLogging(level: Level = Level.BODY): OkHttpClient.Builder =
|
internal fun OkHttpClient.Builder.allowLogging(): OkHttpClient.Builder {
|
||||||
if (BuildConfig.DEBUG) addInterceptor(interceptor = HttpLoggingInterceptor().setLevel(level)) else this
|
return if (BuildConfig.DEBUG) {
|
||||||
|
addInterceptor(interceptor = createNetworkLoggingInterceptor())
|
||||||
|
} else {
|
||||||
|
this
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -22,12 +22,8 @@ dependencies {
|
||||||
|
|
||||||
/** Other libraries */
|
/** Other libraries */
|
||||||
implementation(deps.reKotlin)
|
implementation(deps.reKotlin)
|
||||||
//TODO: refactoring: remove it when all network services moved to the datasource module
|
|
||||||
implementation(deps.retrofit)
|
|
||||||
implementation(deps.retrofit.moshi)
|
|
||||||
implementation(deps.moshi)
|
implementation(deps.moshi)
|
||||||
implementation(deps.moshi.kotlin)
|
implementation(deps.moshi.kotlin)
|
||||||
implementation(deps.okHttp.logging)
|
|
||||||
implementation(deps.timber)
|
implementation(deps.timber)
|
||||||
implementation(deps.kotlin.coroutines)
|
implementation(deps.kotlin.coroutines)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,8 @@ arrow = "1.2.0-RC"
|
||||||
reactiveNetwork = "3.0.8"
|
reactiveNetwork = "3.0.8"
|
||||||
walletConnectCore = "1.17.0"
|
walletConnectCore = "1.17.0"
|
||||||
walletConnectWeb3 = "1.10.0"
|
walletConnectWeb3 = "1.10.0"
|
||||||
|
prettyLogger = "2.2.0"
|
||||||
|
okHttp-prettyLogging = "3.1.0"
|
||||||
# endregion Other libraries
|
# endregion Other libraries
|
||||||
|
|
||||||
# region Tangem
|
# region Tangem
|
||||||
|
|
@ -201,7 +203,7 @@ material = { module = "com.google.android.material:material", version.ref = "goo
|
||||||
moshi = { module = "com.squareup.moshi:moshi", version.ref = "moshi" }
|
moshi = { module = "com.squareup.moshi:moshi", version.ref = "moshi" }
|
||||||
moshi-kotlin = { module = "com.squareup.moshi:moshi-kotlin", version.ref = "moshi" }
|
moshi-kotlin = { module = "com.squareup.moshi:moshi-kotlin", version.ref = "moshi" }
|
||||||
okHttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
|
okHttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
|
||||||
okHttp-logging = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "okhttp" }
|
okHttp-prettyLogging = { module = "com.github.ihsanbal:LoggingInterceptor", version.ref = "okHttp-prettyLogging" }
|
||||||
otaliastudiosCameraView = { module = "com.otaliastudios:cameraview", version.ref = "otaliastudiosCameraView" }
|
otaliastudiosCameraView = { module = "com.otaliastudios:cameraview", version.ref = "otaliastudiosCameraView" }
|
||||||
shopify-buy = { module = "com.shopify.mobilebuysdk:buy3", version.ref = "shopifyBuySdk" }
|
shopify-buy = { module = "com.shopify.mobilebuysdk:buy3", version.ref = "shopifyBuySdk" }
|
||||||
spongecastle-core = { module = "com.madgag.spongycastle:core", version.ref = "spongycastleCryptoCore" }
|
spongecastle-core = { module = "com.madgag.spongycastle:core", version.ref = "spongycastleCryptoCore" }
|
||||||
|
|
@ -222,4 +224,5 @@ arrow-fx = { module = "io.arrow-kt:arrow-fx-coroutines", version.ref = "arrow" }
|
||||||
reactive-network = { module = "com.github.pwittchen:reactivenetwork-rx2", version.ref = "reactiveNetwork" }
|
reactive-network = { module = "com.github.pwittchen:reactivenetwork-rx2", version.ref = "reactiveNetwork" }
|
||||||
walletConnectCore = { module = "com.walletconnect:android-core", version.ref = "walletConnectCore" }
|
walletConnectCore = { module = "com.walletconnect:android-core", version.ref = "walletConnectCore" }
|
||||||
walletConnectWeb3 = { module = "com.walletconnect:web3wallet", version.ref = "walletConnectWeb3" }
|
walletConnectWeb3 = { module = "com.walletconnect:web3wallet", version.ref = "walletConnectWeb3" }
|
||||||
|
prettyLogger = { module = "com.orhanobut:logger", version.ref = "prettyLogger" }
|
||||||
# endregion Other
|
# endregion Other
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue