From 6fa872f9db7c1dd8574d1f3fbc8c05da61f1ce39 Mon Sep 17 00:00:00 2001 From: Matthias Kutscheid Date: Wed, 3 Sep 2025 14:33:57 +0200 Subject: [PATCH 1/3] fix(analytics): fix the typing for screen_view event logging --- packages/analytics/lib/modular/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/analytics/lib/modular/index.d.ts b/packages/analytics/lib/modular/index.d.ts index 83a66da8fb..5d95bbafe0 100644 --- a/packages/analytics/lib/modular/index.d.ts +++ b/packages/analytics/lib/modular/index.d.ts @@ -105,8 +105,8 @@ export declare function logEvent( analytics: Analytics, name: 'screen_view', params?: { - firebase_screen: EventParams['firebase_screen']; - firebase_screen_class: EventParams['firebase_screen_class']; + screen_name: EventParams['firebase_screen']; + screen_class: EventParams['firebase_screen_class']; [key: string]: any; }, options?: AnalyticsCallOptions, From e4c320a0ca6340f227253a9fb697fa4e408c0918 Mon Sep 17 00:00:00 2001 From: Matthias Kutscheid Date: Wed, 3 Sep 2025 16:22:53 +0200 Subject: [PATCH 2/3] docs(analytics): adjust screen logging section of the analytics documentation --- docs/analytics/screen-tracking.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/analytics/screen-tracking.md b/docs/analytics/screen-tracking.md index c177d288cd..c228487e18 100644 --- a/docs/analytics/screen-tracking.md +++ b/docs/analytics/screen-tracking.md @@ -13,11 +13,11 @@ therefore there is no "one fits all" solution to screen tracking. The [React Navigation](https://reactnavigation.org/) library allows for various navigation techniques such as Stack, Tab, Native or even custom navigation. The `NavigationContainer` component which the library exposes provides -access to the current navigation state when a screen changes, allowing you to use the [`logScreenView`](/reference/analytics#logScreenView) +access to the current navigation state when a screen changes, allowing you to use the [`logEvent`](/reference/analytics#logEvent) method the Analytics library provides: ```jsx -import analytics from '@react-native-firebase/analytics'; +import { getAnalytics, logEvent } from '@react-native-firebase/analytics'; import { NavigationContainer } from '@react-navigation/native'; const App = () => { @@ -34,7 +34,7 @@ const App = () => { const currentRouteName = navigationRef.current.getCurrentRoute().name; if (previousRouteName !== currentRouteName) { - await analytics().logScreenView({ + await logEvent(getAnalytics(), 'screen_view', { screen_name: currentRouteName, screen_class: currentRouteName, }); @@ -57,15 +57,15 @@ documentation on the React Navigation website. The [`wix/react-native-navigation`](https://github.com/wix/react-native-navigation) provides 100% native platform navigation for React Native apps. To manually track screens, you need to setup a `componentDidAppear` event listener and manually call the -[`logScreenView`](/reference/analytics#logScreenView) method the Analytics library provides: +[`logEvent`](/reference/analytics#logEvent) method the Analytics library provides: ```js -import analytics from '@react-native-firebase/analytics'; +import { getAnalytics, logEvent } from '@react-native-firebase/analytics'; import { Navigation } from 'react-native-navigation'; Navigation.events().registerComponentDidAppearListener(async ({ componentName, componentType }) => { if (componentType === 'Component') { - await analytics().logScreenView({ + await logEvent(getAnalytics(), 'screen_view', { screen_name: componentName, screen_class: componentName, }); From ae1b3eb63892391ce43b793c00e641541ef3203d Mon Sep 17 00:00:00 2001 From: Matthias Kutscheid Date: Wed, 17 Sep 2025 13:18:06 +0200 Subject: [PATCH 3/3] adjust names of screen view parameters --- packages/analytics/lib/index.d.ts | 9 +-------- packages/analytics/lib/modular/index.d.ts | 4 ++-- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/packages/analytics/lib/index.d.ts b/packages/analytics/lib/index.d.ts index 2267bd9813..726b1a9b09 100644 --- a/packages/analytics/lib/index.d.ts +++ b/packages/analytics/lib/index.d.ts @@ -782,14 +782,7 @@ export namespace FirebaseAnalyticsTypes { number?: string; promotions?: Promotion[]; screen_name?: string; - /** - * Firebase-specific. Use to log a `screen_name` to Firebase Analytics. - */ - firebase_screen?: string; - /** - * Firebase-specific. Use to log a `screen_class` to Firebase Analytics. - */ - firebase_screen_class?: string; + screen_class?: string; search_term?: string; shipping?: Currency; tax?: Currency; diff --git a/packages/analytics/lib/modular/index.d.ts b/packages/analytics/lib/modular/index.d.ts index 5d95bbafe0..c33d8e46d6 100644 --- a/packages/analytics/lib/modular/index.d.ts +++ b/packages/analytics/lib/modular/index.d.ts @@ -105,8 +105,8 @@ export declare function logEvent( analytics: Analytics, name: 'screen_view', params?: { - screen_name: EventParams['firebase_screen']; - screen_class: EventParams['firebase_screen_class']; + screen_name: EventParams['screen_name']; + screen_class: EventParams['screen_class']; [key: string]: any; }, options?: AnalyticsCallOptions,