firebase / firebase/firebase-ios-sdk
FR: Support for multiple Analytics instances
- Dominant language
- C++
- Stars
- 6.7k
- Forks
- 1.8k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 75
Description
### 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](https://docs.expo.io/versions/latest/workflow/how-expo-works/), 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:
```
FIRApp *app = [FIRApp configureWithName:@"myawesomeapp" options:options];
FIRAnalytics *analytics = [FIRAnalytics analyticsForApp:app];
[analytics logEventWithName:@"myawesomeevent" parameters:${}];
```
Love to hear your thoughts 🧡
Contributor guide
Assessment
This issue has not been assessed yet.