Skip to content

fix(plugin-firebase): use the modular API functions instead of instance methods - #1341

Open
Jack-Gill-TH wants to merge 1 commit into
segmentio:masterfrom
Jack-Gill-TH:fix/firebase-plugin-modular-api
Open

Jack-Gill-TH wants to merge 1 commit into
segmentio:masterfrom
Jack-Gill-TH:fix/firebase-plugin-modular-api

Conversation

@Jack-Gill-TH

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #1075 (issue #1105). That change moved instance creation to the
modular getAnalytics(getApp()), which removed the getApp() warning. The
plugin still called methods on the returned instance, so React Native
Firebase still logged a deprecation warning for every call.

Changes

  • track: logEvent(analytics, name, props)
  • identify: setUserId(analytics, id) and setUserProperties(analytics, traits)
  • reset: resetAnalyticsData(analytics)
  • screen: logEvent(analytics, 'screen_view', props). logScreenView is
    deprecated in the namespaced and the modular API.

The screen_view overload in the RNFB typings names the params
firebase_screen and firebase_screen_class. The old logScreenView
forwarded screen_name and screen_class, which the native SDKs read. The
payload is unchanged, so screen.ts casts the params type, with a comment.

The unit tests now expect the modular functions with the instance as the
first argument. They also assert that the deprecated instance methods are not
called.

Testing

  • jest in the plugin: 4 suites, 11 tests pass. All 11 failed before the change.
  • tsc --noEmit, eslint and prettier --check pass. The typecheck runs
    against RNFB 22.2.0.
  • Runtime check in an Expo SDK 55 app (React Native 0.83, RNFB 22.4.0, iOS).
    Plugin 1.0.0 produced 18 deprecation warnings for 18 Firebase calls. With
    this change, 16 calls (logEvent x14, setUserId, setUserProperties) all
    took the modular path and produced no warning.

Not tested: reset at runtime (same pattern as the others), Android, and RNFB
versions between 22.2.0 and 22.4.0 at runtime.

…ce methods

React Native Firebase v22 deprecates calling methods on the analytics
instance. segmentio#1075 created the instance with getAnalytics(getApp()), but the
plugin still called logEvent, logScreenView, setUserId, setUserProperties
and resetAnalyticsData on that instance. Each call logged a deprecation
warning.

Call the modular functions with the instance as the first argument.
logScreenView is deprecated in both APIs, so send a screen_view event
with logEvent and keep the screen_name and screen_class payload.

Refs segmentio#1105

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant