TP-38663 | add IOExceptionE event in gzip (#7753)
This commit is contained in:
@@ -17,6 +17,7 @@ import com.navi.common.model.NetworkInfo
|
||||
import com.navi.common.network.ApiConstants
|
||||
import com.navi.common.network.BaseHttpClient
|
||||
import com.navi.common.network.handleException
|
||||
import com.navi.common.network.logIOException
|
||||
import com.naviapp.BuildConfig
|
||||
import com.naviapp.app.NaviApplication
|
||||
import okhttp3.Cache
|
||||
|
||||
@@ -151,21 +151,4 @@ abstract class BaseHttpClient(
|
||||
}
|
||||
response
|
||||
}
|
||||
|
||||
protected fun logIOException(e: Exception, errorMessage: ErrorMessage, request: Request) {
|
||||
try {
|
||||
NaviTrackEvent.trackEventOnClickStream(
|
||||
NETWORK_CRASH,
|
||||
mapOf(
|
||||
Pair("message", e.message.orEmpty()),
|
||||
Pair("code", errorMessage.statusCode.toString()),
|
||||
Pair("apiUrl", request.url.toString()),
|
||||
Pair("vertical", request.headers[X_TARGET] ?: ""),
|
||||
Pair("appRequestId", request.headers[APPREQUESTID] ?: "")
|
||||
)
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
e.log()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.navi.analytics.utils.NaviAnalyticsHelper
|
||||
import com.navi.analytics.utils.NaviTrackEvent
|
||||
import com.navi.base.utils.BaseUtils
|
||||
import com.navi.common.CommonLibManager
|
||||
import com.navi.common.constants.NETWORK_CRASH
|
||||
import com.navi.common.network.models.ErrorMessage
|
||||
import com.navi.common.network.models.GenericResponse
|
||||
import com.navi.common.utils.CommonNaviAnalytics
|
||||
@@ -19,6 +20,7 @@ import com.navi.common.utils.GENERAL_ERROR
|
||||
import com.navi.common.utils.NO_INTERNET
|
||||
import com.navi.common.utils.SOCKET_TIMEOUT
|
||||
import com.navi.common.utils.log
|
||||
import okhttp3.Request
|
||||
import java.net.ConnectException
|
||||
import java.net.SocketTimeoutException
|
||||
import java.net.UnknownHostException
|
||||
@@ -88,3 +90,19 @@ fun <T> getCfRayFromResponse(response: Response<GenericResponse<T>>): String? {
|
||||
}
|
||||
return null
|
||||
}
|
||||
fun logIOException(e: Exception, errorMessage: ErrorMessage, request: Request) {
|
||||
try {
|
||||
NaviTrackEvent.trackEventOnClickStream(
|
||||
NETWORK_CRASH,
|
||||
mapOf(
|
||||
Pair("message", e.message.orEmpty()),
|
||||
Pair("code", errorMessage.statusCode.toString()),
|
||||
Pair("apiUrl", request.url.toString()),
|
||||
Pair("vertical", request.headers[BaseHttpClient.X_TARGET] ?: ""),
|
||||
Pair("appRequestId", request.headers[BaseHttpClient.APPREQUESTID] ?: "")
|
||||
)
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
e.log()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.google.common.net.HttpHeaders.CONTENT_ENCODING
|
||||
import com.google.common.net.HttpHeaders.CONTENT_LENGTH
|
||||
import com.navi.base.network.util.ApiConstants
|
||||
import com.navi.common.network.handleException
|
||||
import com.navi.common.network.logIOException
|
||||
import com.navi.common.utils.Constants.GZIP
|
||||
import okhttp3.Interceptor
|
||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||
@@ -21,6 +22,7 @@ class GzipInterceptor : Interceptor {
|
||||
chain.proceed(request)
|
||||
} catch (e: Exception) {
|
||||
val errorMessage = handleException(e)
|
||||
logIOException(e, errorMessage, request)
|
||||
// A mocked response in case of n/w exception
|
||||
val errorStatusCode: Int = errorMessage.statusCode ?: ApiConstants.API_CODE_ERROR
|
||||
Response.Builder()
|
||||
|
||||
Reference in New Issue
Block a user