[🐛] Deprecation warning in analytics
Issue
This warning is produced each time analytics tracks something:
import analytics from '@react-native-firebase/analytics'
analytics().logScreenView({ screen_name: 'test', screen_class: 'test' })
WARN This method is deprecated (as well as all React Native Firebase namespaced API) and will be removed in the next major release as part of move to match Firebase Web modular SDK API. Please see migration guide for more details: https://rnfirebase.io/migrating-to-v22 Please use
getApp()instead.
Project Files
Javascript
Click To Expand
package.json:
"@react-native-firebase/analytics": "^23.5.0",
"@react-native-firebase/app": "^23.5.0",
"@react-native-firebase/messaging": "^23.5.0",
firebase.json for react-native-firebase v6:
# N/A
iOS
Click To Expand
ios/Podfile:
- [ ] I'm not using Pods
- [x] I'm using Pods and my Podfile looks like:
# N/A
AppDelegate.m:
// N/A
Android
Click To Expand
Have you converted to AndroidX?
- [ ] my application is an AndroidX application?
- [ ] I am using
android/gradle.settingsjetifier=truefor Android compatibility? - [ ] I am using the NPM package
jetifierfor react-native compatibility?
android/build.gradle:
// N/A
android/app/build.gradle:
// N/A
android/settings.gradle:
// N/A
MainApplication.java:
// N/A
AndroidManifest.xml:
<!-- N/A -->
Environment
Click To Expand
react-native info output:
OUTPUT GOES HERE
-
Platform that you're experiencing the issue on:
- [x] iOS
- [x] Android
- [ ] iOS but have not tested behavior on Android
- [ ] Android but have not tested behavior on iOS
- [ ] Both
-
react-native-firebaseversion you're using that has this issue:-
e.g. 5.4.3
-
-
Firebasemodule(s) you're using that has the issue:-
e.g. Instance ID
-
-
Are you using
TypeScript?-
Y/N&VERSION
-
- 👉 Check out
React Native FirebaseandInvertaseon Twitter for updates on the library.
Additionally, this warning is shown for logScreenView, which is recommended in the docs:
WARN This method is deprecated (as well as all React Native Firebase namespaced API) and will be removed in the next major release as part of move to match Firebase Web modular SDK API. Please see migration guide for more details: https://rnfirebase.io/migrating-to-v22. Method called was
logScreenView. Please uselogEvent()instead.
Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '/MyPath/node_modules/@react-native-firebase/app/lib/common' is not supported resolving ES modules imported from /MyPath/node_modules/@react-native-firebase/analytics/lib/index.js Did you mean to import "@react-native-firebase/app/lib/common/index.js"?
"@react-native-firebase/analytics": "^23.7.0", "@react-native-firebase/app": "^23.7.0" "expo": "~53.0.22", "react": "19.0.0", "react-dom": "19.0.0",
the above error occurs when doing expo prebuild, how to fix it
Hi there
import analytics from '@react-native-firebase/analytics'
analytics().logScreenView({ screen_name: 'test', screen_class: 'test' })
This is the name-spaced API, the docs are yet to be updated to only use modular examples but you should be using the modular API as we will be scrapping the name-spaced (which is the one you are currently using).
To use the modular api it should look something like this:
import { getAnalytics, logEvent } from '@react-native-firebase/analytics';
const analytics = getAnalytics();
await logEvent(analytics, 'screen_view', {
firebase_screen: 'HomeScreen',
firebase_screen_class: 'HomeScreen',
});