Hi folks, How to add analytics and crashlytics to ...
# android
a
Hi folks, How to add analytics and crashlytics to android libraries?
not kotlin but kotlin colored 2
If I add Firebase directly to the library, it would create a transitive dependency of Firebase for the client apps. What is the recommended approach to add crashlytics and analytics to a android libraries? How does moshi, retrofit, etc handle this?
k
As far as I know nor moshi nor retrofit collect any of your data. You can look it up in their source code. It's up to consumer of library to track errors that happen while using said library. Kind of depends on your use case though. If your library is some type of sdk and you want to track usage by clients it'd be easier to track it on your backend API which is ultimately used by consumers.
a
Usually Android Libraries do not require Analytics, that seems a red flag against usage of the library to me. If you really require the data then there is no way around adding a transitive dependency I guess, since the firebase lib needs to be added to your android library. One probable compromise might be to add the firebase analytics only to debug builds, but still I would advise against tracking anything inside of a library, libraries are not apps.
a
Thanks for answering @Konstantin, I was going through the source code of some libraries and could not find any relevant info. So, we have to rely on issues raised by consumer for any crashes and there is no direct way to get this info by the library authors? Regarding the BE API, my libraries are mostly UI component libraries, so no BE API is involved.
Thanks @Alex, The analytics and crashlytics are only for quality purposes - To get crash logs, traces, and some debug info on where and how the crash happens. I would prefer not to add a transitive dependency to client for this. So, I was wondering how it is usually handled by others libraries. Seems like relying on clients is the only option here.