Skip to content

Commit

Permalink
Update PresentmentDetails signature
Browse files Browse the repository at this point in the history
  • Loading branch information
warmkesselj committed Dec 16, 2024
1 parent d4cef52 commit 60f8099
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,28 +200,28 @@ class ShopperInsightsFragment : BaseFragment() {
payPalVaultButton.isEnabled = true
shopperInsightsClient.sendPresentedEvent(
shopperSessionId,
PresentmentDetails("PaymentReady", ExperimentType.CONTROL),
PresentmentDetails(
ExperimentType.TEST,
ButtonOrder.OTHER,
PageType.HOMEPAGE
),
listOf("PayPal", "Venmo", "other"),
ButtonType.PAYPAL,
ButtonOrder.OTHER,
PageType.HOMEPAGE
)

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

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

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

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

enum class ExperimentType {
CONTROL,
TEST
enum class ExperimentType(val rawValue: String) {
CONTROL("control"),
TEST("test");

fun formattedExperiment(): String {
return """
[
{ "exp_name" : "PaymentReady" }
{ "treatment_name" : $rawValue }
]
"""
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ 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
* @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.
*/
data class PresentmentDetails (
val treatmentName: String,
val type: ExperimentType
val type: ExperimentType,
val buttonOrder: ButtonOrder,
val pageType: PageType
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,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 @@ -173,26 +172,21 @@ class ShopperInsightsClient internal constructor(
* @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(
shopperSessionId: String? = null,
presentmentDetails: PresentmentDetails? = null,
paymentMethodsDisplayed: List<String> = emptyList(),
buttonType: ButtonType? = null,
buttonOrder: ButtonOrder? = null,
pageType: PageType? = null
) {
braintreeClient.sendAnalyticsEvent(
PAYPAL_PRESENTED,
AnalyticsEventParams(
experiment = presentmentDetails.toString(),
experiment = presentmentDetails?.type?.formattedExperiment(),
paymentMethodsDisplayed = paymentMethodsDisplayed,
shopperSessionId = shopperSessionId,
buttonType = buttonType.toString(),
buttonOrder = buttonOrder.toString(),
pageType = pageType.toString()
buttonOrder = presentmentDetails?.buttonOrder.toString()
)
)
}
Expand Down

0 comments on commit 60f8099

Please sign in to comment.