Skip to content

Commit

Permalink
PayPalWebCheckout analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
KunJeongPark committed Jan 7, 2025
1 parent 2695c83 commit 98aade7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Sources/PayPalWebPayments/PayPalWebCheckoutClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public class PayPalWebCheckoutClient: NSObject {
/// if it fails, `PayPalWebCheckoutResult will be `nil` and `error` will describe the failure
public func start(request: PayPalWebCheckoutRequest, completion: @escaping (PayPalWebCheckoutResult?, CoreSDKError?) -> Void) {
analyticsService = AnalyticsService(coreConfig: config, orderID: request.orderID)
analyticsService?.sendEvent("paypal-web-payments:started")
analyticsService?.sendEvent("paypal-web-payments:checkout:started")

let baseURLString = config.environment.payPalBaseURL.absoluteString
let payPalCheckoutURLString =
"\(baseURLString)/checkoutnow?token=\(request.orderID)" +
Expand All @@ -54,9 +54,9 @@ public class PayPalWebCheckoutClient: NSObject {
context: self,
sessionDidDisplay: { [weak self] didDisplay in
if didDisplay {
self?.analyticsService?.sendEvent("paypal-web-payments:browser-presentation:succeeded")
self?.analyticsService?.sendEvent("paypal-web-payments:checkout:auth-challenge-presentation:succeeded")
} else {
self?.analyticsService?.sendEvent("paypal-web-payments:browser-presentation:failed")
self?.analyticsService?.sendEvent("paypal-web-payments:checkout:auth-challenge-presentation:failed")
}
},
sessionDidComplete: { url, error in
Expand Down Expand Up @@ -203,17 +203,17 @@ public class PayPalWebCheckoutClient: NSObject {
}

private func notifyCheckoutSuccess(for result: PayPalWebCheckoutResult, completion: (PayPalWebCheckoutResult?, CoreSDKError?) -> Void) {
self.analyticsService?.sendEvent("paypal-web-payments:succeeded")
self.analyticsService?.sendEvent("paypal-web-payments:checkout:auth-challenge-succeeded")
completion(result, nil)
}

private func notifyCheckoutFailure(with error: CoreSDKError, completion: (PayPalWebCheckoutResult?, CoreSDKError?) -> Void) {
self.analyticsService?.sendEvent("paypal-web-payments:failed")
self.analyticsService?.sendEvent("paypal-web-payments:checkout:auth-challenge-failed")
completion(nil, error)
}

private func notifyCheckoutCancelWithError(with error: CoreSDKError, completion: (PayPalWebCheckoutResult?, CoreSDKError?) -> Void) {
analyticsService?.sendEvent("paypal-web-payments:browser-login:canceled")
analyticsService?.sendEvent("paypal-web-payments:checkout:auth-challenge-canceled")
completion(nil, error)
}

Expand Down

0 comments on commit 98aade7

Please sign in to comment.