Skip to content

Commit

Permalink
Merge pull request #1929 from Adyen/feature/analytics_add_message_for…
Browse files Browse the repository at this point in the history
…_error_events

Analytics - Add message for error events
  • Loading branch information
araratthehero authored Dec 12, 2024
2 parents b4473d2 + 6845eb4 commit 88b04a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 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
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,12 @@ internal class DefaultTwintActionDelegate(
}

TwintPayResult.TW_B_ERROR -> {
trackThirdPartyErrorEvent()
trackThirdPartyErrorEvent("Twint result is error")
onError(ComponentException("Twint encountered an error."))
}

TwintPayResult.TW_B_APP_NOT_INSTALLED -> {
trackThirdPartyErrorEvent()
trackThirdPartyErrorEvent("Twint app not installed")
onError(ComponentException("Twint app not installed."))
}
}
Expand Down Expand Up @@ -223,10 +223,11 @@ internal class DefaultTwintActionDelegate(
)
}

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

0 comments on commit 88b04a8

Please sign in to comment.