Skip to content

Commit

Permalink
Add message field for Google pay error events
Browse files Browse the repository at this point in the history
COAND-1047
  • Loading branch information
araratthehero committed Dec 12, 2024
1 parent b19bed9 commit 6845eb4
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,19 +231,19 @@ internal class DefaultGooglePayDelegate(
AutoResolveHelper.RESULT_ERROR -> {
val statusMessage: String = paymentDataTaskResult.status.statusMessage?.let { ": $it" }.orEmpty()
adyenLog(AdyenLogLevel.ERROR) { "GooglePay encountered an error$statusMessage" }
trackThirdPartyErrorEvent()
trackThirdPartyErrorEvent("Result is error")
exceptionChannel.trySend(ComponentException("GooglePay encountered an error$statusMessage"))
}

CommonStatusCodes.INTERNAL_ERROR -> {
adyenLog(AdyenLogLevel.ERROR) { "GooglePay encountered an internal error" }
trackThirdPartyErrorEvent()
trackThirdPartyErrorEvent("Result is internal error")
exceptionChannel.trySend(ComponentException("GooglePay encountered an internal error"))
}

else -> {
adyenLog(AdyenLogLevel.ERROR) { "GooglePay encountered an unexpected error, statusCode: $statusCode" }
trackThirdPartyErrorEvent()
trackThirdPartyErrorEvent("Unexpected error")
exceptionChannel.trySend(ComponentException("GooglePay encountered an unexpected error"))
}
}
Expand All @@ -254,7 +254,7 @@ internal class DefaultGooglePayDelegate(
when (resultCode) {
Activity.RESULT_OK -> {
if (data == null) {
trackThirdPartyErrorEvent()
trackThirdPartyErrorEvent("Activity result is ok, but data is missing")
exceptionChannel.trySend(ComponentException("Result data is null"))
return
}
Expand All @@ -266,7 +266,7 @@ internal class DefaultGooglePayDelegate(
}

AutoResolveHelper.RESULT_ERROR -> {
trackThirdPartyErrorEvent()
trackThirdPartyErrorEvent("Activity result is error")

val status = AutoResolveHelper.getStatusFromIntent(data)
val statusMessage: String = status?.let { ": ${it.statusMessage}" }.orEmpty()
Expand All @@ -278,7 +278,7 @@ internal class DefaultGooglePayDelegate(
private fun initiatePayment(paymentData: PaymentData?) {
if (paymentData == null) {
adyenLog(AdyenLogLevel.ERROR) { "Payment data is null" }
trackThirdPartyErrorEvent()
trackThirdPartyErrorEvent("Result is success, but data is missing")
exceptionChannel.trySend(ComponentException("GooglePay encountered an unexpected error"))
return
}
Expand All @@ -291,10 +291,11 @@ internal class DefaultGooglePayDelegate(
submitHandler.onSubmit(_componentStateFlow.value)
}

private fun trackThirdPartyErrorEvent() {
private fun trackThirdPartyErrorEvent(message: String) {
val event = GenericEvents.error(
component = getPaymentMethodType(),
event = ErrorEvent.THIRD_PARTY,
message = message,
)
analyticsManager.trackEvent(event)
}
Expand Down

0 comments on commit 6845eb4

Please sign in to comment.