-
Notifications
You must be signed in to change notification settings - Fork 241
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
Update Venmo with FPTI Analytics Events #846
Changes from 4 commits
1f37c59
e13dc5d
c722c9d
5bb6ce5
7a9fec8
2d5cfe0
ef8b821
8de3d07
de18ecd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -80,25 +80,26 @@ public void showVenmoInGooglePlayStore(@NonNull FragmentActivity activity) { | |||||
public void createPaymentAuthRequest(@NonNull final FragmentActivity activity, | ||||||
@NonNull final VenmoRequest request, | ||||||
@NonNull VenmoPaymentAuthRequestCallback callback) { | ||||||
braintreeClient.sendAnalyticsEvent("pay-with-venmo.selected"); | ||||||
braintreeClient.sendAnalyticsEvent(VenmoAnalytics.TOKENIZE_STARTED.event); | ||||||
braintreeClient.getConfiguration((configuration, error) -> { | ||||||
if (configuration == null && error != null) { | ||||||
callback.onVenmoPaymentAuthRequest(new VenmoPaymentAuthRequest.Failure(error)); | ||||||
braintreeClient.sendAnalyticsEvent("pay-with-venmo.app-switch.failed"); | ||||||
braintreeClient.sendAnalyticsEvent(VenmoAnalytics.TOKENIZE_FAILED.event); | ||||||
return; | ||||||
} | ||||||
|
||||||
String exceptionMessage = null; | ||||||
if (!configuration.isVenmoEnabled()) { | ||||||
exceptionMessage = "Venmo is not enabled"; | ||||||
braintreeClient.sendAnalyticsEvent(VenmoAnalytics.TOKENIZE_FAILED.event); | ||||||
} else if (!deviceInspector.isVenmoAppSwitchAvailable(activity)) { | ||||||
exceptionMessage = "Venmo is not installed"; | ||||||
braintreeClient.sendAnalyticsEvent(VenmoAnalytics.APP_SWITCH_FAILED.event); | ||||||
} | ||||||
|
||||||
if (exceptionMessage != null) { | ||||||
callback.onVenmoPaymentAuthRequest( | ||||||
new VenmoPaymentAuthRequest.Failure(new AppSwitchNotAvailableException(exceptionMessage))); | ||||||
braintreeClient.sendAnalyticsEvent("pay-with-venmo.app-switch.failed"); | ||||||
return; | ||||||
} | ||||||
|
||||||
|
@@ -110,7 +111,7 @@ public void createPaymentAuthRequest(@NonNull final FragmentActivity activity, | |||||
callback.onVenmoPaymentAuthRequest(new VenmoPaymentAuthRequest.Failure(new BraintreeException( | ||||||
"Cannot collect customer data when ECD is disabled. Enable this feature " + | ||||||
"in the Control Panel to collect this data."))); | ||||||
braintreeClient.sendAnalyticsEvent("pay-with-venmo.app-switch.failed"); | ||||||
braintreeClient.sendAnalyticsEvent(VenmoAnalytics.TOKENIZE_FAILED.event); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
nit: Would it be better to convert There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could rename the "event" property in this enum, or what you're describing sounds like a class with a companion object filled with string constants rather than an enum - do you think that would be better? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I'd go companion There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool - updated 👍 |
||||||
return; | ||||||
} | ||||||
|
||||||
|
@@ -128,7 +129,7 @@ public void createPaymentAuthRequest(@NonNull final FragmentActivity activity, | |||||
paymentContextId, callback); | ||||||
} else { | ||||||
callback.onVenmoPaymentAuthRequest(new VenmoPaymentAuthRequest.Failure(exception)); | ||||||
braintreeClient.sendAnalyticsEvent("pay-with-venmo.app-switch.failed"); | ||||||
braintreeClient.sendAnalyticsEvent(VenmoAnalytics.TOKENIZE_FAILED.event); | ||||||
} | ||||||
}); | ||||||
}); | ||||||
|
@@ -150,7 +151,6 @@ private void createPaymentAuthRequest( | |||||
new VenmoPaymentAuthRequestParams(configuration, venmoProfileId, paymentContextId, | ||||||
braintreeClient.getSessionId(), braintreeClient.getIntegrationType()); | ||||||
callback.onVenmoPaymentAuthRequest(new VenmoPaymentAuthRequest.ReadyToLaunch(params)); | ||||||
braintreeClient.sendAnalyticsEvent("pay-with-venmo.app-switch.started"); | ||||||
} | ||||||
|
||||||
/** | ||||||
|
@@ -166,7 +166,7 @@ private void createPaymentAuthRequest( | |||||
public void tokenize(@NonNull final VenmoPaymentAuthResult venmoPaymentAuthResult, | ||||||
@NonNull VenmoTokenizeCallback callback) { | ||||||
if (venmoPaymentAuthResult.getError() == null) { | ||||||
braintreeClient.sendAnalyticsEvent("pay-with-venmo.app-switch.success"); | ||||||
braintreeClient.sendAnalyticsEvent(VenmoAnalytics.APP_SWITCH_SUCCEEDED.event); | ||||||
|
||||||
final boolean isClientTokenAuth = (braintreeClient.getAuthorization() instanceof ClientToken); | ||||||
|
||||||
|
@@ -181,19 +181,19 @@ public void tokenize(@NonNull final VenmoPaymentAuthResult venmoPaymentAuthResul | |||||
vaultVenmoAccountNonce(nonce.getString(), | ||||||
(venmoAccountNonce, vaultError) -> { | ||||||
if (venmoAccountNonce != null) { | ||||||
braintreeClient.sendAnalyticsEvent(VenmoAnalytics.TOKENIZE_SUCCEEDED.event); | ||||||
callback.onVenmoResult(new VenmoResult.Success(venmoAccountNonce)); | ||||||
} else if (vaultError != null) { | ||||||
braintreeClient.sendAnalyticsEvent(VenmoAnalytics.TOKENIZE_FAILED.event); | ||||||
callback.onVenmoResult(new VenmoResult.Failure(vaultError)); | ||||||
} | ||||||
}); | ||||||
} else { | ||||||
braintreeClient.sendAnalyticsEvent( | ||||||
"pay-with-venmo.app-switch.failure"); | ||||||
braintreeClient.sendAnalyticsEvent(VenmoAnalytics.TOKENIZE_SUCCEEDED.event); | ||||||
callback.onVenmoResult(new VenmoResult.Success(nonce)); | ||||||
} | ||||||
} else if (error != null) { | ||||||
braintreeClient.sendAnalyticsEvent( | ||||||
"pay-with-venmo.app-switch.failure"); | ||||||
braintreeClient.sendAnalyticsEvent(VenmoAnalytics.TOKENIZE_FAILED.event); | ||||||
callback.onVenmoResult(new VenmoResult.Failure(error)); | ||||||
} | ||||||
}); | ||||||
|
@@ -205,36 +205,35 @@ public void tokenize(@NonNull final VenmoPaymentAuthResult venmoPaymentAuthResul | |||||
if (shouldVault && isClientTokenAuth) { | ||||||
vaultVenmoAccountNonce(nonce, (venmoAccountNonce, error) -> { | ||||||
if (venmoAccountNonce != null) { | ||||||
braintreeClient.sendAnalyticsEvent(VenmoAnalytics.TOKENIZE_SUCCEEDED.event); | ||||||
callback.onVenmoResult(new VenmoResult.Success(venmoAccountNonce)); | ||||||
} else if (error != null) { | ||||||
braintreeClient.sendAnalyticsEvent(VenmoAnalytics.TOKENIZE_FAILED.event); | ||||||
callback.onVenmoResult(new VenmoResult.Failure(error)); | ||||||
} | ||||||
}); | ||||||
} else { | ||||||
String venmoUsername = venmoPaymentAuthResult.getVenmoUsername(); | ||||||
VenmoAccountNonce venmoAccountNonce = | ||||||
new VenmoAccountNonce(nonce, venmoUsername, false); | ||||||
braintreeClient.sendAnalyticsEvent(VenmoAnalytics.TOKENIZE_SUCCEEDED.event); | ||||||
callback.onVenmoResult(new VenmoResult.Success(venmoAccountNonce)); | ||||||
} | ||||||
|
||||||
} | ||||||
} else if (venmoPaymentAuthResult.getError() != null) { | ||||||
if (venmoPaymentAuthResult.getError() instanceof UserCanceledException) { | ||||||
braintreeClient.sendAnalyticsEvent("pay-with-venmo.app-switch.canceled"); | ||||||
braintreeClient.sendAnalyticsEvent(VenmoAnalytics.APP_SWITCH_CANCELED.event); | ||||||
callback.onVenmoResult(VenmoResult.Cancel.INSTANCE); | ||||||
} else { | ||||||
braintreeClient.sendAnalyticsEvent(VenmoAnalytics.TOKENIZE_FAILED.event); | ||||||
callback.onVenmoResult(new VenmoResult.Failure(venmoPaymentAuthResult.getError())); | ||||||
} | ||||||
callback.onVenmoResult(VenmoResult.Cancel.INSTANCE); | ||||||
} | ||||||
} | ||||||
|
||||||
private void vaultVenmoAccountNonce(String nonce, final VenmoInternalCallback callback) { | ||||||
venmoApi.vaultVenmoAccountNonce(nonce, (venmoAccountNonce, error) -> { | ||||||
if (venmoAccountNonce != null) { | ||||||
braintreeClient.sendAnalyticsEvent("pay-with-venmo.vault.success"); | ||||||
} else { | ||||||
braintreeClient.sendAnalyticsEvent("pay-with-venmo.vault.failed"); | ||||||
} | ||||||
callback.onResult(venmoAccountNonce, error); | ||||||
}); | ||||||
venmoApi.vaultVenmoAccountNonce(nonce, (venmoAccountNonce, error) -> callback.onResult(venmoAccountNonce, error)); | ||||||
} | ||||||
|
||||||
/** | ||||||
|
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 used "app-switch" failed more previously, but to be more accurate, I updated this to only be "app switch failed" for errors returned from actual app switching, or if Venmo is not installed.