NTP-58492 | Added event for duplicate upi request id (#15976)

This commit is contained in:
Ujjwal Kumar
2025-04-29 13:33:35 +05:30
committed by GitHub
parent 1e0c4b8f61
commit 23adbcf1cf
3 changed files with 30 additions and 4 deletions

View File

@@ -295,6 +295,13 @@ class NaviPayAnalytics private constructor() {
fun onNaviPayEmptyHomeScreenLanded() {
NaviTrackEvent.trackEventOnClickStream("NaviPay_Empty_Home_Screen_Landed")
}
fun onDuplicateUpiRequestIdReceived(duplicateIds: String) {
NaviTrackEvent.trackEventOnClickStream(
"NaviPay_Duplicate_UpiRequestId_Received",
mapOf("duplicateIds" to duplicateIds),
)
}
}
inner class SetupUseCaseEvents {

View File

@@ -108,8 +108,7 @@ constructor(
return emptyList()
}
// distinct is used to remove duplicate requestId getting from snowflake
return requestIdAPIResponse.data!!.requestIdSuffixList.distinct()
return requestIdAPIResponse.data!!.requestIdSuffixList
}
suspend fun getMandateDetail(

View File

@@ -9,6 +9,7 @@ package com.navi.pay.common.usecase
import com.navi.base.cache.model.NaviCacheEntity
import com.navi.base.cache.repository.NaviCacheRepository
import com.navi.pay.analytics.NaviPayAnalytics
import com.navi.pay.common.model.view.PspType
import com.navi.pay.common.repository.CommonRepository
import com.navi.pay.common.utils.getTimeInMillisTillMidnight
@@ -28,6 +29,8 @@ constructor(
) {
private val mutex = Mutex()
private val naviPayAnalytics: NaviPayAnalytics.UtilityEvents =
NaviPayAnalytics.INSTANCE.UtilityEvents()
suspend fun execute(pspType: PspType): String {
mutex.withLock {
@@ -56,8 +59,25 @@ constructor(
return ""
}
val upiRequestIdSuffixToUse = upiRequestIdSuffixListFromNetwork.first()
val upiRequestSuffixIdsToCache = upiRequestIdSuffixListFromNetwork.drop(1)
// Check for duplicates
// TODO: To be removed after 5.45.0
val duplicateIds =
upiRequestIdSuffixListFromNetwork
.groupBy { it }
.filter { it.value.size > 1 }
.keys
.toList()
if (duplicateIds.isNotEmpty()) {
naviPayAnalytics.onDuplicateUpiRequestIdReceived(
duplicateIds = duplicateIds.joinToString(separator = COMMA)
)
}
val uniqueRequestIds = upiRequestIdSuffixListFromNetwork.distinct()
val upiRequestIdSuffixToUse = uniqueRequestIds.first()
val upiRequestSuffixIdsToCache = uniqueRequestIds.drop(1)
if (upiRequestSuffixIdsToCache.isNotEmpty()) {
naviCacheRepository.save(