TP-00000 | Added ApiUrl in error event (#6564)
* TP-00000 | Added ApiUrl in error event * TP-00000 | Fix
This commit is contained in:
committed by
GitHub Enterprise
parent
001def730e
commit
82d0305d1d
@@ -8,7 +8,6 @@
|
||||
package com.naviapp.network.retrofit
|
||||
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||
import com.google.firebase.ktx.Firebase
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.navi.base.utils.BaseUtils
|
||||
@@ -17,6 +16,7 @@ import com.navi.common.network.ApiConstants.API_CODE_ERROR
|
||||
import com.navi.common.network.ApiConstants.API_CODE_SOCKET_TIMEOUT
|
||||
import com.navi.common.network.ApiConstants.NO_INTERNET
|
||||
import com.navi.common.network.models.ErrorMessage
|
||||
import com.navi.common.network.models.GenericErrorResponse
|
||||
import com.navi.common.network.models.GenericResponse
|
||||
import com.navi.common.network.models.RepoResult
|
||||
import com.navi.common.utils.TemporaryStorageHelper
|
||||
@@ -53,6 +53,7 @@ abstract class ResponseCallback {
|
||||
if (isDataNeedsToUpdate(response.raw().request.method, response.raw().request.url.toString())) {
|
||||
TemporaryStorageHelper.updateScreenData()
|
||||
}
|
||||
addApiUrlInErrorResponse(response?.body()?.errors, response?.raw()?.request?.url.toString())
|
||||
response.body()?.let {
|
||||
if (it.errors?.firstOrNull()?.code == E_OFFER_EXPIRED) {
|
||||
handleError(it.errors, RedirectPageStatus(rejectReason = LOAN_OFFER_EXPIRED))
|
||||
@@ -146,4 +147,10 @@ abstract class ResponseCallback {
|
||||
result.error = errorMessage
|
||||
return result
|
||||
}
|
||||
|
||||
private fun addApiUrlInErrorResponse(errors: List<GenericErrorResponse>?, apiUrl: String) {
|
||||
errors?.forEach{
|
||||
it.apiUrl = apiUrl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ data class GenericErrorResponse(
|
||||
@SerializedName("isNewJourneyCustomer") val isNewJourneyCustomer: Boolean? = null,
|
||||
@SerializedName("statusCode") val statusCode: Int? = null,
|
||||
@SerializedName("errorScreenData") val errorScreenData: ActionCheckResponse? = null,
|
||||
val apiUrl: String? = null,
|
||||
var apiUrl: String? = null,
|
||||
val logMessage: String? = null,
|
||||
val errorMetaData: ErrorMetaData? = null
|
||||
) : Parcelable
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.navi.common.network.ApiConstants.API_SUCCESS_CODE
|
||||
import com.navi.common.network.ApiConstants.API_SUCCESS_CODE_204
|
||||
import com.navi.common.network.ApiConstants.NO_INTERNET
|
||||
import com.navi.common.network.models.ErrorMessage
|
||||
import com.navi.common.network.models.GenericErrorResponse
|
||||
import com.navi.common.network.models.GenericResponse
|
||||
import com.navi.common.network.models.RepoResult
|
||||
import com.navi.common.utils.TemporaryStorageHelper
|
||||
@@ -44,6 +45,7 @@ abstract class ResponseCallback {
|
||||
if (isDataNeedsToUpdate(response.raw().request.method, response.raw().request.url.toString())) {
|
||||
TemporaryStorageHelper.updateScreenData()
|
||||
}
|
||||
addApiUrlInErrorResponse(response.body()?.errors, response?.raw()?.request?.url.toString())
|
||||
response.body()?.let {
|
||||
if (it.statusCode.orZero() in API_SUCCESS_CODE until API_BAD_REQUEST) {
|
||||
return RepoResult(it.data, null, it.errors, it.warning, it.statusCode)
|
||||
@@ -121,4 +123,10 @@ abstract class ResponseCallback {
|
||||
result.error = errorMessage
|
||||
return result
|
||||
}
|
||||
|
||||
private fun addApiUrlInErrorResponse(errors: List<GenericErrorResponse>?, apiUrl: String) {
|
||||
errors?.forEach{
|
||||
it.apiUrl = apiUrl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,7 +333,8 @@ abstract class BaseActivity :
|
||||
errorMessage: ErrorMessage?
|
||||
) {
|
||||
val eventName = screenName ?: this.eventTrackingScreenName ?: this.screenName
|
||||
analyticsErrorEventTracker.onApiFailure(eventName + "_error", error, errorMessage)
|
||||
val apiUrl = error?.apiUrl ?: errorMessage?.apiUrl
|
||||
analyticsErrorEventTracker.onApiFailure(eventName + "_error", error, errorMessage, apiUrl)
|
||||
}
|
||||
|
||||
override fun sendApiFailureEvent(
|
||||
|
||||
@@ -37,13 +37,14 @@ class CommonNaviAnalytics private constructor() {
|
||||
fun onApiFailure(
|
||||
eventName: String,
|
||||
error: GenericErrorResponse?,
|
||||
errorMessage: ErrorMessage?
|
||||
errorMessage: ErrorMessage?,
|
||||
apiUrl: String?
|
||||
) {
|
||||
val map =
|
||||
mapOf(
|
||||
Pair("error_data", error.toString()),
|
||||
Pair("message", errorMessage.toString()),
|
||||
Pair("apiUrl", error?.apiUrl.toString()),
|
||||
Pair("apiUrl", apiUrl.toString()),
|
||||
Pair("logMessage", error?.logMessage.toString()),
|
||||
)
|
||||
NaviTrackEvent.trackEvent(eventName, map)
|
||||
|
||||
@@ -503,6 +503,7 @@ fun com.navi.payment.model.GenericErrorResponse.toCommonGenericErrorResponse():
|
||||
message = message,
|
||||
actions = actions?.map { it.toAction() },
|
||||
optionalNote = optionalNote,
|
||||
additionalDescription = additionalDescription
|
||||
additionalDescription = additionalDescription,
|
||||
apiUrl = apiUrl
|
||||
)
|
||||
}
|
||||
|
||||
@@ -11,4 +11,5 @@ data class GenericErrorResponse(
|
||||
@SerializedName("actions") val actions: List<ActionData>? = null,
|
||||
@SerializedName("optionalNote") val optionalNote: String? = null,
|
||||
@SerializedName("additionalDescription") val additionalDescription: List<String>? = null,
|
||||
var apiUrl: String? = null,
|
||||
)
|
||||
@@ -12,6 +12,7 @@ import com.google.gson.reflect.TypeToken
|
||||
import com.navi.base.utils.BaseUtils.isNetworkAvailable
|
||||
import com.navi.base.utils.orZero
|
||||
import com.navi.payment.R
|
||||
import com.navi.payment.model.GenericErrorResponse
|
||||
import com.navi.payment.model.GenericPaymentResponse
|
||||
import com.navi.payment.model.PaymentMethodResponse
|
||||
import com.navi.payment.model.RpdPaymentDetails
|
||||
@@ -58,6 +59,7 @@ class PaymentRepository {
|
||||
}
|
||||
|
||||
private fun <T> handleResponse(response: Response<GenericPaymentResponse<T>>): GenericPaymentResponse<T> {
|
||||
addApiUrlInErrorResponse(response?.body()?.errors, response?.raw()?.request?.url.toString())
|
||||
response.body()?.let {
|
||||
if (it.statusCode.orZero() in API_SUCCESS_CODE until API_BAD_REQUEST) {
|
||||
return GenericPaymentResponse(data = it.data, message = null, errors = it.errors, statusCode = it.statusCode)
|
||||
@@ -109,4 +111,10 @@ class PaymentRepository {
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private fun addApiUrlInErrorResponse(errors: List<GenericErrorResponse>?, apiUrl: String) {
|
||||
errors?.forEach{
|
||||
it.apiUrl = apiUrl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user