firebase / firebase-android-sdk

Firebase Android SDK
https://firebase.google.com
Apache License 2.0
2.27k stars 575 forks source link

FR: Support for multiple Analytics instances #1264

Open IjzerenHein opened 4 years ago

IjzerenHein commented 4 years ago

Feature proposal

It is currently only possible to log Firebase Analytics data to the default Firebase app. This "tight" coupling of Analytics with the default app makes it difficult/impossible to log analytics data to other Firebase Apps.

One example of a scenario where logging to multiple Firebase projects is needed, is the standard Expo client, which is a universal react-native app and can load (and host) different projects (where a project can be described as some JavaScript code, assets, and configuration settings). In this case, a unique Firebase App is created for each loaded project, which utilizes its own Firebase configuration.

The standard Expo client can be considered a "testing" environment, with which people can quickly get started and iterate/share their projects. It is therefore not essential that each additional Firebase Analytics instance behaves exactly as the default one. Instead, it would be sufficient if manual logging of events is possible.

Other scenarios where data-driven apps want to record data to multiple Firebase projects are also imaginable.

As a current workaround for the standard Expo client, a community version of a pure JavaScript Firebase Analytics client has been developed. It uses the "unstable" Measurement Protocol version 2. Another drawback of this approach is that it requires additional configuration and an additional web-app needs to be configured in the Firebase project (in order to obtain a measurementId to log to). https://github.com/firebase/firebase-js-sdk/issues/2644

Optionally, it would be nice (food for thought), if the lifecycle events that are captured for the default Analytics instance are routable, and could for instance be "routed" to one of the other Analytics instances, instead of just the default instance.

Proposed API:

FirebaseAnalytics analytics = FirebaseAnalytics.getInstance(app);
analytics.logEvent(..)

Love to hear your thoughts 🧡

quanlt3 commented 4 years ago

Firebase Analytics only works for the default Firebase app, It means we can't use custom property, audience in Firebase Remote Config. I think this feature is very important.

jeffbking commented 3 years ago

We would like to use Google analytics through firebase to track events in our SDK code. Unfortunately, Google Analytics does not allow us to specify the firebase project in which to send the events for tracking, it uses the global one as default. We would need a mechanism to specify to google analytics which firebase project to use when sending event data.

Decoydoll commented 1 year ago

We also think this feature should be supported. In my company, there is a case where our app that already use Firebase Analytics SDK and send events to our company GA4 property needs to send some events to our sister company GA4 account which require us to setup a new separated Firebase Project. And that cannot be done because of the limitation.

It can be done via the Measurement Protocol GA4, but we cannot get the geographic data from it.

edharkhimich commented 1 year ago

Is there any update regarding this feature?

eduardogalbiati commented 11 months ago

is there any update here? this feature would be extremelly useful for my project

Pedrobam commented 11 months ago

I would like this feature in my project too

AdamBebko commented 10 months ago

Same here. How else do Prod and Dev environments work?