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

Paypal analytics #1231

Merged
merged 12 commits into from
Dec 10, 2024
Merged

Paypal analytics #1231

merged 12 commits into from
Dec 10, 2024

Conversation

saperi22
Copy link
Contributor

@saperi22 saperi22 commented Dec 5, 2024

Summary of changes

  • Add PayPal analytics.

Checklist

  • Added a changelog entry
  • Relevant test coverage
  • Tested and confirmed payment flows affected by this change are functioning as expected

Authors

List GitHub usernames for everyone who contributed to this pull request.

@@ -212,13 +212,6 @@ class PayPalClient internal constructor(
val switchInitiatedTime = Uri.parse(approvalUrl).getQueryParameter("switch_initiated_time")
val isAppSwitchFlow = !switchInitiatedTime.isNullOrEmpty()

if (isAppSwitchFlow) {
Copy link
Contributor Author

@saperi22 saperi22 Dec 5, 2024

Choose a reason for hiding this comment

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

not sure why HANDLE_RETURN_STARTED was tied to app switch flow, but I'm NOT copying that logic into PayPalLauncher.

@saperi22 saperi22 marked this pull request as ready for review December 7, 2024 02:56
@saperi22 saperi22 requested a review from a team as a code owner December 7, 2024 02:56
Copy link
Collaborator

@tdchow tdchow left a comment

Choose a reason for hiding this comment

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

Thanks for making these changes for the PayPal module!

@@ -625,7 +625,6 @@ public void tokenize_whenPayPalInternalClientTokenizeResult_sendsAppSwitchSuccee
assertEquals(payPalAccountNonce, ((PayPalResult.Success) result).getNonce());

AnalyticsEventParams params = new AnalyticsEventParams();
verify(braintreeClient).sendAnalyticsEvent(PayPalAnalytics.HANDLE_RETURN_STARTED, params);
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious why we needed to remove this check from this tests. It looks like this test returns APP_SWITCH_SUCCEEDED which I would expect also to have a HANDLE_RETURN_STARTED event, but maybe am misunderstanding the updates.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We were previously sending the events on tokenize() method in the PayPalClient, due to some limitations around code structuring.
See: https://github.com/braintree/braintree_android/pull/1231/files#diff-51d311cd1ffbe27893d893c2eaed2c00c8ff26cb497f6d5f2cd1b7eb2e42e00aL222
I removed that logic.

After some refactor by @tdchow, we are now able to send the events from PayPalLauncher. I've moved the logic there.
https://github.com/braintree/braintree_android/pull/1231/files#diff-c4a51a1d2f652fee6eef372ea3a5d1e232de64156bc91c97cf5b4f45f7420e2bR98

Copy link
Contributor

Choose a reason for hiding this comment

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

Gotcha, so there is no way in this test to mock calling PayPalLauncher to verify this event is sent with the app switch success events? If not that's fine, moreso for my understanding since on iOS we don't have an internal vs external client.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I may not have understood your question correctly.
Since these are 'unit' tests, PayPalClient wouldn't have any knowledge of what PayPalLauncher is doing.

I've moved the event logging into PayPalLauncher and I've a test in its tests. See: https://github.com/braintree/braintree_android/pull/1231/files/50684dcbba1170da5419d61df0a7d882f0e82959#diff-c4a51a1d2f652fee6eef372ea3a5d1e232de64156bc91c97cf5b4f45f7420e2bR103

Does that answer your question? If not, we can sync off-comment; online.

@saperi22
Copy link
Contributor Author

saperi22 commented Dec 9, 2024

@saperi22 to add the app switch url to the analytics params.

@saperi22
Copy link
Contributor Author

@saperi22 to add the app switch url to the analytics params.

Will add it as part of a separate PR to get reviews.

@saperi22 saperi22 merged commit caf65bd into main Dec 10, 2024
3 checks passed
@saperi22 saperi22 deleted the paypal-analytics branch December 10, 2024 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants