Open
Description
What feature would you like to see?
I would like to have type safe builders in Firebase Analytics that would help developers logging events. This way developers would know which data type each parameter expects, and it would also be easier for developers to know which parameters are optional and which ones are required.
How would you use it?
For example, the builder to log the SCREEN_VIEW
event would look something like this:
FirebaseAnalytics analytics = FirebaseAnalytics.getInstance()
ScreenViewEvent screenViewEvent = ScreenViewEvent.Builder()
.setClass("MainActivity")
.setName("Main Screen")
.build();
analytics.logEvent(screenViewEvent);
Other than being type-safe, I think this is less verbose than the current usage:
FirebaseAnalytics analytics = FirebaseAnalytics.getInstance()
Bundle parameters = new Bundle();
parameters.putString(FirebaseAnalytics.Param.SCREEN_CLASS, "MainActivity");
parameters.putString(FirebaseAnalytics.Param.SCREEN_NAME, "Main Screen");
analytics.logEvent(FirebaseAnalytics.Event.SCREEN_VIEW, parameters);
If at some point one of the event gets deprecated, we can deprecate the builder class for that event.
If one of the parameter gets deprecated, we can deprecate the respective method.