Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analytics - Track third party error events - Google pay #1900

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -231,16 +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()
exceptionChannel.trySend(ComponentException("GooglePay encountered an error$statusMessage"))
}

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

else -> {
adyenLog(AdyenLogLevel.ERROR) { "GooglePay encountered an unexpected error, statusCode: $statusCode" }
trackThirdPartyErrorEvent()
exceptionChannel.trySend(ComponentException("GooglePay encountered an unexpected error"))
}
}
Expand Down Expand Up @@ -275,6 +278,7 @@ internal class DefaultGooglePayDelegate(
private fun initiatePayment(paymentData: PaymentData?) {
if (paymentData == null) {
adyenLog(AdyenLogLevel.ERROR) { "Payment data is null" }
trackThirdPartyErrorEvent()
exceptionChannel.trySend(ComponentException("GooglePay encountered an unexpected error"))
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,20 @@ internal class DefaultGooglePayDelegateTest(
analyticsManager.assertIsCleared()
}

@ParameterizedTest
@MethodSource("com.adyen.checkout.googlepay.internal.ui.DefaultGooglePayDelegateTest#paymentResultErrorSource")
fun `when handling payment result is error, then error event is tracked`(
result: ApiTaskResult<PaymentData>
) {
delegate.handlePaymentResult(result)

val expectedEvent = GenericEvents.error(
component = TEST_PAYMENT_METHOD_TYPE,
event = ErrorEvent.THIRD_PARTY,
)
analyticsManager.assertLastEventEquals(expectedEvent)
}

@Test
fun `when activity result is OK and data is null, then error event is tracked`() {
delegate.handleActivityResult(Activity.RESULT_OK, data = null)
Expand Down Expand Up @@ -426,5 +440,14 @@ internal class DefaultGooglePayDelegateTest(
arguments(true, false, false, GooglePayUnavailableException()),
arguments(true, true, true, null),
)

@JvmStatic
fun paymentResultErrorSource() = listOf(
// result
arguments(ApiTaskResult(null, Status.RESULT_SUCCESS)),
arguments(ApiTaskResult(null, Status.RESULT_INTERNAL_ERROR)),
arguments(ApiTaskResult(null, Status.RESULT_INTERRUPTED)),
arguments(ApiTaskResult(null, Status(AutoResolveHelper.RESULT_ERROR))),
)
}
}
Loading