Updated on 2026-08-14
This commit is contained in:
parent
c14158ff0f
commit
567a1689fd
2 changed files with 25 additions and 14 deletions
|
|
@ -304,10 +304,11 @@ internal class DefaultMarketsTokenRepository(
|
|||
}
|
||||
|
||||
private fun createListErrorEvent(error: ApiResponseError): MarketsDataAnalyticsEvent.List.Error {
|
||||
return createErrorEvent(error) { errorType, errorCode ->
|
||||
return createErrorEvent(error) { errorType, errorCode, errorMessage ->
|
||||
MarketsDataAnalyticsEvent.List.Error(
|
||||
errorType = errorType,
|
||||
errorCode = errorCode,
|
||||
errorMessage = errorMessage,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -317,10 +318,11 @@ internal class DefaultMarketsTokenRepository(
|
|||
request: MarketsDataAnalyticsEvent.Details.Error.Request,
|
||||
tokenSymbol: String,
|
||||
): MarketsDataAnalyticsEvent.Details.Error {
|
||||
return createErrorEvent(error) { errorType, errorCode ->
|
||||
return createErrorEvent(error) { errorType, errorCode, errorMessage ->
|
||||
MarketsDataAnalyticsEvent.Details.Error(
|
||||
errorType = errorType,
|
||||
errorCode = errorCode,
|
||||
errorMessage = errorMessage,
|
||||
request = request,
|
||||
tokenSymbol = tokenSymbol,
|
||||
)
|
||||
|
|
@ -329,20 +331,20 @@ internal class DefaultMarketsTokenRepository(
|
|||
|
||||
private inline fun <T> createErrorEvent(
|
||||
error: ApiResponseError,
|
||||
createEvent: (MarketsDataAnalyticsEvent.Type, Int?) -> T,
|
||||
createEvent: (MarketsDataAnalyticsEvent.Type, Int?, String) -> T,
|
||||
): T {
|
||||
return when (error) {
|
||||
is ApiResponseError.HttpException -> {
|
||||
createEvent(MarketsDataAnalyticsEvent.Type.Http, error.code.code)
|
||||
createEvent(MarketsDataAnalyticsEvent.Type.Http, error.code.code, error.message.orEmpty())
|
||||
}
|
||||
is ApiResponseError.TimeoutException -> {
|
||||
createEvent(MarketsDataAnalyticsEvent.Type.Timeout, null)
|
||||
createEvent(MarketsDataAnalyticsEvent.Type.Timeout, null, error.message.orEmpty())
|
||||
}
|
||||
is ApiResponseError.NetworkException -> {
|
||||
createEvent(MarketsDataAnalyticsEvent.Type.Network, null)
|
||||
createEvent(MarketsDataAnalyticsEvent.Type.Network, null, error.message.orEmpty())
|
||||
}
|
||||
is ApiResponseError.UnknownException -> {
|
||||
createEvent(MarketsDataAnalyticsEvent.Type.Unknown, null)
|
||||
createEvent(MarketsDataAnalyticsEvent.Type.Unknown, null, error.message.orEmpty())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.tangem.data.markets.analytics
|
||||
|
||||
import com.tangem.core.analytics.models.AnalyticsEvent
|
||||
import com.tangem.core.analytics.models.AnalyticsParam
|
||||
|
||||
sealed interface MarketsDataAnalyticsEvent {
|
||||
|
||||
|
|
@ -12,11 +13,13 @@ sealed interface MarketsDataAnalyticsEvent {
|
|||
data class Error(
|
||||
val errorType: Type,
|
||||
val errorCode: Int? = null,
|
||||
val errorMessage: String,
|
||||
) : List(
|
||||
event = "Data Error",
|
||||
params = buildMap {
|
||||
put("Error Type", errorType.value)
|
||||
errorCode?.let { put("Error Code", it.toString()) }
|
||||
put(AnalyticsParam.ERROR_TYPE, errorType.value)
|
||||
put(AnalyticsParam.ERROR_CODE, errorCode?.toString() ?: IS_NOT_HTTP_ERROR)
|
||||
put(AnalyticsParam.ERROR_MESSAGE, errorMessage)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
@ -31,13 +34,15 @@ sealed interface MarketsDataAnalyticsEvent {
|
|||
val tokenSymbol: String,
|
||||
val errorType: Type,
|
||||
val errorCode: Int? = null,
|
||||
val errorMessage: String,
|
||||
) : Details(
|
||||
event = "Data Error",
|
||||
params = buildMap {
|
||||
put("Source", request.source)
|
||||
put("Token", tokenSymbol)
|
||||
errorCode?.let { put("Error Code", it.toString()) }
|
||||
put("Error Type", errorType.value)
|
||||
put(AnalyticsParam.ERROR_TYPE, errorType.value)
|
||||
put(AnalyticsParam.ERROR_CODE, errorCode?.toString() ?: IS_NOT_HTTP_ERROR)
|
||||
put(AnalyticsParam.ERROR_MESSAGE, errorMessage)
|
||||
},
|
||||
) {
|
||||
|
||||
|
|
@ -63,9 +68,9 @@ sealed interface MarketsDataAnalyticsEvent {
|
|||
event = "Data Error",
|
||||
params = buildMap {
|
||||
put("Request path", requestPath)
|
||||
errorCode?.let { put("Error Code", it.toString()) }
|
||||
put("Error Type", errorType.value)
|
||||
put("Error Description", "Chart data contains null values from the API")
|
||||
put(AnalyticsParam.ERROR_TYPE, errorType.value)
|
||||
put(AnalyticsParam.ERROR_CODE, errorCode?.toString() ?: IS_NOT_HTTP_ERROR)
|
||||
put(AnalyticsParam.ERROR_MESSAGE, "Chart data contains null values from the API")
|
||||
},
|
||||
),
|
||||
MarketsDataAnalyticsEvent
|
||||
|
|
@ -77,4 +82,8 @@ sealed interface MarketsDataAnalyticsEvent {
|
|||
Custom("Custom"),
|
||||
Unknown("Unknown"),
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val IS_NOT_HTTP_ERROR = "Is not http error"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue