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

Create FPTI Analytics Event Enums #820

Merged
merged 22 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
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
@@ -0,0 +1,8 @@
package com.braintreepayments.api

internal enum class AmericanExpressAnalytics(@JvmField val event: String) {

REWARDS_BALANCE_STARTED("amex:rewards-balance:started"),
REWARDS_BALANCE_FAILED("amex:rewards-balance:failed"),
REWARDS_BALANCE_SUCCEEDED("amex:rewards-balance:succeeded")
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public void getRewardsBalance(@NonNull String nonce, @NonNull String currencyIso
.appendQueryParameter("currencyIsoCode", currencyIsoCode)
.build()
.toString();
String analytis = AmericanExpressAnalytics.REWARDS_BALANCE_SUCCEEDED.event;
sarahkoop marked this conversation as resolved.
Show resolved Hide resolved

braintreeClient.sendAnalyticsEvent("amex.rewards-balance.start");
braintreeClient.sendGET(getRewardsBalanceUrl, (responseBody, httpError) -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.braintreepayments.api

import org.junit.Assert.assertEquals
import org.junit.Test

class AmericanExpressAnalyticsUnitTest {

@Test
fun testAnalyticsEvents_sendsExpectedEventNames() {
assertEquals(
"amex:rewards-balance:started",
AmericanExpressAnalytics.REWARDS_BALANCE_STARTED.event
)
assertEquals(
"amex:rewards-balance:failed",
AmericanExpressAnalytics.REWARDS_BALANCE_FAILED.event
)
assertEquals(
"amex:rewards-balance:succeeded",
AmericanExpressAnalytics.REWARDS_BALANCE_SUCCEEDED.event
)
}
}
8 changes: 8 additions & 0 deletions Card/src/main/java/com/braintreepayments/api/CardAnalytics.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.braintreepayments.api

internal enum class CardAnalytics(@JvmField val event: String) {

CARD_TOKENIZE_STARTED("card:tokenize:started"),
CARD_TOKENIZE_FAILED("card:tokenize:failed"),
CARD_TOKENIZE_SUCCEEDED("card:tokenize:succeeded")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.braintreepayments.api

import org.junit.Assert.assertEquals
import org.junit.Test

class CardAnalyticsUnitTest {

@Test
fun testAnalyticsEvents_sendsExpectedEventNames() {
assertEquals("card:tokenize:started", CardAnalytics.CARD_TOKENIZE_STARTED.event)
assertEquals("card:tokenize:failed", CardAnalytics.CARD_TOKENIZE_FAILED.event)
assertEquals("card:tokenize:succeeded", CardAnalytics.CARD_TOKENIZE_SUCCEEDED.event)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.braintreepayments.api

internal enum class GooglePayAnalytics(@JvmField val event: String) {

PAYMENT_REQUEST_STARTED("google-pay:payment-request:started"),
PAYMENT_REQUEST_FAILED("google-pay:payment-request:failed"),
PAYMENT_REQUEST_SUCCEEDED("google-pay:payment-request:succeeded"),

TOKENIZE_STARTED("google-pay:tokenize:started"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit - should we add the // Conversion events comment here too?

TOKENIZE_FAILED("google-pay:tokenize:failed"),
TOKENIZE_SUCCEEDED("google-pay:tokenize:succeeded")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.braintreepayments.api

import org.junit.Assert.assertEquals
import org.junit.Test

class GooglePayAnalyticsUnitTest {

@Test
fun testAnalyticsEvents_sendsExpectedEventNames() {
assertEquals(
"google-pay:payment-request:started",
GooglePayAnalytics.PAYMENT_REQUEST_STARTED.event
)
assertEquals(
"google-pay:payment-request:failed",
GooglePayAnalytics.PAYMENT_REQUEST_FAILED.event
)
assertEquals(
"google-pay:payment-request:succeeded",
GooglePayAnalytics.PAYMENT_REQUEST_SUCCEEDED.event
)
assertEquals(
"google-pay:tokenize:started",
GooglePayAnalytics.TOKENIZE_STARTED.event
)
assertEquals(
"google-pay:tokenize:failed",
GooglePayAnalytics.TOKENIZE_FAILED.event
)
assertEquals(
"google-pay:tokenize:succeeded",
GooglePayAnalytics.TOKENIZE_SUCCEEDED.event
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.braintreepayments.api

internal enum class LocalPaymentAnalytics(@JvmField val event: String) {

// Conversion Events
PAYMENT_STARTED("local-payment:start-payment:started"),
PAYMENT_SUCCEEDED("local-payment:start-payment:succeeded"),
PAYMENT_FAILED("local-payment:start-payment:failed"),
PAYMENT_CANCELED("local-payment:start-payment:browser-login:canceled"),

// Browser Presentation Events
BROWSER_SWITCH_SUCCEEDED("local-payment:start-payment:browser-presentation:succeeded"),
BROWSER_SWITCH_FAILED("local-payment:start-payment:browser-presentation:failed"),

// Browser Login Events
BROWSER_LOGIN_FAILED("local-payment:start-payment:browser-login:failed")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.braintreepayments.api

import org.junit.Assert.assertEquals
import org.junit.Test

class LocalPaymentAnalyticsUnitTest {

@Test
fun testAnalyticsEvents_sendsExpectedEventNames() {
assertEquals(
"local-payment:start-payment:started",
LocalPaymentAnalytics.PAYMENT_STARTED.event
)
assertEquals(
"local-payment:start-payment:succeeded",
LocalPaymentAnalytics.PAYMENT_SUCCEEDED.event
)
assertEquals(
"local-payment:start-payment:failed",
LocalPaymentAnalytics.PAYMENT_FAILED.event
)
assertEquals(
"local-payment:start-payment:browser-login:canceled",
LocalPaymentAnalytics.PAYMENT_CANCELED.event
)
assertEquals(
"local-payment:start-payment:browser-presentation:succeeded",
LocalPaymentAnalytics.BROWSER_SWITCH_SUCCEEDED.event
)
assertEquals(
"local-payment:start-payment:browser-presentation:failed",
LocalPaymentAnalytics.BROWSER_SWITCH_FAILED.event
)
assertEquals(
"local-payment:start-payment:browser-login:failed",
LocalPaymentAnalytics.BROWSER_LOGIN_FAILED.event
)
}
}
14 changes: 14 additions & 0 deletions PayPal/src/main/java/com/braintreepayments/api/PayPalAnalytics.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.braintreepayments.api

internal enum class PayPalAnalytics(@JvmField val event: String) {

// Conversion Events
TOKENIZATION_STARTED("paypal:tokenize:started"),
TOKENIZATION_FAILED("paypal:tokenize:failed"),
TOKENIZATION_SUCCEEDED("paypal:tokenize:succeeded"),
BROWSER_LOGIN_CANCELED("paypal:tokenize:browser-login:canceled"),

// Browser Presentation Events
BROWSER_SWITCH_SUCCEEDED("paypal:tokenize:browser-presentation:succeeded"),
BROWSER_SWITCH_FAILED("paypal:tokenize:browser-presentation:failed")
Comment on lines +12 to +13
Copy link
Contributor

@scannillo scannillo Nov 9, 2023

Choose a reason for hiding this comment

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

On iOS we have a synchronous bool return value from ASWeb into if the ASWeb view presented or didn't.

Do we have this insight on Android? A way to know if the CCT displayed or didn't?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

BrowserSwitchClient#start (which launches the CCT) throws a BrowserSwitchException in some cases, mainly for improper deep linking configuration, but also if the host activity is finishing while trying to launch CCT. In those cases if we receive that BrowserSwitchException, we would send that BROWSER_SWITCH_FAILED analytic event on Android. So it's not a 1 to 1 match with the iOS meaning of that event, but I think it's still useful for Android

Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome, this is great - thanks for the explanation

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

import org.junit.Assert.assertEquals
import org.junit.Test

class PayPalAnalyticsUnitTest {

@Test
fun testAnalyticsEvents_sendsExpectedEventNames() {
assertEquals("paypal:tokenize:started", PayPalAnalytics.TOKENIZATION_STARTED.event)
assertEquals("paypal:tokenize:failed", PayPalAnalytics.TOKENIZATION_FAILED.event)
assertEquals(
"paypal:tokenize:succeeded",
PayPalAnalytics.TOKENIZATION_SUCCEEDED.event
)
assertEquals(
"paypal:tokenize:browser-presentation:succeeded",
PayPalAnalytics.BROWSER_SWITCH_SUCCEEDED.event
)
assertEquals(
"paypal:tokenize:browser-presentation:failed",
PayPalAnalytics.BROWSER_SWITCH_FAILED.event
)
assertEquals(
"paypal:tokenize:browser-login:canceled",
PayPalAnalytics.BROWSER_LOGIN_CANCELED.event
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.braintreepayments.api

internal enum class PayPalNativeCheckoutAnalytics(@JvmField val event: String) {

// Conversion Events
TOKENIZATION_STARTED("paypal-native:tokenize:started"),
TOKENIZATION_FAILED("paypal-native:tokenize:failed"),
TOKENIZATION_SUCCEEDED("paypal-native:tokenize:succeeded"),
TOKENIZATION_CANCELED("paypal-native:tokenize:canceled"),

// Additional Detail Events
ORDER_CREATION_FAILED("paypal-native:tokenize:order-creation:failed")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.braintreepayments.api

import org.junit.Assert.assertEquals
import org.junit.Test

class PayPalNativeCheckoutAnalyticsUnitTest {

@Test
fun testAnalyticsEvents_sendsExpectedEventNames() {
assertEquals(
"paypal-native:tokenize:started",
PayPalNativeCheckoutAnalytics.TOKENIZATION_STARTED.event
)
assertEquals(
"paypal-native:tokenize:failed",
PayPalNativeCheckoutAnalytics.TOKENIZATION_FAILED.event
)
assertEquals(
"paypal-native:tokenize:succeeded",
PayPalNativeCheckoutAnalytics.TOKENIZATION_SUCCEEDED.event
)
assertEquals(
"paypal-native:tokenize:canceled",
PayPalNativeCheckoutAnalytics.TOKENIZATION_CANCELED.event
)
assertEquals(
"paypal-native:tokenize:order-creation:failed",
PayPalNativeCheckoutAnalytics.ORDER_CREATION_FAILED.event
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.braintreepayments.api

internal enum class SEPADirectDebitAnalytics(@JvmField val event: String) {

// Conversion Events
TOKENIZE_STARTED("sepa:tokenize:started"),
TOKENIZE_SUCCEEDED("sepa:tokenize:succeeded"),
TOKENIZE_FAILED("sepa:tokenize:failed"),
CHALLENGE_CANCELED("sepa:tokenize:challenge:canceled"),

// Additional Detail Events
CREATE_MANDATE_CHALLENGE_REQUIRED("sepa:tokenize:create-mandate:challenge-required"),
CREATE_MANDATE_SUCCEEDED("sepa:tokenize:create-mandate:succeeded"),
CREATE_MANDATE_FAILED("sepa:tokenize:create-mandate:failed"),
CHALLENGE_PRESENTATION_SUCCEEDED("sepa:tokenize:challenge-presentation:succeeded"),
CHALLENGE_PRESENTATION_FAILED("sepa:tokenize:challenge-presentation:failed"),
CHALLENGE_SUCCEEDED("sepa:tokenize:challenge:succeeded"),
CHALLENGE_FAILED("sepa:tokenize:challenge:failed")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.braintreepayments.api

import org.junit.Assert.assertEquals
import org.junit.Test

class SEPADirectDebitAnalyticsUnitTest {

@Test
fun testAnalyticsEvents_sendsExpectedEventNames() {
assertEquals(
"sepa:tokenize:started",
SEPADirectDebitAnalytics.TOKENIZE_STARTED.event
)
assertEquals(
"sepa:tokenize:succeeded",
SEPADirectDebitAnalytics.TOKENIZE_SUCCEEDED.event
)
assertEquals("sepa:tokenize:failed", SEPADirectDebitAnalytics.TOKENIZE_FAILED.event)
assertEquals(
"sepa:tokenize:challenge:canceled",
SEPADirectDebitAnalytics.CHALLENGE_CANCELED.event
)
assertEquals(
"sepa:tokenize:create-mandate:challenge-required",
SEPADirectDebitAnalytics.CREATE_MANDATE_CHALLENGE_REQUIRED.event
)
assertEquals(
"sepa:tokenize:create-mandate:succeeded",
SEPADirectDebitAnalytics.CREATE_MANDATE_SUCCEEDED.event
)
assertEquals(
"sepa:tokenize:create-mandate:failed",
SEPADirectDebitAnalytics.CREATE_MANDATE_FAILED.event
)
assertEquals(
"sepa:tokenize:challenge-presentation:succeeded",
SEPADirectDebitAnalytics.CHALLENGE_PRESENTATION_SUCCEEDED.event
)
assertEquals(
"sepa:tokenize:challenge-presentation:failed",
SEPADirectDebitAnalytics.CHALLENGE_PRESENTATION_FAILED.event
)
assertEquals(
"sepa:tokenize:challenge:succeeded",
SEPADirectDebitAnalytics.CHALLENGE_SUCCEEDED.event
)
assertEquals(
"sepa:tokenize:challenge:failed",
SEPADirectDebitAnalytics.CHALLENGE_FAILED.event
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.braintreepayments.api

internal enum class ThreeDSecureAnalytics(@JvmField val event: String) {

// Conversion Events
VERIFY_STARTED("3ds:verify:started"),
VERIFY_SUCCEEDED("3ds:verify:succeeded"),
VERIFY_FAILED("3ds:verify:failed"),
// cardinal sdk returns a cancellation result
VERIFY_CANCELED("3ds:verify:canceled"),

// Lookup Events
LOOKUP_SUCCEEDED("3ds:verify:lookup:succeeded"),
LOOKUP_FAILED("3ds:verify:lookup:failed"),
CHALLENGE_REQUIRED("3ds:verify:lookup:challenge-required"),

// Challenge Events
CHALLENGE_SUCCEEDED("3ds:verify:challenge.succeeded"),
CHALLENGE_FAILED("3ds:verify:challenge.failed"),

// JWT Events
JWT_AUTH_SUCCEEDED("3ds:verify:authenticate-jwt:succeeded"),
JWT_AUTH_FAILED("3ds:verify:authenticate-jwt:failed")
}
Loading