NTP-8444 | NAP Phase 2 | OE for GI (#13693)
Co-authored-by: shrihari-raju_navi <shrihari.raju@navi.com> Co-authored-by: Kshitij Pramod Ghongadi <kshitij.pramod@navi.com>
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
package com.naviapp.common.tab
|
||||
|
||||
import com.navi.common.checkmate.model.MetricInfo
|
||||
import com.navi.common.model.ModuleName
|
||||
import com.navi.common.model.ModuleNameV2
|
||||
import com.navi.common.network.models.RepoResult
|
||||
@@ -25,35 +26,50 @@ class InsuranceTabRepository
|
||||
constructor(@SuperAppRetroFit private val apiService: RetrofitService) : ResponseCallback() {
|
||||
private val giTabId = "GI"
|
||||
|
||||
suspend fun fetchInsuranceTabPage(): RepoResult<InsuranceTabResponse> {
|
||||
suspend fun fetchInsuranceTabPage(
|
||||
metricInfo: MetricInfo.InsuranceMetricInfo<InsuranceTabResponse>
|
||||
): RepoResult<InsuranceTabResponse> {
|
||||
return apiResponseCallback(
|
||||
apiService.fetchInsuranceTabForgeScreen(
|
||||
acceptEncoding = GZIP,
|
||||
target = ModuleNameV2.FORGE.name,
|
||||
giTabId
|
||||
)
|
||||
),
|
||||
metricInfo = metricInfo
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun dismissCta(toastReferenceId: String) =
|
||||
suspend fun dismissCta(
|
||||
toastReferenceId: String,
|
||||
metricInfo: MetricInfo.InsuranceMetricInfo<String>
|
||||
) =
|
||||
apiResponseCallback(
|
||||
apiService.dismissToast(
|
||||
target = ModuleName.GI.name,
|
||||
request = ToastRequestBody(toastIdentifier = toastReferenceId)
|
||||
)
|
||||
),
|
||||
metricInfo = metricInfo
|
||||
)
|
||||
|
||||
suspend fun closePolicyCard(quoteId: String): RepoResult<ClosePolicyCardResponse> {
|
||||
suspend fun closePolicyCard(
|
||||
quoteId: String,
|
||||
metricInfo: MetricInfo.InsuranceMetricInfo<ClosePolicyCardResponse>
|
||||
): RepoResult<ClosePolicyCardResponse> {
|
||||
return apiResponseCallback(
|
||||
apiService.closePolicyCard(applicationId = quoteId, target = ModuleName.GI.name)
|
||||
apiService.closePolicyCard(applicationId = quoteId, target = ModuleName.GI.name),
|
||||
metricInfo = metricInfo
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun clearCache(): RepoResult<ClearCacheResponse> {
|
||||
suspend fun clearCache(
|
||||
metricInfo: MetricInfo.InsuranceMetricInfo<ClearCacheResponse>
|
||||
): RepoResult<ClearCacheResponse> {
|
||||
|
||||
return apiResponseCallback(
|
||||
apiService.clearCache(
|
||||
target = ModuleName.GI.name,
|
||||
)
|
||||
),
|
||||
metricInfo = metricInfo
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,15 +26,20 @@ import com.navi.common.analytics.NaviAnalytics
|
||||
import com.navi.common.analytics.NaviAnalytics.Companion.CACHE_API_LOAD_ERROR
|
||||
import com.navi.common.analytics.NaviAnalytics.Companion.INSURANCE_TAB_INIT
|
||||
import com.navi.common.callback.RequestToCallbackHandler
|
||||
import com.navi.common.checkmate.model.MetricInfo
|
||||
import com.navi.common.model.ModuleNameV2
|
||||
import com.navi.common.network.models.ErrorMetaData
|
||||
import com.navi.common.network.models.isSuccessWithData
|
||||
import com.navi.common.react.ReactPreLoadHeadLessActivity
|
||||
import com.navi.common.uitron.model.action.CtaAction
|
||||
import com.navi.common.utils.SingleLiveEvent
|
||||
import com.navi.common.utils.isValidResponse
|
||||
import com.navi.common.viewmodel.BaseVM
|
||||
import com.navi.insurance.common.models.ClearCacheResponse
|
||||
import com.navi.insurance.common.models.GiErrorMetaData
|
||||
import com.navi.insurance.common.models.InsuranceTabResponse
|
||||
import com.navi.insurance.common.models.InsuranceTabState
|
||||
import com.navi.insurance.models.response.ClosePolicyCardResponse
|
||||
import com.navi.insurance.navigator.NaviInsuranceDeeplinkNavigator
|
||||
import com.navi.insurance.network.ApiErrorTagType
|
||||
import com.navi.insurance.util.Constants
|
||||
@@ -75,7 +80,16 @@ constructor(
|
||||
_insuranceTabDataFlow.update { it.copy(isLoading = true) }
|
||||
}
|
||||
viewModelScope.safeLaunch(coroutineContext = Dispatchers.IO) {
|
||||
val response = repository.fetchInsuranceTabPage()
|
||||
val metricInfo =
|
||||
MetricInfo.InsuranceMetricInfo<InsuranceTabResponse>(
|
||||
screen = INSURANCE_TAB_INIT,
|
||||
isNae = {
|
||||
!it.isSuccessWithData() ||
|
||||
(it.data?.listOfUiTronWidgets.isNullOrEmpty() &&
|
||||
it.data?.listOfNativeWidgets.isNullOrEmpty())
|
||||
}
|
||||
)
|
||||
val response = repository.fetchInsuranceTabPage(metricInfo)
|
||||
if (
|
||||
response.error.isNull() &&
|
||||
response.errors.isNullOrEmpty() &&
|
||||
@@ -116,7 +130,12 @@ constructor(
|
||||
|
||||
private fun dismissCta(toastIdentifier: String) {
|
||||
viewModelScope.safeLaunch(coroutineContext = Dispatchers.IO) {
|
||||
val response = repository.dismissCta(toastIdentifier)
|
||||
val metricInfo =
|
||||
MetricInfo.InsuranceMetricInfo<String>(
|
||||
screen = INSURANCE_TAB_INIT,
|
||||
isNae = { false }
|
||||
)
|
||||
val response = repository.dismissCta(toastIdentifier, metricInfo)
|
||||
if (response.statusCode.orZero().equals(200)) {} else {
|
||||
val errorUnifiedResponse =
|
||||
getErrorUnifiedResponse(
|
||||
@@ -148,7 +167,12 @@ constructor(
|
||||
private fun closePolicyCard(quoteId: String) {
|
||||
_insuranceTabDataFlow.update { it.copy(isLoading = true, data = null) }
|
||||
viewModelScope.safeLaunch(coroutineContext = Dispatchers.IO) {
|
||||
val response = repository.closePolicyCard(quoteId)
|
||||
val metricInfo =
|
||||
MetricInfo.InsuranceMetricInfo<ClosePolicyCardResponse>(
|
||||
screen = INSURANCE_TAB_INIT,
|
||||
isNae = { false }
|
||||
)
|
||||
val response = repository.closePolicyCard(quoteId, metricInfo)
|
||||
if (
|
||||
response.error.isNull() &&
|
||||
response.errors.isNullOrEmpty() &&
|
||||
@@ -211,7 +235,12 @@ constructor(
|
||||
|
||||
fun clearCacheOnVersionUpgrade() {
|
||||
viewModelScope.safeLaunch(coroutineContext = Dispatchers.IO) {
|
||||
val response = repository.clearCache()
|
||||
val metricInfo =
|
||||
MetricInfo.InsuranceMetricInfo<ClearCacheResponse>(
|
||||
screen = INSURANCE_TAB_INIT,
|
||||
isNae = { false }
|
||||
)
|
||||
val response = repository.clearCache(metricInfo)
|
||||
if (response.isValidResponse()) {
|
||||
response.data?.pageVersionList?.forEach { item ->
|
||||
val entity = naviCacheRepository.get(key = item.pageName.orEmpty())
|
||||
|
||||
@@ -12,7 +12,11 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule
|
||||
import com.facebook.react.bridge.ReactMethod
|
||||
import com.facebook.react.bridge.ReadableMap
|
||||
import com.navi.base.utils.orFalse
|
||||
import com.navi.base.utils.orZero
|
||||
import com.navi.common.checkmate.core.CheckMateManager
|
||||
import com.navi.common.model.ModuleNameV2
|
||||
import com.navi.common.utils.CommonNaviAnalytics
|
||||
import com.naviapp.react_native.native_bridge.connectors.NativeAnalyticsConnector.Companion.moduleNameListForGI
|
||||
import com.naviapp.utils.toMap
|
||||
|
||||
class NativeAnalyticsConnector internal constructor(context: ReactApplicationContext?) :
|
||||
@@ -96,8 +100,42 @@ class NativeAnalyticsConnector internal constructor(context: ReactApplicationCon
|
||||
extras = extras.toMutableMap(),
|
||||
journeySource = journeySource
|
||||
)
|
||||
|
||||
val latency = (propsMap["latency"] as? Double)?.toLong() ?: 0L
|
||||
val errorCode = propsMap["errorCode"] as? String
|
||||
val errorTitle = propsMap["errorTitle"] as? String
|
||||
|
||||
CheckMateManager.recordNetworkEvent(
|
||||
statusCode = statusCode?.toInt().orZero(),
|
||||
actualLatency = latency.orZero(),
|
||||
networkLatency = latency.orZero(),
|
||||
isNae = statusCode?.toInt() != 20,
|
||||
httpStatusCode = statusCode?.toInt().orZero(),
|
||||
vertical = getModuleNameForCheckMate(moduleName),
|
||||
screen = source.orEmpty(),
|
||||
endpoint = methodName.orEmpty(),
|
||||
errorCode = errorCode.orEmpty(),
|
||||
errorTitle = errorTitle.orEmpty(),
|
||||
errorDes = reason.orEmpty(),
|
||||
exception = reason.orEmpty(),
|
||||
)
|
||||
if (isAppDowntimeEvent.orFalse()) {
|
||||
sendAsAppDowntimeEvent(eventProps)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
val moduleNameListForGI = listOf("gi", "hi", "Insurance")
|
||||
}
|
||||
}
|
||||
|
||||
fun getModuleNameForCheckMate(moduleName: String) =
|
||||
when {
|
||||
moduleName in moduleNameListForGI -> ModuleNameV2.Insurance.name
|
||||
moduleName.contains("home", ignoreCase = true) ||
|
||||
moduleName.contains("notification", ignoreCase = true) -> ModuleNameV2.App.name
|
||||
moduleName.contains("investment", ignoreCase = true) ||
|
||||
moduleName.contains("amc", ignoreCase = true) -> ModuleNameV2.AMC.name
|
||||
moduleName.contains("gold", ignoreCase = true) -> ModuleNameV2.GOLD.name
|
||||
else -> "Unknown"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user