diff --git a/Sources/BraintreeShopperInsights/BTShopperInsightsClient.swift b/Sources/BraintreeShopperInsights/BTShopperInsightsClient.swift index df256b7be..72d760fd6 100644 --- a/Sources/BraintreeShopperInsights/BTShopperInsightsClient.swift +++ b/Sources/BraintreeShopperInsights/BTShopperInsightsClient.swift @@ -122,7 +122,11 @@ public class BTShopperInsightsClient { /// Call this method when a button has been selected/tapped by the buyer. /// This method sends analytics to help improve the Shopper Insights feature experience. public func sendSelectedEvent(for buttonType: BTButtonType) { - apiClient.sendAnalyticsEvent(BTShopperInsightsAnalytics.buttonSelected, shopperSessionID: shopperSessionID) + apiClient.sendAnalyticsEvent( + BTShopperInsightsAnalytics.buttonSelected, + buttonType: buttonType.rawValue, + shopperSessionID: shopperSessionID + ) } /// Indicates whether the PayPal App is installed. diff --git a/UnitTests/BraintreePayPalTests/BTPayPalClient_Tests.swift b/UnitTests/BraintreePayPalTests/BTPayPalClient_Tests.swift index 7d112d2d3..14527dbb6 100644 --- a/UnitTests/BraintreePayPalTests/BTPayPalClient_Tests.swift +++ b/UnitTests/BraintreePayPalTests/BTPayPalClient_Tests.swift @@ -982,24 +982,6 @@ class BTPayPalClient_Tests: XCTestCase { XCTAssertNil(lastPostParameters["merchant_app_return_url"] as? String) } - func testInvokedOpenURLSuccessfully_whenSuccess_sendsAppSwitchSucceededWithAppSwitchURL() { - let eventName = BTPayPalAnalytics.appSwitchSucceeded - let fakeURL = URL(string: "some-url")! - payPalClient.invokedOpenURLSuccessfully(true, url: fakeURL) { _, _ in } - - XCTAssertEqual(mockAPIClient.postedAnalyticsEvents.last!, eventName) - XCTAssertEqual(mockAPIClient.postedAppSwitchURL[eventName], fakeURL.absoluteString) - } - - func testInvokedOpenURLSuccessfully_whenFailure_sendsAppSwitchFailedWithAppSwitchURL() { - let eventName = BTPayPalAnalytics.appSwitchFailed - let fakeURL = URL(string: "some-url")! - payPalClient.invokedOpenURLSuccessfully(false, url: fakeURL) { _, _ in } - - XCTAssertEqual(mockAPIClient.postedAnalyticsEvents.first!, eventName) - XCTAssertEqual(mockAPIClient.postedAppSwitchURL[eventName], fakeURL.absoluteString) - } - // MARK: - Analytics func testAPIClientMetadata_hasIntegrationSetToCustom() { diff --git a/UnitTests/BraintreeShopperInsightsTests/BTShopperInsightsClient_Tests.swift b/UnitTests/BraintreeShopperInsightsTests/BTShopperInsightsClient_Tests.swift index 96dbb22a2..413598691 100644 --- a/UnitTests/BraintreeShopperInsightsTests/BTShopperInsightsClient_Tests.swift +++ b/UnitTests/BraintreeShopperInsightsTests/BTShopperInsightsClient_Tests.swift @@ -224,8 +224,9 @@ class BTShopperInsightsClient_Tests: XCTestCase { sut.sendSelectedEvent(for: .payPal) XCTAssertEqual(mockAPIClient.postedAnalyticsEvents.first, "shopper-insights:button-selected") XCTAssertEqual(mockAPIClient.postedShopperSessionID, "fake-shopper-session-id") + XCTAssertEqual(mockAPIClient.postedButtonType, "PayPal") } - + func testSendVenmoPresentedEvent_sendsAnalytic() { sut.sendVenmoPresentedEvent() XCTAssertEqual(mockAPIClient.postedAnalyticsEvents.first, "shopper-insights:venmo-presented") @@ -235,6 +236,7 @@ class BTShopperInsightsClient_Tests: XCTestCase { func testSendVenmoSelectedEvent_sendsAnalytic() { sut.sendSelectedEvent(for: .venmo) XCTAssertEqual(mockAPIClient.postedAnalyticsEvents.first, "shopper-insights:button-selected") + XCTAssertEqual(mockAPIClient.postedButtonType, "Venmo") } func testShopperInsightsClient_withSessionID_setSessionIDInMetadata() { diff --git a/UnitTests/BraintreeTestShared/MockAPIClient.swift b/UnitTests/BraintreeTestShared/MockAPIClient.swift index b88dd1e46..80665cebf 100644 --- a/UnitTests/BraintreeTestShared/MockAPIClient.swift +++ b/UnitTests/BraintreeTestShared/MockAPIClient.swift @@ -11,7 +11,8 @@ public class MockAPIClient: BTAPIClient { public var lastGETParameters = [:] as [String: Any]? public var lastGETAPIClientHTTPType: BTAPIClientHTTPService? - public var postedAnalyticsEvents : [String] = [] + public var postedButtonType: String? = nil + public var postedAnalyticsEvents: [String] = [] public var postedPayPalContextID: String? = nil public var postedLinkType: LinkType? = nil public var postedIsVaultRequest = false @@ -106,6 +107,7 @@ public class MockAPIClient: BTAPIClient { appSwitchURL: URL? = nil, shopperSessionID: String? = nil ) { + postedButtonType = buttonType postedPayPalContextID = payPalContextID postedLinkType = linkType postedIsVaultRequest = isVaultRequest ?? false