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

Analytics - Send different values when checkoutAttemptId is not available or it failed to fetch #1812

Conversation

araratthehero
Copy link
Contributor

@araratthehero araratthehero commented Oct 8, 2024

Description

Send different values, based on if checkoutAttemptId is fetched, not fetched or failed to fetch.

Checklist

  • PR is labelled
  • Code is unit tested
  • Changes are tested manually

COAND-982

@araratthehero araratthehero added the Chore [PRs only] Indicates any task that does not need to be mentioned in the public release notes label Oct 8, 2024
@araratthehero araratthehero changed the title Analytics - Send different values when checkoutAttemptId is not available or it failed to fetch Draft - Analytics - Send different values when checkoutAttemptId is not available or it failed to fetch Oct 8, 2024
@araratthehero araratthehero force-pushed the feature/analytics_send_checkout_attempt_id_not_yet_fetched branch 2 times, most recently from 17180b0 to 8e5facd Compare October 9, 2024 07:57
@araratthehero araratthehero marked this pull request as ready for review October 9, 2024 07:58
@araratthehero araratthehero requested a review from a team as a code owner October 9, 2024 07:58
@araratthehero araratthehero force-pushed the feature/analytics_send_checkout_attempt_id_not_yet_fetched branch from 8e5facd to 23a9e1c Compare October 9, 2024 09:30
@araratthehero araratthehero changed the title Draft - Analytics - Send different values when checkoutAttemptId is not available or it failed to fetch Analytics - Send different values when checkoutAttemptId is not available or it failed to fetch Oct 9, 2024
}.fold(
onSuccess = { /* Not necessary */ },
onFailure = { throwable -> adyenLog(AdyenLogLevel.WARN, throwable) { "Failed sending analytics events" } },
)
}

override fun getCheckoutAttemptId(): String? = checkoutAttemptId
override fun getCheckoutAttemptIdState() = checkoutAttemptIdState
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the state should be something private to DefaultAnalyticsManager and then this method can stay as it was

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was my initial implementation, but I changed it, since checkoutAttemptId-not-fetched and fetch-checkoutAttemptId-failed values are not really related to the analytics. They are only necessary to be sent in the /payments call, based on if the checkoutAttemptId is fetched or not. Those two values are not the actual values of the checkoutAttemptId, that is why I separated them, to make sure that the Analytics manager is not aware of them and if they change in the future, they will not change the logic of the analytics manager. They are relevant only for the /payments call.

Do you think there is a better way to handle this and keep them separate from the analytics manager?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm I see your point, but I think it actually is related to analytics. Currently, the getCheckoutAttemptId method is only used by delegates for the /payments call. The only other place we use it is to make analytics requests, but we don't make analytics requests if we have no attempt id. Making the not fetched and failed values valid attempt ids imo

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 was thinking of exposing a state and whenever necessary we can assign custom values to the checkoutAttemptId, since those are not values which are returned from backend. But I guess it is just thinking about cases which we do not have now.
I can move everything to the analytics manager and later we can make changes if necessary.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I think that's a good idea

import com.adyen.checkout.components.core.internal.analytics.CheckoutAttemptIdState

@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
const val CHECKOUT_ATTEMPT_ID_NOT_FETCHED = "checkoutAttemptId-not-fetched"
Copy link
Contributor

Choose a reason for hiding this comment

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

All these fields and methods should be internal or even moved to DefaultAnalyticsManager IMO. These two vals are now used in tests, but I think if you make the change I suggested earlier and hardcode a value in TestAnalyticsManager then tests don't have to know about these

@araratthehero araratthehero force-pushed the feature/analytics_send_checkout_attempt_id_not_yet_fetched branch 3 times, most recently from 7f92856 to 0954120 Compare October 10, 2024 11:43
@araratthehero araratthehero force-pushed the feature/analytics_send_checkout_attempt_id_not_yet_fetched branch from 0954120 to 7503f8b Compare October 10, 2024 11:49
Copy link

✅ No public API changes

Copy link

sonarcloud bot commented Oct 10, 2024

@araratthehero araratthehero merged commit e43f1bf into develop Oct 10, 2024
9 checks passed
@araratthehero araratthehero deleted the feature/analytics_send_checkout_attempt_id_not_yet_fetched branch October 10, 2024 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Chore [PRs only] Indicates any task that does not need to be mentioned in the public release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants