Skip to content

Commit fe2f27d

Browse files
committed
card vault analytics changes
1 parent a6e9468 commit fe2f27d

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

Sources/CardPayments/CardClient.swift

+20-10
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class CardClient: NSObject {
5353
if result.status == "PAYER_ACTION_REQUIRED",
5454
let urlString = result.links.first(where: { $0.rel == "approve" })?.href {
5555
guard urlString.contains("helios"), let url = URL(string: urlString) else {
56-
self.notifyVaultFailure(with: CardError.threeDSecureURLError, completion: completion)
56+
self.notify3dsVaultFailure(with: CardError.threeDSecureURLError, completion: completion)
5757
return
5858
}
5959
analyticsService?.sendEvent("card-payments:vault-wo-purchase:challenge-required")
@@ -157,9 +157,9 @@ public class CardClient: NSObject {
157157
context: self,
158158
sessionDidDisplay: { [weak self] didDisplay in
159159
if didDisplay {
160-
self?.analyticsService?.sendEvent("card-payments:approve-order:challenge-presentation:succeeded")
160+
self?.analyticsService?.sendEvent("card-payments:approve-order:auth-challenge-presentation:succeeded")
161161
} else {
162-
self?.analyticsService?.sendEvent("card-payments:approve-order:challenge-presentation:failed")
162+
self?.analyticsService?.sendEvent("card-payments:approve-order:auth-challenge-presentation:failed")
163163
}
164164
},
165165
sessionDidComplete: { _, error in
@@ -197,25 +197,25 @@ public class CardClient: NSObject {
197197
sessionDidDisplay: { [weak self] didDisplay in
198198
if didDisplay {
199199
// TODO: analytics for card vault
200-
self?.analyticsService?.sendEvent("card-payments:3ds:challenge-presentation:succeeded")
200+
self?.analyticsService?.sendEvent("card-payments:vault-wo-purchase:auth-challenge-presentation:succeeded")
201201
} else {
202-
self?.analyticsService?.sendEvent("card-payments:3ds:challenge-presentation:failed")
202+
self?.analyticsService?.sendEvent("card-payments:vault-wo-purchase:auth-challenge-presentation:failed")
203203
}
204204
},
205205
sessionDidComplete: { _, error in
206206
if let error = error {
207207
switch error {
208208
case ASWebAuthenticationSessionError.canceledLogin:
209-
self.notifyVaultCancelWithError(with: CardError.threeDSecureCanceledError, completion: completion)
209+
self.notify3dsVaultCancelWithError(with: CardError.threeDSecureCanceledError, completion: completion)
210210
return
211211
default:
212-
self.notifyVaultFailure(with: CardError.threeDSecureError(error), completion: completion)
212+
self.notify3dsVaultFailure(with: CardError.threeDSecureError(error), completion: completion)
213213
return
214214
}
215215
}
216216

217217
let cardVaultResult = CardVaultResult(setupTokenID: setupTokenID, status: nil, didAttemptThreeDSecureAuthentication: true)
218-
self.notifyVaultSuccess(for: cardVaultResult, completion: completion)
218+
self.notify3dsVaultSuccess(for: cardVaultResult, completion: completion)
219219
}
220220
)
221221
}
@@ -250,13 +250,23 @@ public class CardClient: NSObject {
250250
completion(vaultResult, nil)
251251
}
252252

253+
private func notify3dsVaultSuccess(for vaultResult: CardVaultResult, completion: (CardVaultResult?, CoreSDKError?) -> Void) {
254+
analyticsService?.sendEvent("card-payments:vault-wo-purchase:auth-challenge-succeeded")
255+
completion(vaultResult, nil)
256+
}
257+
253258
private func notifyVaultFailure(with vaultError: CoreSDKError, completion: (CardVaultResult?, CoreSDKError?) -> Void) {
254259
analyticsService?.sendEvent("card-payments:vault-wo-purchase:failed")
255260
completion(nil, vaultError)
256261
}
257262

258-
private func notifyVaultCancelWithError(with vaultError: CoreSDKError, completion: (CardVaultResult?, CoreSDKError?) -> Void) {
259-
analyticsService?.sendEvent("card-payments:vault-wo-purchase:challenge:canceled")
263+
private func notify3dsVaultFailure(with vaultError: CoreSDKError, completion: (CardVaultResult?, CoreSDKError?) -> Void) {
264+
analyticsService?.sendEvent("card-payments:vault-wo-purchase:auth-challenge-failed")
265+
completion(nil, vaultError)
266+
}
267+
268+
private func notify3dsVaultCancelWithError(with vaultError: CoreSDKError, completion: (CardVaultResult?, CoreSDKError?) -> Void) {
269+
analyticsService?.sendEvent("card-payments:vault-wo-purchase:auth-challenge-canceled")
260270
completion(nil, vaultError)
261271
}
262272
}

0 commit comments

Comments
 (0)