Update deprecated Firebase API for RN Firebase v22 #62

Closed
opened 2026-04-15 12:01:07 +00:00 by Omexae · 0 comments
Contributor

Checklist

  • I have searched existing issues and pull requests to ensure this feature has not been requested before
  • I have reviewed the documentation to confirm this feature doesn't already exist
  • This feature aligns with the project's goals

Feature Description

Following update to React Native Firebase v22, the current namespaced API used in the project is considered deprecated, provoking a lot of warnings that pollutes logs journal. The modular API approach should be used from now on.

Problem Statement

The warnings coming from Firebase to warn that all namespaced API are deprecated and will be removed in the next major release pollutes logs journal.

Proposed Solution

Following the official documentation (https://rnfirebase.io/migrating-to-v22), the solution would be to switch to the modular API, where logEvent is imported as a standalone function instead of calling it through the analytics instance.
This means that the createFirebaseLogger signature needs to be updated to follow this solution.
This update should not any impact on the current behavior of Firebase logger, though it would bring a breaking change for future releases.

Use Case

If a react native application using this library try to upgrade their Firebase dependency to the next major version, the Firebase logger implemented in this library could break.

Alternatives Considered

An alternative could be to prevent this library to allow users to upgrade to the next RN Firebase major update, but that would means renouncing the security fixes and new features brought along the update.

Examples

Here is an example on how a Firebase logger would be initialized in an application using the updated library.

import {
  createFirebaseLogger,
  init,
} from '@openrn/react-native-logging-tools';
import analytics, { logEvent } from '@react-native-firebase/analytics';

export const initLogging = () => {
  init({
    analytics: [
      createFirebaseLogger(analytics, logEvent),
    ]
  });
};

Implementation Ideas

Updating the createFirebaseLogger to the following would do the trick :

export const createFirebaseLogger =
  (analytics: any, logEvent: any, printLogs = false) =>
  (event: string, params: any, eventType: number) => {
    if (eventType !== -1 && excludeLogs.firebase?.includes(eventType)) {
      return;
    }
    try {
      logEvent(analytics, event, params);
    } catch (error) {
      if (printLogs) {
        console.log('Error: Unable to tag firebase analytics event:', error);
      }
    }
  };

Additional Context

None

## Checklist - [x] I have searched existing issues and pull requests to ensure this feature has not been requested before - [x] I have reviewed the documentation to confirm this feature doesn't already exist - [x] This feature aligns with the project's goals ## Feature Description Following update to React Native Firebase v22, the current namespaced API used in the project is considered deprecated, provoking a lot of warnings that pollutes logs journal. The modular API approach should be used from now on. ## Problem Statement The warnings coming from Firebase to warn that all namespaced API are deprecated and will be removed in the next major release pollutes logs journal. ## Proposed Solution Following the official documentation (https://rnfirebase.io/migrating-to-v22), the solution would be to switch to the modular API, where `logEvent` is imported as a standalone function instead of calling it through the `analytics` instance. This means that the `createFirebaseLogger` signature needs to be updated to follow this solution. This update should not any impact on the current behavior of Firebase logger, though it would bring a breaking change for future releases. ## Use Case If a react native application using this library try to upgrade their Firebase dependency to the next major version, the Firebase logger implemented in this library could break. ## Alternatives Considered An alternative could be to prevent this library to allow users to upgrade to the next RN Firebase major update, but that would means renouncing the security fixes and new features brought along the update. ## Examples Here is an example on how a Firebase logger would be initialized in an application using the updated library. ```javascript import { createFirebaseLogger, init, } from '@openrn/react-native-logging-tools'; import analytics, { logEvent } from '@react-native-firebase/analytics'; export const initLogging = () => { init({ analytics: [ createFirebaseLogger(analytics, logEvent), ] }); }; ``` ## Implementation Ideas Updating the `createFirebaseLogger` to the following would do the trick : ```javascript export const createFirebaseLogger = (analytics: any, logEvent: any, printLogs = false) => (event: string, params: any, eventType: number) => { if (eventType !== -1 && excludeLogs.firebase?.includes(eventType)) { return; } try { logEvent(analytics, event, params); } catch (error) { if (printLogs) { console.log('Error: Unable to tag firebase analytics event:', error); } } }; ``` ## Additional Context None
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openrn/react-native-logging-tools#62
No description provided.