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

Align Analytics Event Names with iOS #310

Merged
merged 6 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -5,51 +5,57 @@ import com.paypal.android.corepayments.analytics.AnalyticsService
@Suppress("TooManyFunctions")
internal class CardAnalytics(private val analyticsService: AnalyticsService) {

// region Approve Order
fun notifyApproveOrderStarted(orderId: String) {
val eventName = "card-payments:approve-order:started"
analyticsService.sendAnalyticsEvent(eventName, orderId)
}
private object ApproveOrderEvent {
// @formatter:off
const val STARTED = "card-payments:approve-order:started"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice!

const val SUCCEEDED = "card-payments:approve-order:succeeded"
const val FAILED = "card-payments:approve-order:failed"
const val AUTH_CHALLENGE_REQUIRED = "card-payments:approve-order:auth-challenge-required"

fun notifyApproveOrderSucceeded(orderId: String) {
val eventName = "card-payments:approve-order:succeeded"
analyticsService.sendAnalyticsEvent(eventName, orderId)
}
const val AUTH_CHALLENGE_PRESENTATION_SUCCEEDED = "card-payments:approve-order:auth-challenge-presentation:succeeded"
const val AUTH_CHALLENGE_PRESENTATION_FAILED = "card-payments:approve-order:auth-challenge-presentation:failed"

fun notifyApproveOrderFailed(orderId: String) {
val eventName = "card-payments:approve-order:failed"
analyticsService.sendAnalyticsEvent(eventName, orderId)
const val AUTH_CHALLENGE_SUCCEEDED = "card-payments:approve-order:auth-challenge:succeeded"
const val AUTH_CHALLENGE_FAILED = "card-payments:approve-order:auth-challenge:failed"
const val AUTH_CHALLENGE_CANCELED = "card-payments:approve-order:auth-challenge-canceled"
Copy link
Collaborator

@KunJeongPark KunJeongPark Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this one also follows format :canceled

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 ok I think this got fixed I had some typos initially.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉🚢

// @formatter:on
}

fun notifyApproveOrderAuthChallengeReceived(orderId: String) {
val eventName = "card-payments:approve-order:auth-challenge-received"
analyticsService.sendAnalyticsEvent(eventName, orderId)
private fun sendEvent(
eventName: String,
orderId: String? = null,
setupTokenId: String? = null
) {
analyticsService.sendAnalyticsEvent(eventName, orderId ?: setupTokenId)
}

fun notifyApproveOrderAuthChallengeStarted(orderId: String?) {
val eventName = "card-payments:approve-order:auth-challenge-started"
analyticsService.sendAnalyticsEvent(eventName, orderId)
}
// region Approve Order
fun notifyApproveOrderStarted(orderId: String?) =
sendEvent(ApproveOrderEvent.STARTED, orderId = orderId)

fun notifyApproveOrderAuthChallengeSucceeded(orderId: String) {
val eventName = "card-payments:approve-order:auth-challenge-succeeded"
analyticsService.sendAnalyticsEvent(eventName, orderId)
}
fun notifyApproveOrderSucceeded(orderId: String?) =
sendEvent(ApproveOrderEvent.SUCCEEDED, orderId = orderId)

fun notifyApproveOrderAuthChallengeCanceled(orderId: String?) {
val eventName = "card-payments:approve-order:auth-challenge-canceled"
analyticsService.sendAnalyticsEvent(eventName, orderId)
}
fun notifyApproveOrderFailed(orderId: String?) =
sendEvent(ApproveOrderEvent.FAILED, orderId = orderId)

fun notifyApproveOrderAuthChallengeFailed(orderId: String?) {
val eventName = "card-payments:approve-order:auth-challenge-failed"
analyticsService.sendAnalyticsEvent(eventName, orderId)
}
fun notifyApproveOrderAuthChallengeRequired(orderId: String) =
sendEvent(ApproveOrderEvent.AUTH_CHALLENGE_REQUIRED, orderId = orderId)

fun notifyApproveOrderUnknownError(orderId: String?) {
val eventName = "card-payments:approve-order:unknown-error"
analyticsService.sendAnalyticsEvent(eventName, orderId)
}
fun notifyApproveOrderAuthChallengePresentationSucceeded(orderId: String?) =
sendEvent(ApproveOrderEvent.AUTH_CHALLENGE_PRESENTATION_SUCCEEDED, orderId = orderId)

fun notifyApproveOrderAuthChallengePresentationFailed(orderId: String?) =
sendEvent(ApproveOrderEvent.AUTH_CHALLENGE_PRESENTATION_FAILED, orderId = orderId)

fun notifyApproveOrderAuthChallengeSucceeded(orderId: String?) =
sendEvent(ApproveOrderEvent.AUTH_CHALLENGE_SUCCEEDED, orderId = orderId)

fun notifyApproveOrderAuthChallengeFailed(orderId: String?) =
sendEvent(ApproveOrderEvent.AUTH_CHALLENGE_FAILED, orderId = orderId)

fun notifyApproveOrderAuthChallengeCanceled(orderId: String?) =
sendEvent(ApproveOrderEvent.AUTH_CHALLENGE_CANCELED, orderId = orderId)
// endregion

// region Vault
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class CardClient internal constructor(
}
callback.onCardApproveOrderResult(result)
} else {
analytics.notifyApproveOrderAuthChallengeReceived(cardRequest.orderId)
analytics.notifyApproveOrderAuthChallengeRequired(cardRequest.orderId)

val url = Uri.parse(response.payerActionHref)
val authChallenge = CardAuthChallenge.ApproveOrder(url, cardRequest)
Expand Down Expand Up @@ -148,7 +148,7 @@ class CardClient internal constructor(
when (authChallenge) {
// TODO: see if we can get order id from somewhere
is CardAuthChallenge.ApproveOrder ->
analytics.notifyApproveOrderAuthChallengeStarted(null)
analytics.notifyApproveOrderAuthChallengePresentationSucceeded(null)

// TODO: see if we can get setup token from somewhere
is CardAuthChallenge.Vault ->
Expand All @@ -160,7 +160,7 @@ class CardClient internal constructor(
when (authChallenge) {
// TODO: see if we can get order id from somewhere
is CardAuthChallenge.ApproveOrder ->
analytics.notifyApproveOrderAuthChallengeFailed(null)
analytics.notifyApproveOrderAuthChallengePresentationFailed(null)

// TODO: see if we can get setup token id from somewhere
is CardAuthChallenge.Vault ->
Expand Down