Skip to content

Commit

Permalink
chore: remove unused analytics flavor
Browse files Browse the repository at this point in the history
  • Loading branch information
erenbesel committed Feb 8, 2024
1 parent 87a69e2 commit 7e1a7f3
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 41 deletions.
7 changes: 0 additions & 7 deletions Adyen/Analytics/AnalyticsProvider/AnalyticsFlavor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,12 @@ public enum AnalyticsFlavor {
case components(type: PaymentMethodType)
case dropIn(type: String = "dropin", paymentMethods: [String])

// The `dropInComponent` type describes a component within the drop-in component.
// In analytics, we need to distinguish when a component is used from the drop-in
// and when it's used as standalone.
case dropInComponent

public var value: String {
switch self {
case .components:
return "components"
case .dropIn:
return "dropin"
case .dropInComponent:
return "dropInComponent"
}
}
}
1 change: 0 additions & 1 deletion Adyen/Analytics/AnalyticsProvider/AnalyticsProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ internal final class AnalyticsProvider: AnalyticsProviderProtocol {
checkoutAttemptId = "do-not-track"
return
}
if case .dropInComponent = flavor { return }

let analyticsData = AnalyticsData(flavor: flavor,
additionalFields: additionalFields,
Expand Down
20 changes: 2 additions & 18 deletions Tests/Adyen Tests/Analytics/AnalyticsEventTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,9 @@ class AnalyticsEventTests: XCTestCase {
XCTAssertEqual(sut.checkoutAttemptId, "do-not-track")
}

func testSendInitialEventGivenEnabledAndFlavorIsDropInComponentShouldNotSendAnyRequest() throws {
// Given
var analyticsConfiguration = AnalyticsConfiguration()
sut = AnalyticsProvider(apiClient: apiClient, configuration: analyticsConfiguration)

let flavor: AnalyticsFlavor = .dropInComponent
let expectedRequestCalls = 0

// When
sendInitialAnalytics(flavor: flavor)

// Then
XCTAssertEqual(expectedRequestCalls, apiClient.counter, "One or more analytics requests were sent.")
XCTAssertNil(sut.checkoutAttemptId)
}

func testSendInitialEventGivenEnabledAndFlavorIsComponentsShouldSendInitialRequest() throws {
// Given
var analyticsConfiguration = AnalyticsConfiguration()
let analyticsConfiguration = AnalyticsConfiguration()
sut = AnalyticsProvider(apiClient: apiClient, configuration: analyticsConfiguration)

let flavor: AnalyticsFlavor = .components(type: .affirm)
Expand All @@ -88,7 +72,7 @@ class AnalyticsEventTests: XCTestCase {

func testSendInitialEventGivenEnabledAndFlavorIsDropInShouldSendInitialRequest() throws {
// Given
var analyticsConfiguration = AnalyticsConfiguration()
let analyticsConfiguration = AnalyticsConfiguration()
sut = AnalyticsProvider(apiClient: apiClient, configuration: analyticsConfiguration)

let flavor: AnalyticsFlavor = .dropIn(paymentMethods: ["scheme", "paypal", "affirm"])
Expand Down
11 changes: 0 additions & 11 deletions Tests/Adyen Tests/Analytics/AnalyticsFlavorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,4 @@ class AnalyticsFlavorTests: XCTestCase {
// Then
XCTAssertEqual(expectedFlavorValue, sut.value)
}

func testAnalyticsFlavorValueWhenFlavorIsDropInComponentMatchesFlavorType() throws {
// Given
let expectedFlavorValue = "dropInComponent"

// When
sut = .dropInComponent

// Then
XCTAssertEqual(expectedFlavorValue, sut.value)
}
}
8 changes: 4 additions & 4 deletions Tests/Adyen Tests/Analytics/AnalyticsProviderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class AnalyticsProviderTests: XCTestCase {
apiClient.mockedResults = [checkoutAttemptIdResult]

// When
sut.sendInitialAnalytics(with: .dropInComponent, additionalFields: nil)
sut.sendInitialAnalytics(with: .components(type: .atome), additionalFields: nil)
// Then
XCTAssertNil(sut.checkoutAttemptId, "The checkoutAttemptId is not nil.")
}
Expand Down Expand Up @@ -202,7 +202,7 @@ class AnalyticsProviderTests: XCTestCase {

func testInitialRequestEncoding() throws {

let analyticsData = AnalyticsData(flavor: .dropInComponent,
let analyticsData = AnalyticsData(flavor: .components(type: .achDirectDebit),
additionalFields: AdditionalAnalyticsFields(amount: .init(value: 1, currencyCode: "EUR"), sessionId: "test_session_id"),
context: AnalyticsContext(version: "version", platform: .flutter))

Expand All @@ -215,8 +215,8 @@ class AnalyticsProviderTests: XCTestCase {
"locale": "en_US",
"paymentMethods": analyticsData.paymentMethods,
"platform": "flutter",
"component": "",
"flavor": "dropInComponent",
"component": "ach",
"flavor": "components",
"channel": "iOS",
"systemVersion": analyticsData.systemVersion,
"screenWidth": analyticsData.screenWidth,
Expand Down

0 comments on commit 7e1a7f3

Please sign in to comment.