react-native-firebase icon indicating copy to clipboard operation
react-native-firebase copied to clipboard

[🐛] Deprecation warning in analytics

Open bladeSk opened this issue 3 months ago • 3 comments

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.settings jetifier=true for Android compatibility?
  • [ ] I am using the NPM package jetifier for 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-firebase version you're using that has this issue:
    • e.g. 5.4.3
  • Firebase module(s) you're using that has the issue:
    • e.g. Instance ID
  • Are you using TypeScript?
    • Y/N & VERSION

bladeSk avatar Dec 05 '25 11:12 bladeSk

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 use logEvent() instead.

bladeSk avatar Dec 05 '25 11:12 bladeSk

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

enhbolorZB avatar Dec 09 '25 03:12 enhbolorZB

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',
});

MichaelVerdon avatar Dec 09 '25 12:12 MichaelVerdon