-
Notifications
You must be signed in to change notification settings - Fork 295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shopper Insights - Added Presentment Details Object and Update Presented Events #1484
Shopper Insights - Added Presentment Details Object and Update Presented Events #1484
Conversation
…/braintree/braintree_ios into shopper-insights-rp2-presentment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like there is a compiler issue currently causing the build to fail that we will want to address. Also, do we want to add unit tests to this PR or do you want to make a follow up ticket for testing?
I was working on trying to figure out why there's a compiler issue yesterday. It's likely due to a bad merge from a parent branch. Will continue to figure it out today I wrote tests in |
…/braintree/braintree_ios into shopper-insights-rp2-presentment
I added a few more tests to check that |
case connectionStartTime = "connect_start_time" | ||
case correlationID = "correlation_id" | ||
case errorDescription = "error_desc" | ||
case eventName = "event_name" | ||
case experimentType = "experiment_type" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed, we don't need this, lets reuse merchantExperiment
below
…/braintree/braintree_ios into shopper-insights-rp2-presentment # Conflicts: # Sources/BraintreeShopperInsights/BTShopperInsightsClient.swift
/// - Warning: This module is in beta. It's public API may change or be removed in future releases. | ||
public enum BTButtonOrder: String { | ||
|
||
/// 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets update these docstrings to represent the values accurately
/// The experiment type that is sent to analytics to help improve the Shopper Insights feature experience. | ||
let experimentType: String? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can delete this and use the experiment that already exists
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) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets revert deleting these tests
…ntment analytics at the correct time.
…-presentment # Conflicts: # CHANGELOG.md # Sources/BraintreePayPal/BTPayPalClient.swift
private func togglePayPalVaultButton(enabled: Bool) { | ||
payPalVaultButton.isEnabled = enabled | ||
|
||
guard enabled else { return } | ||
|
||
let presentmentDetails = BTPresentmentDetails( | ||
buttonOrder: .first, | ||
experimentType: .control, | ||
pageType: .about | ||
) | ||
|
||
shopperInsightsClient.sendPresentedEvent( | ||
for: .payPal, | ||
presentmentDetails: presentmentDetails | ||
) | ||
} | ||
|
||
private func toggleVenmoButton(enabled: Bool) { | ||
venmoButton.isEnabled = enabled | ||
|
||
guard enabled else { return } | ||
|
||
let presentmentDetails = BTPresentmentDetails( | ||
buttonOrder: .second, | ||
experimentType: .control, | ||
pageType: .about | ||
) | ||
|
||
shopperInsightsClient.sendPresentedEvent( | ||
for: .venmo, | ||
presentmentDetails: presentmentDetails | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take it or leave it but we could combine this logic if we wanted:
private func togglePayPalVaultButton(enabled: Bool) { | |
payPalVaultButton.isEnabled = enabled | |
guard enabled else { return } | |
let presentmentDetails = BTPresentmentDetails( | |
buttonOrder: .first, | |
experimentType: .control, | |
pageType: .about | |
) | |
shopperInsightsClient.sendPresentedEvent( | |
for: .payPal, | |
presentmentDetails: presentmentDetails | |
) | |
} | |
private func toggleVenmoButton(enabled: Bool) { | |
venmoButton.isEnabled = enabled | |
guard enabled else { return } | |
let presentmentDetails = BTPresentmentDetails( | |
buttonOrder: .second, | |
experimentType: .control, | |
pageType: .about | |
) | |
shopperInsightsClient.sendPresentedEvent( | |
for: .venmo, | |
presentmentDetails: presentmentDetails | |
) | |
} | |
private func toggleButtons(result: BTShopperInsightsResult) { | |
payPalVaultButton.isEnabled = result.isPayPalRecommended | |
venmoButton.isEnabled = result.isVenmoRecommended | |
let payPalPresentmentDetails = BTPresentmentDetails( | |
buttonOrder: .first, | |
experimentType: .control, | |
pageType: .about | |
) | |
let venmoPresentmentDetails = BTPresentmentDetails( | |
buttonOrder: .second, | |
experimentType: .control, | |
pageType: .about | |
) | |
if result.isPayPalRecommended { | |
shopperInsightsClient.sendPresentedEvent( | |
for: .payPal, | |
presentmentDetails: payPalPresentmentDetails | |
) | |
} | |
if result.isVenmoRecommended { | |
shopperInsightsClient.sendPresentedEvent( | |
for: .venmo, | |
presentmentDetails: venmoPresentmentDetails | |
) | |
} | |
} |
Summary of changes
BTButtonType
enumBTButtonOrder
enumBTExperimentType
enumBTPageType
enumsendPayPalPresentedEvent
andsendVenmoPresentedEvent
tosendPresentedEvent(for buttonType: BTButtonType, presentmentDetails: BTPresentmentDetails)
Checklist
Authors