Is it possible for the FirebaseAnalytics instance in my Library project to send the tracked events into a Firebase project that isn't the app's? [duplicate]

南楼画角 提交于 2021-01-29 06:21:32

问题


I have a Library Project consisting of a single Activity with various fragments and helper classes.

I have FirebaseAnalytics put inside this library project, put in its own helper class. The instance in that helper class was retrieved using the code:

private val firebaseAnalytics = FirebaseAnalytics.getInstance(LibInterface.getInstance().srcApp)

As can be inferred from the code, I'm using the source application's Application instance to get the instanceof the FirebaseAnalytics used in the library project.

This source application also uses its own FirebaseAnalytics instance:

mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);

I'm taking a guess that both instances of FirebaseAnalytics would be the exact same, and that they would both be sending tracked events into the App's Firebase project.

Is it possible to send the events tracked in the library project into a separate Firebase project by getting the FirebaseAnalytics instance using the context of the sole Activity inside the Library project, and do I need a library-level google-services.json for that?


回答1:


It is not possible. Analytics works per-app, not per-library. There is currently no way for a library to redirect analytics information to a different project than the one that was used as the default for the app. This is important to make sure that each app owners understands the activity of the app in its entirety.



来源:https://stackoverflow.com/questions/52694971/is-it-possible-for-the-firebaseanalytics-instance-in-my-library-project-to-send

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!