Skip to content

Commit

Permalink
Analytics in apple pay component (#1947)
Browse files Browse the repository at this point in the history
# Summary

Generic analytics code via the `ViewControllerDelegate` on
`TrackableComponent` does not work on `ApplePayComponent` as its view
controller is not a `FormViewController`.

Call analytics explicitly here and remove redundant conformance to
`ViewControllerDelegate`


# Ticket

<ticket>
COIOS-849
</ticket>
  • Loading branch information
erenbesel authored Jan 15, 2025
1 parent aca3c4c commit 4f3a04d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions AdyenComponents/Apple Pay/ApplePayComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ public class ApplePayComponent: NSObject, PresentableComponent, PaymentComponent
super.init()

paymentAuthorizationViewController?.delegate = self
sendInitialAnalytics()
}

public var viewController: UIViewController {
createPaymentAuthorizationViewController()
sendDidLoadEvent()
return createPaymentAuthorizationViewController()
}

public func didFinalize(with success: Bool, completion: (() -> Void)?) {
Expand Down Expand Up @@ -130,6 +132,3 @@ extension ApplePayComponent {

@_spi(AdyenInternal)
extension ApplePayComponent: TrackableComponent {}

@_spi(AdyenInternal)
extension ApplePayComponent: ViewControllerDelegate {}
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ class ApplePayComponentTest: XCTestCase {
)

// When
sut.viewDidLoad(viewController: mockViewController)
sut.viewController.loadViewIfNeeded()

// Then
XCTAssertEqual(analyticsProviderMock.initialEventCallsCount, 1)
Expand Down

0 comments on commit 4f3a04d

Please sign in to comment.