-
Notifications
You must be signed in to change notification settings - Fork 659
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
[Connect] Add analytics client and spec #9780
Conversation
Diffuse output:
APK
|
8671bad
to
9e55604
Compare
stripe-core/src/main/java/com/stripe/android/core/networking/DefaultStripeNetworkClient.kt
Outdated
Show resolved
Hide resolved
/** | ||
* Analytics event for the Connect SDK. One subclass per unique analytics event is expected. | ||
*/ | ||
internal sealed class ConnectAnalyticsEvent( |
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.
4d93381
to
162d768
Compare
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.
Nice! Minor things and would like to start improving our testing story.
/** | ||
* Log an analytic [event]. | ||
*/ | ||
fun track(event: ConnectAnalyticsEvent) { |
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.
Currently unused. Can you add sending at least ComponentCreated
to prove it works?
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.
/** | ||
* Log an analytic [event]. | ||
*/ | ||
fun track(event: ConnectAnalyticsEvent) { |
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.
Add unit tests for this? At least verify the params are being added.
* Service for logging [AnalyticsRequestV2] for the Connect SDK. | ||
* This service is very simple. Consumers should prefer [ComponentAnalyticsService] instead, | ||
* which uses this service internally. |
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.
This docstring is inaccurate.
* Service for logging [AnalyticsRequestV2] for the Connect SDK. | |
* This service is very simple. Consumers should prefer [ComponentAnalyticsService] instead, | |
* which uses this service internally. | |
* Analytics service configured for Connect SDK. |
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.
What's inaccurate about this docstring? Is it specifically mentioning AnalyticsRequestV2, since that's the type we log but not the type the service exposes?
I think it's still useful to recommend consumers to ComponentAnalyticsService (which is what should be used in other parts of the SDK anyways), @lng-stripe let me know what you think of the updated docstring.
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.
Oh, I might've misread it. I thought it was saying ConnectAnalyticsService
uses ComponentAnalyticsService
internally, but it's saying the opposite (which is true).
Still, I'm not a fan of referencing downstream dependencies since it's not clean and adds maintenance cost.
* This service is very simple. Consumers should prefer [ComponentAnalyticsService] instead, | ||
* which uses this service internally. | ||
*/ | ||
internal class ConnectAnalyticsService(application: Application) { |
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.
Ideally this would be abstracted for testability. Imagine unit testing EmbeddedComponentManager.onActivityCreate()
, which we should be doing (either now or after the public API is finalized).
@lng-stripe this is ready for re-review |
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.
👍 👍
Summary
Creates the analytics client and analytics shapes from the spec.
This PR adds the analytics to the WebViewContainer as early as possible so that it can be used for all event tracking later on, including initialization errors.
I also manually regressed the Payouts and Account Onboarding views in both XML and programmatic configuration, plus checked that props were correctly passed in the Onboarding case to make sure I didn't break anything with initialization.
MXMOBILE-2514
Motivation
This lays the groundwork for analytics emissions in the Connect SDK.
Testing
I manually created the analytics client in a view and saw that it could fire an event with all the proper metadata, including the
event_metadata
nested json in addition to the metadata present at the root-level.