firebase-android-sdk icon indicating copy to clipboard operation
firebase-android-sdk copied to clipboard

FR: Support for multiple Analytics instances

Open IjzerenHein opened this issue 5 years ago • 7 comments

Feature proposal

  • Firebase Component: Analytics

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 🧡

IjzerenHein avatar Feb 21 '20 10:02 IjzerenHein

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.

quanlt3 avatar May 25 '20 04:05 quanlt3

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.

jeffbking avatar Oct 19 '21 13:10 jeffbking

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.

Decoydoll avatar Dec 09 '22 01:12 Decoydoll

Is there any update regarding this feature?

edharkhimich avatar Sep 08 '23 19:09 edharkhimich

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

eduardogalbiati avatar Nov 01 '23 19:11 eduardogalbiati

I would like this feature in my project too

Pedrobam avatar Nov 01 '23 19:11 Pedrobam

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

AdamBebko avatar Dec 04 '23 19:12 AdamBebko