NTP-3458 | Analytics logs for otp flow houston (#12486)

This commit is contained in:
A Shrihari Raju
2024-09-12 10:21:57 +05:30
committed by GitHub
parent 96706ce9db
commit 1ae81cee37
3 changed files with 89 additions and 10 deletions

View File

@@ -92,9 +92,30 @@ class OTPVM @Inject constructor(private val repository: OTPRepository) : BaseAmc
repository.generateOtp(otpGenerateData)
}
if (response.error == null && response.errors.isNullOrEmpty()) {
sendEvent(
eventName = AmcAnalytics.AMC_OTP_GENERATE_SUCCESSFUL,
extraAttributes =
hashMapOf(
AmcAnalytics.AMC_OTP_GENERATE_SUCCESSFUL_RESPONSE_DATA to
response.data.toString()
),
screenName = AmcAnalytics.OTP_INIT
)
response.data?.isResendOtp = isResendOtp
_generateOtpResponse.value = response.data
} else {
sendEvent(
eventName = AmcAnalytics.AMC_OTP_GENERATE_ERROR,
extraAttributes =
hashMapOf(
AmcAnalytics.AMC_OTP_GENERATE_ERROR_RESPONSE_DATA to
response.data.toString(),
AmcAnalytics.AMC_OTP_GENERATE_ERROR_ERRORS to
response.errors.toString(),
AmcAnalytics.AMC_OTP_GENERATE_ERROR_ERROR to response.error.toString()
),
screenName = AmcAnalytics.OTP_INIT
)
setErrorData(response.errors, response.error)
}
}
@@ -105,12 +126,44 @@ class OTPVM @Inject constructor(private val repository: OTPRepository) : BaseAmc
val response = repository.verifyOtp(otpVerifyData)
if (response.error == null && response.errors.isNullOrEmpty()) {
_verifyOtpResponse.value = response.data
sendEvent(
eventName = AmcAnalytics.AMC_OTP_VERIFY_SUCCESSFUL,
extraAttributes =
hashMapOf(
AmcAnalytics.AMC_OTP_VERIFY_SUCCESSFUL_RESPONSE_DATA to
response.data.toString(),
),
screenName = AmcAnalytics.OTP_INIT
)
} else if (
response.error?.statusCode == API_WRONG_OTP ||
response.errors?.firstOrNull()?.statusCode == API_WRONG_OTP
) {
_wrongOtp.value = true
sendEvent(
eventName = AmcAnalytics.AMC_OTP_VERIFY_WRONG_OTP,
extraAttributes =
hashMapOf(
AmcAnalytics.AMC_OTP_VERIFY_WRONG_OTP_RESPONSE_DATA to
response.data.toString(),
AmcAnalytics.AMC_OTP_VERIFY_WRONG_OTP_ERRORS to
response.errors.toString(),
AmcAnalytics.AMC_OTP_VERIFY_WRONG_OTP_ERROR to response.error.toString()
),
screenName = AmcAnalytics.OTP_INIT
)
} else {
sendEvent(
eventName = AmcAnalytics.AMC_OTP_VERIFY_ERROR,
extraAttributes =
hashMapOf(
AmcAnalytics.AMC_OTP_VERIFY_ERROR_RESPONSE_DATA to
response.data.toString(),
AmcAnalytics.AMC_OTP_VERIFY_ERROR_ERRORS to response.errors.toString(),
AmcAnalytics.AMC_OTP_VERIFY_ERROR_ERROR to response.error.toString()
),
screenName = AmcAnalytics.OTP_INIT
)
setErrorData(response.errors, response.error)
}
}

View File

@@ -244,16 +244,20 @@ class FundBuyActivity :
} else {
AmcTaskManager.requestParams[PREFETCH_SOURCE_SCREEN] =
viewModel.providePrefetchSourceScreen().orEmpty()
actionData?.url?.let {
val requestCodeForResult = needActivityResultCode(it)
actionData.toNavigateAmcModule(
this,
finish = false,
bundle = bundle,
clearTask = toClearTask(currentScreenTag),
requestCode = requestCodeForResult,
needsResult = requestCodeForResult.isNotNull()
)
actionData?.url?.let { url ->
if (url == "back") {
navigateBack()
} else {
val requestCodeForResult = needActivityResultCode(url)
actionData.toNavigateAmcModule(
this,
finish = false,
bundle = bundle,
clearTask = toClearTask(currentScreenTag),
requestCode = requestCodeForResult,
needsResult = requestCodeForResult.isNotNull()
)
}
} ?: kotlin.run { navigateBack() }
}
} catch (exception: Exception) {

View File

@@ -267,6 +267,28 @@ object AmcAnalytics {
const val AMC_INIT_AUTOPAY_SETUP_SCREEN = "amc_init_autopay_setup_screen"
const val AMC_AUTOPAY_MODE_CHANGED = "amc_autopay_mode_changed"
const val AMC_OTP_VERIFY_SUCCESSFUL = "amc_otp_verify_successful"
const val AMC_OTP_VERIFY_SUCCESSFUL_RESPONSE_DATA = "amc_otp_verify_response_data"
const val AMC_OTP_VERIFY_WRONG_OTP = "amc_otp_verify_wrong_otp"
const val AMC_OTP_VERIFY_WRONG_OTP_RESPONSE_DATA = "amc_otp_verify_wrong_response_data"
const val AMC_OTP_VERIFY_WRONG_OTP_ERRORS = "amc_otp_verify_wrong_response_errors"
const val AMC_OTP_VERIFY_WRONG_OTP_ERROR = "amc_otp_verify_wrong_response_error"
const val AMC_OTP_VERIFY_ERROR = "amc_otp_verify_error"
const val AMC_OTP_VERIFY_ERROR_RESPONSE_DATA = "amc_otp_verify_error_response_data"
const val AMC_OTP_VERIFY_ERROR_ERRORS = "amc_otp_verify_error_response_errors"
const val AMC_OTP_VERIFY_ERROR_ERROR = "amc_otp_verify_error_response_error"
const val AMC_OTP_GENERATE_SUCCESSFUL = "amc_otp_generate_successful"
const val AMC_OTP_GENERATE_SUCCESSFUL_RESPONSE_DATA =
"amc_otp_generate_successful_response_data"
const val AMC_OTP_GENERATE_ERROR = "amc_otp_generate_error"
const val AMC_OTP_GENERATE_ERROR_RESPONSE_DATA = "amc_otp_generate_error_response_data"
const val AMC_OTP_GENERATE_ERROR_ERRORS = "amc_otp_generate_error_response_errors"
const val AMC_OTP_GENERATE_ERROR_ERROR = "amc_otp_generate_error_response_error"
fun sendEvent(
eventsData: GenericAnalyticsData?,
extraAttributes: HashMap<String, String>? = null,