fix(analytics): fix the typing for screen_view event logging
Description
Motivation:
Since migrating from logScreenView to logging screen_view events we lost the screen tracking in our project. To prevent this from happening to other developers only the typing information has to be fixed.
Without the change developers are encouraged to use faulty parameter names, leading to errors in the firebase backend and dropped events due to reserved property names. If the names screen_name and screen class are used the issue does not exist and screen views are tracked as before via logScreenView
See issue https://github.com/invertase/react-native-firebase/issues/8609 for more details on this.
It is likely that the EventParams firebase_screen and firebase_screen_class are not needed any more.
Related issues
Fixes #8609
Release Summary
This changes the names you need to supply to logEvent(analytics, 'screen_view') to what it should have been already. Without a change to parameter names your screen tracking will not work!
Checklist
- I read the Contributor Guide and followed the process outlined there for submitting PRs.
- [X] Yes
- My change supports the following platforms;
- [X]
Android - [X]
iOS - [X]
Other(macOS, web)
- [X]
- My change includes tests;
- [-]
e2etests added or updated inpackages/\*\*/e2e - [-]
jesttests added or updated inpackages/\*\*/__tests__
- [-]
- [X] I have updated TypeScript types that are affected by my change.
- This is a breaking change;
- [X] Yes (it will require changes to the passed in parameters, but it is more fixing than breaking)
- [-] No
Test Plan
I only changed typings and validated the change in my own Project since it requires checks on the firebase debugging backend.
And since I read the whole guide I am allowed to add some flames in the end :) :fire:
The latest updates on your projects. Learn more about Vercel for GitHub.
| Project | Deployment | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| react-native-firebase | Preview | Comment | Sep 17, 2025 11:21am |
it would be great to get some movement into this rather minor change :) so far @liamjones had a look, but we need another person to review it
it would be great to get some movement into this rather minor change :) so far @liamjones had a look, but we need another person to review it
Can we expedite this one please, it will help us a lot, tnx :)
LGTM thanks for making this:
Are we able to get it fully matching https://firebase.google.com/docs/analytics/screenviews#web ?? Our aim on React Native Firebase is to make it match the js-sdk so users if not looking at react native docs can also refer to js.
unfortunately not, as those property names are illegal for the native SDKs. I also thought about exposing the names like on the JS SDK but then change them internally, but I am a bit lost in the js code there
The only possibility to keep the invalid parameter names I see right now is to have an if in the logEvent function that rebuilds the parameters. If you have any better hints I would gladly implement them. @MichaelVerdon
any news on this?
I'd also love to get some clarity here before I change to using logEvent and potentially break my analytics. I'm seeing a TypeScript warning when using logEvent with name 'screen_view'. Is this how it's supposed to be?:
Before: logScreenView(firebaseAnalytics, { screen_name: name })
After: logEvent(firebaseAnalytics, 'screen_view', { firebase_screen: name })
This is on v23.4.1
yes. you MUST NOT use the names starting with firebase_ as those names are illegal for the native frameworks. The warning tells you that you cannot use screen_view together with firebase_screen. Production will not highlight that on the type script layer, but you will break your analytics with the code above.
If you want to ensure you get no warning in prod you need to specify both firebase_screen_class and firebase_screen. But this will break your screen tracking.
Something like this will throw a TS warning but work:
logEvent(getAnalytics(), 'screen_view', { screen_class: screenName, screen_name: screenName, });
@AdamGerthel Beyond what @GoodSir42 said, you can check the events as they are picked up by Google Analytics by using DebugView.
You'll then be able to see errors in the events like I screenshotted above: https://github.com/invertase/react-native-firebase/pull/8687#discussion_r2354970338
Any updates on this?
I gave up on this PR as I have the feeling nobody really cares. I understand that this is a very minor thing but it breaks the projects of those that follow the implementation guides and I have the impression that it is not accepted because it breaks the compatibility with the pure web implementation of firebase. If we get a second reviewer on board here I am happy to merge it. if there are requests for changes I would be equally happy to make them, but so far I think there won't be priority on this issue.
I care - just a bit too busy to get it over the line as of yet, but it's still open so it shouldn't be dropped
No offense, but why is it taking so long to merge this simple fix?