Skip to content
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 rp2 feature presentment details #1244

Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d4a85d8
Add new classes and enums
warmkesselj Dec 11, 2024
4c06919
Update new objects, introduce new method
warmkesselj Dec 11, 2024
a70f898
Use a data class instead
warmkesselj Dec 16, 2024
216747e
Use the built in functionality to convert the treatment to a string
warmkesselj Dec 16, 2024
89231d0
Update content, update analyticsEventParam to take in a buttonType
warmkesselj Dec 16, 2024
fdcd77f
Use refactored sendPresentedEvent fun
warmkesselj Dec 16, 2024
81bcb92
Remove comments
warmkesselj Dec 16, 2024
41b4dc9
Update sendPresentedEvent signature
warmkesselj Dec 16, 2024
1947e24
Remove unused methods
warmkesselj Dec 16, 2024
a633a70
Update comments button order
warmkesselj Dec 16, 2024
d7bfdd7
Update comments for button type
warmkesselj Dec 16, 2024
3cbe0c5
Update comments
warmkesselj Dec 16, 2024
c47c6f6
Update signature
warmkesselj Dec 16, 2024
112fff9
Merge branch 'shopper-insights-rp2-feature' into shopper-insights-rp2…
warmkesselj Dec 16, 2024
d4cef52
Resolve conflicts
warmkesselj Dec 16, 2024
60f8099
Update PresentmentDetails signature
warmkesselj Dec 16, 2024
286e86d
Update analyticsEvent and add button selected string name
warmkesselj Dec 16, 2024
658441d
Add comment for shopperSessionId
warmkesselj Dec 16, 2024
310f988
Update AnalyticsClient
warmkesselj Dec 17, 2024
6da4705
Update unit test
warmkesselj Dec 17, 2024
94ec46f
Update presentment signature
warmkesselj Dec 17, 2024
5cc6d72
Add changelog
warmkesselj Dec 17, 2024
a61449c
Remove shopperSessionId from signature
warmkesselj Dec 17, 2024
1efab3f
Remove comment
warmkesselj Dec 17, 2024
48bb650
Remove extra line
warmkesselj Dec 17, 2024
108709e
Fix lint issues
warmkesselj Dec 17, 2024
2900826
Newline
warmkesselj Dec 17, 2024
c51062b
Update unit test to test venmo and control type button
warmkesselj Dec 17, 2024
f0bfe7d
Lint issues
warmkesselj Dec 17, 2024
9aa01a5
Update ButtonOrder
warmkesselj Dec 17, 2024
8487b8e
Update keys
warmkesselj Dec 17, 2024
c03d4eb
PR Comments
warmkesselj Dec 18, 2024
9cc981e
Analytics update
warmkesselj Dec 18, 2024
be84b9f
Add accessors to enum func to get internal string value
warmkesselj Dec 18, 2024
043d4ac
Use upper case notation for enums with a string representation for th…
warmkesselj Dec 18, 2024
1cc0285
Updates
warmkesselj Dec 18, 2024
8fab98f
Fix unit test
warmkesselj Dec 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@ data class AnalyticsEventParams @JvmOverloads constructor(
var endpoint: String? = null,
val experiment: String? = null,
val paymentMethodsDisplayed: List<String> = emptyList(),
val appSwitchUrl: String? = null
val appSwitchUrl: String? = null,
sarahkoop marked this conversation as resolved.
Show resolved Hide resolved
val buttonType: String? = null,
val buttonOrder: String? = null,
val pageType: String? = null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't technically need doc strings for this class, but since we have them for all other params lets add them for consistency and for our future reference

)
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ import com.braintreepayments.api.paypal.PayPalPaymentAuthRequest
import com.braintreepayments.api.paypal.PayPalPaymentAuthResult
import com.braintreepayments.api.paypal.PayPalPendingRequest
import com.braintreepayments.api.paypal.PayPalResult
import com.braintreepayments.api.shopperinsights.ButtonOrder
import com.braintreepayments.api.shopperinsights.ButtonType
import com.braintreepayments.api.shopperinsights.ExperimentType
import com.braintreepayments.api.shopperinsights.PageType
import com.braintreepayments.api.shopperinsights.PresentmentDetails
import com.braintreepayments.api.shopperinsights.ShopperInsightsBuyerPhone
import com.braintreepayments.api.shopperinsights.ShopperInsightsClient
import com.braintreepayments.api.shopperinsights.ShopperInsightsRequest
Expand Down Expand Up @@ -191,18 +196,28 @@ class ShopperInsightsFragment : BaseFragment() {
is ShopperInsightsResult.Success -> {
if (result.response.isPayPalRecommended) {
payPalVaultButton.isEnabled = true
shopperInsightsClient.sendPayPalPresentedEvent(
"""{"exp_name":"PaymentReady","treatment_name":"control"}""",
listOf("PayPal", "Venmo", "other")
shopperInsightsClient.sendPresentedEvent(
PresentmentDetails("PaymentReady", ExperimentType.CONTROL),
listOf("PayPal", "Venmo", "other"),
ButtonType.PAYPAL,
ButtonOrder.OTHER,
PageType.HOMEPAGE
)

//"""{"exp_name":"PaymentReady","treatment_name":"control"}""",
}

if (result.response.isVenmoRecommended) {
venmoButton.isEnabled = true
shopperInsightsClient.sendVenmoPresentedEvent(
"""{"exp_name":"PaymentReady","treatment_name":"test"}""",
listOf("Venmo", "PayPal", "other")
shopperInsightsClient.sendPresentedEvent(
PresentmentDetails("PaymentReady", ExperimentType.TEST),
listOf("Venmo", "PayPal", "other"),
ButtonType.VENMO,
ButtonOrder.OTHER,
PageType.HOMEPAGE
)

//"""{"exp_name":"PaymentReady","treatment_name":"test"}""",
}

responseTextView.text =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.braintreepayments.api.shopperinsights

/**
* The order or ranking in which payment buttons appear.
*/
enum class ButtonOrder {

/**
* First place
*/
FIRST,

/**
* Second place
*/
SECOND,

/**
* Third place
*/
THIRD,

/**
* Fourth place
*/
FOURTH,

/**
* Fifth place
*/
FIFTH,

/**
* Sixth place
*/
SIXTH,

/**
* Seventh place
*/
SEVENTH,

/**
* Eighth place
*/
Eights,

/**
* Greater than Eighth place
*/
OTHER
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.braintreepayments.api.shopperinsights

/**
The button type to be displayed or presented.
*/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/**
The button type to be displayed or presented.
*/
/**
* The button type to be displayed or presented.
*/

enum class ButtonType(internal val stringValue: String) {
/**
* PayPal button
*/
PAYPAL("paypal"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PAYPAL("paypal"),
PAYPAL("PayPal"),


/**
* Venmo button
*/
VENMO("venmo"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
VENMO("venmo"),
VENMO("Venmo"),


/**
* Other button
*/
OTHER("other"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
OTHER("other"),
OTHER("Other"),

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.braintreepayments.api.shopperinsights

enum class ExperimentType {
CONTROL,
TEST
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.braintreepayments.api.shopperinsights

/**
* The page or view that a button is displayed on.
*/
enum class PageType {
/**
* The homepage
*/
HOMEPAGE,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does capitalization here matter? On iOS we are sending these all lowercase values - wondering if we should do the same on Android


/**
* The about page
*/
ABOUT,

/**
* The contact page
*/
CONTACT,

/**
* A product category page
*/
PRODUCT_CATEGORY,

/**
* The product details page
*/
PRODUCT_DETAILS,

/**
* The search page
*/
SEARCH,

/**
* The checkout page
*/
CHECKOUT,

/**
* The order review page
*/
ORDER_REVIEW,

/**
* The order confirmation page
*/
ORDER_CONFIRMATION,

/**
* The mini cart
*/
MINI_CART,

/**
* Some other page
*/
OTHER
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.braintreepayments.api.shopperinsights


/**
* Initializes a new PresentmentDetails instance
*
* @param treatmentName The experiment or treatment name
* @param type An ExperimentType that is either a control or test type
*/
data class PresentmentDetails (
val treatmentName: String,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameters here don't seem to match the ticket description - can you confirm? It should align with iOS too.

val type: ExperimentType
)
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import com.braintreepayments.api.shopperinsights.ShopperInsightsAnalytics.GET_RE
import com.braintreepayments.api.shopperinsights.ShopperInsightsAnalytics.GET_RECOMMENDED_PAYMENTS_SUCCEEDED
import com.braintreepayments.api.shopperinsights.ShopperInsightsAnalytics.PAYPAL_PRESENTED
import com.braintreepayments.api.shopperinsights.ShopperInsightsAnalytics.PAYPAL_SELECTED
import com.braintreepayments.api.shopperinsights.ShopperInsightsAnalytics.VENMO_PRESENTED
import com.braintreepayments.api.shopperinsights.ShopperInsightsAnalytics.VENMO_SELECTED

/**
Expand Down Expand Up @@ -161,20 +160,28 @@ class ShopperInsightsClient internal constructor(
/**
* Call this method when the PayPal button has been successfully displayed to the buyer.
* This method sends analytics to help improve the Shopper Insights feature experience.
*
* @param experiment optional JSON string representing an experiment you want to run
* @param presentmentDetails optional JSON string representing an experiment you want to run.
* @param paymentMethodsDisplayed optional The list of available payment methods,
* rendered in the same order in which they are displayed
* @param buttonType optional Represents the tapped button type.
* @param buttonOrder optional Represents this buttons order in context of other buttons.
* @param pageType optional Represents the page or view the button is rendered on.
*/
fun sendPayPalPresentedEvent(
experiment: String? = null,
paymentMethodsDisplayed: List<String> = emptyList()
fun sendPresentedEvent(
sarahkoop marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a CHANGELOG entry for this method change

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want both buttonType and presentmentDetails to be required vs defaulted to null

presentmentDetails: PresentmentDetails,
paymentMethodsDisplayed: List<String> = emptyList(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove paymentMethodsDisplayed

buttonType: ButtonType,
buttonOrder: ButtonOrder,
pageType: PageType
) {
braintreeClient.sendAnalyticsEvent(
PAYPAL_PRESENTED,
AnalyticsEventParams(
experiment = experiment,
paymentMethodsDisplayed = paymentMethodsDisplayed
experiment = presentmentDetails.toString(),
paymentMethodsDisplayed = paymentMethodsDisplayed,
buttonType = buttonType.toString(),
buttonOrder = buttonOrder.toString(),
pageType = pageType.toString()
)
)
}
Expand All @@ -187,27 +194,6 @@ class ShopperInsightsClient internal constructor(
braintreeClient.sendAnalyticsEvent(PAYPAL_SELECTED)
}

/**
* Call this method when the Venmo button has been successfully displayed to the buyer.
* This method sends analytics to help improve the Shopper Insights feature experience.
*
* @param experiment optional JSON string representing an experiment you want to run
* @param paymentMethodsDisplayed optional The list of available payment methods,
* rendered in the same order in which they are displayed
*/
fun sendVenmoPresentedEvent(
experiment: String? = null,
paymentMethodsDisplayed: List<String> = emptyList()
) {
braintreeClient.sendAnalyticsEvent(
VENMO_PRESENTED,
AnalyticsEventParams(
experiment = experiment,
paymentMethodsDisplayed = paymentMethodsDisplayed
)
)
}

/**
* Call this method when the Venmo button has been selected/tapped by the buyer.
* This method sends analytics to help improve the Shopper Insights feature experience.
Expand Down