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

Clean up Analytics Names #313

Merged
merged 8 commits into from
Jan 9, 2025
Merged
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
16 changes: 8 additions & 8 deletions Sources/CardPayments/CardClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public class CardClient: NSObject {
/// if it fails, `CardResult will be `nil` and `error` will describe the failure
public func approveOrder(request: CardRequest, completion: @escaping (CardResult?, CoreSDKError?) -> Void) {
analyticsService = AnalyticsService(coreConfig: config, orderID: request.orderID)
analyticsService?.sendEvent("card-payments:3ds:started")
analyticsService?.sendEvent("card-payments:approve-order:started")
Task {
do {
let result = try await checkoutOrdersAPI.confirmPaymentSource(cardRequest: request)
Expand All @@ -113,19 +113,19 @@ public class CardClient: NSObject {
return
}

analyticsService?.sendEvent("card-payments:3ds:confirm-payment-source:challenge-required")
analyticsService?.sendEvent("card-payments:confirm-payment-source:challenge-required")
KunJeongPark marked this conversation as resolved.
Show resolved Hide resolved
startThreeDSecureChallenge(url: url, orderId: result.id, completion: completion)
} else {
analyticsService?.sendEvent("card-payments:3ds:confirm-payment-source:succeeded")
analyticsService?.sendEvent("card-payments:confirm-payment-source:succeeded")

let cardResult = CardResult(orderID: result.id, status: result.status, didAttemptThreeDSecureAuthentication: false)
notifyCheckoutSuccess(for: cardResult, completion: completion)
}
} catch let error as CoreSDKError {
analyticsService?.sendEvent("card-payments:3ds:confirm-payment-source:failed")
analyticsService?.sendEvent("card-payments:confirm-payment-source:failed")
notifyCheckoutFailure(with: error, completion: completion)
} catch {
analyticsService?.sendEvent("card-payments:3ds:confirm-payment-source:failed")
analyticsService?.sendEvent("card-payments:confirm-payment-source:failed")
notifyCheckoutFailure(with: CardError.unknownError, completion: completion)
}
}
Expand Down Expand Up @@ -225,17 +225,17 @@ public class CardClient: NSObject {
}

private func notifyCheckoutSuccess(for result: CardResult, completion: (CardResult?, CoreSDKError?) -> Void) {
analyticsService?.sendEvent("card-payments:3ds:succeeded")
analyticsService?.sendEvent("card-payments:approve-order:succeeded")
completion(result, nil)
}

private func notifyCheckoutFailure(with error: CoreSDKError, completion: (CardResult?, CoreSDKError?) -> Void) {
analyticsService?.sendEvent("card-payments:3ds:failed")
analyticsService?.sendEvent("card-payments:approve-order:failed")
completion(nil, error)
}

private func notifyCheckoutCancelWithError(with error: CoreSDKError, completion: (CardResult?, CoreSDKError?) -> Void) {
analyticsService?.sendEvent("card-payments:3ds:challenge:user-canceled")
analyticsService?.sendEvent("card-payments:approve-order:challenge:user-canceled")
KunJeongPark marked this conversation as resolved.
Show resolved Hide resolved
completion(nil, error)
}

Expand Down