Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/analytics/screen-tracking.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand All @@ -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,
});
Expand All @@ -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,
});
Expand Down
4 changes: 2 additions & 2 deletions packages/analytics/lib/modular/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down