Skip to content

Commit

Permalink
Update sendPresentedEvent signature
Browse files Browse the repository at this point in the history
  • Loading branch information
warmkesselj committed Dec 16, 2024
1 parent 81bcb92 commit 41b4dc9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,7 @@ data class AnalyticsEventParams @JvmOverloads constructor(
val experiment: String? = null,
val paymentMethodsDisplayed: List<String> = emptyList(),
val appSwitchUrl: String? = null,
val buttonType: String? = null
val buttonType: String? = null,
val buttonOrder: String? = null,
val pageType: String? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ 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
Expand Down Expand Up @@ -195,9 +197,11 @@ class ShopperInsightsFragment : BaseFragment() {
if (result.response.isPayPalRecommended) {
payPalVaultButton.isEnabled = true
shopperInsightsClient.sendPresentedEvent(
ButtonType.PAYPAL,
PresentmentDetails("PaymentReady", ExperimentType.CONTROL),
listOf("PayPal", "Venmo", "other")
listOf("PayPal", "Venmo", "other"),
ButtonType.PAYPAL,
ButtonOrder.OTHER,
PageType.HOMEPAGE
)

//"""{"exp_name":"PaymentReady","treatment_name":"control"}""",
Expand All @@ -206,9 +210,11 @@ class ShopperInsightsFragment : BaseFragment() {
if (result.response.isVenmoRecommended) {
venmoButton.isEnabled = true
shopperInsightsClient.sendPresentedEvent(
ButtonType.VENMO,
PresentmentDetails("PaymentReady", ExperimentType.TEST),
listOf("Venmo", "PayPal", "other")
listOf("Venmo", "PayPal", "other"),
ButtonType.VENMO,
ButtonOrder.OTHER,
PageType.HOMEPAGE
)

//"""{"exp_name":"PaymentReady","treatment_name":"test"}""",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,22 +182,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 buttonType optional Represents the tapped button type.
* @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 sendPresentedEvent(
buttonType: ButtonType,
presentmentDetails: PresentmentDetails,
paymentMethodsDisplayed: List<String> = emptyList()
paymentMethodsDisplayed: List<String> = emptyList(),
buttonType: ButtonType,
buttonOrder: ButtonOrder,
pageType: PageType
) {
braintreeClient.sendAnalyticsEvent(
PAYPAL_PRESENTED,
AnalyticsEventParams(
experiment = presentmentDetails.toString(),
paymentMethodsDisplayed = paymentMethodsDisplayed,
buttonType = buttonType.toString()
buttonType = buttonType.toString(),
buttonOrder = buttonOrder.toString(),
pageType = pageType.toString()
)
)
}
Expand Down

0 comments on commit 41b4dc9

Please sign in to comment.