Skip to content

Commit

Permalink
chore: remove unused code and rename analytic events
Browse files Browse the repository at this point in the history
  • Loading branch information
erenbesel committed Feb 7, 2024
1 parent 6212915 commit 45a64c3
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 62 deletions.
53 changes: 0 additions & 53 deletions Adyen/Analytics/AnalyticsProvider/AnalyticsProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,6 @@ public protocol AnalyticsProviderProtocol {
func sendInitialAnalytics(with flavor: TelemetryFlavor, additionalFields: AdditionalAnalyticsFields?)

var checkoutAttemptId: String? { get }

/// Sends an info event to Checkout Anayltics
func send(info: AnalyticsEventInfo)

/// Sends a log event to Checkout Anayltics
func send(log: AnalyticsEventLog)

/// Sends an error event to Checkout Anayltics
func send(error: AnalyticsEventError)
}

internal final class AnalyticsProvider: AnalyticsProviderProtocol {
Expand All @@ -67,10 +58,6 @@ internal final class AnalyticsProvider: AnalyticsProviderProtocol {
internal let configuration: AnalyticsConfiguration
internal private(set) var checkoutAttemptId: String?
private let uniqueAssetAPIClient: UniqueAssetAPIClient<InitialAnalyticsResponse>

private var infos: [AnalyticsEventInfo] = []
private var logs: [AnalyticsEventLog] = []
private var errors: [AnalyticsEventError] = []

// MARK: - Initializers

Expand Down Expand Up @@ -107,44 +94,4 @@ internal final class AnalyticsProvider: AnalyticsProviderProtocol {
}
}
}

internal func send(info: AnalyticsEventInfo) {
infos.append(info)
}

internal func send(log: AnalyticsEventLog) {
logs.append(log)
}

internal func send(error: AnalyticsEventError) {
errors.append(error)
sendAll()
}

private func setupTimer() {
let timer = Timer(timeInterval: 10, target: self, selector: #selector(sendAll), userInfo: nil, repeats: true)
timer.tolerance = 1
RunLoop.current.add(timer, forMode: .common)
}

@objc private func sendAll() {
guard configuration.isEnabled,
let checkoutAttemptId else { return }
var request = AnalyticsRequest(checkoutAttemptId: checkoutAttemptId)

request.infos = infos
request.logs = logs
request.errors = errors

apiClient.perform(request) { [weak self] _ in
guard let self else { return }
self.clearAll()
}
}

private func clearAll() {
infos = []
logs = []
errors = []
}
}
9 changes: 0 additions & 9 deletions Adyen/Core/Core Protocols/PresentableComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,13 @@ public protocol TrackableComponent: Component {

/// Sends the initial data and retireves the checkout attempt id
func sendInitialAnalytics()

/// Sent when the component is first displayed on the screen.
func sendComponentDidLoadEvent()
}

@_spi(AdyenInternal)
extension TrackableComponent where Self: ViewControllerDelegate {

public func viewDidLoad(viewController: UIViewController) {
sendInitialAnalytics()
sendComponentDidLoadEvent()
}
}

Expand All @@ -91,9 +87,4 @@ extension TrackableComponent where Self: PaymentMethodAware {
context.analyticsProvider?.sendInitialAnalytics(with: flavor,
additionalFields: additionalFields)
}

public func sendComponentDidLoadEvent() {
let info = AnalyticsEventInfo(component: paymentMethod.type.rawValue, type: .rendered)
context.analyticsProvider?.send(info: info)
}
}

0 comments on commit 45a64c3

Please sign in to comment.