File tree Expand file tree Collapse file tree 3 files changed +15
-21
lines changed
Expand file tree Collapse file tree 3 files changed +15
-21
lines changed Original file line number Diff line number Diff line change @@ -17,11 +17,9 @@ This example shows how to do screen tracking and send to Google Analytics. The a
1717
1818``` js
1919import * as React from ' react' ;
20- import { GoogleAnalyticsTracker } from ' react-native-google- analytics-bridge ' ;
20+ import analytics from ' @ react-native-firebase/ analytics' ;
2121import { NavigationNativeContainer } from ' @react-navigation/native' ;
2222
23- const tracker = new GoogleAnalyticsTracker (GA_TRACKING_ID );
24-
2523// Gets the current screen from navigation state
2624const getActiveRouteName = state => {
2725 const route = state .routes [state .index ];
@@ -52,9 +50,9 @@ export default function App() {
5250 );
5351
5452 if (previousRouteName !== currentRouteName) {
55- // The line below uses the Google Analytics tracker
53+ // The line below uses the @react-native-firebase/analytics tracker
5654 // Change this line to use another Mobile analytics SDK
57- tracker . trackScreenView ( currentRouteName);
55+ analytics (). setCurrentScreen (currentRouteName, currentRouteName);
5856 }
5957
6058 // Save the current route name for later comparision
Original file line number Diff line number Diff line change @@ -11,9 +11,7 @@ This example shows how to do screen tracking and send to Google Analytics. The a
1111
1212``` js
1313import { createAppContainer , createStackNavigator } from ' react-navigation' ;
14- import { GoogleAnalyticsTracker } from ' react-native-google-analytics-bridge' ;
15-
16- const tracker = new GoogleAnalyticsTracker (GA_TRACKING_ID );
14+ import analytics from ' @react-native-firebase/analytics' ;
1715
1816// gets the current screen from navigation state
1917function getActiveRouteName (navigationState ) {
@@ -34,13 +32,13 @@ const AppContainer = createAppContainer(AppNavigator);
3432export default () => (
3533 < AppContainer
3634 onNavigationStateChange= {(prevState , currentState , action ) => {
37- const currentScreen = getActiveRouteName (currentState);
38- const prevScreen = getActiveRouteName (prevState);
35+ const currentRouteName = getActiveRouteName (currentState);
36+ const previousRouteName = getActiveRouteName (prevState);
3937
40- if (prevScreen !== currentScreen ) {
41- // the line below uses the Google Analytics tracker
38+ if (previousRouteName !== currentRouteName ) {
39+ // The line below uses the @react-native-firebase/analytics tracker
4240 // change the tracker here to use other Mobile analytics SDK.
43- tracker . trackScreenView (currentScreen );
41+ analytics (). setCurrentScreen (currentRouteName, currentRouteName );
4442 }
4543 }}
4644 / >
Original file line number Diff line number Diff line change @@ -11,9 +11,7 @@ This example shows how to do screen tracking and send to Google Analytics. The a
1111
1212``` js
1313import { createAppContainer , createStackNavigator } from ' react-navigation' ;
14- import { GoogleAnalyticsTracker } from ' react-native-google-analytics-bridge' ;
15-
16- const tracker = new GoogleAnalyticsTracker (GA_TRACKING_ID );
14+ import analytics from ' @react-native-firebase/analytics' ;
1715
1816// gets the current screen from navigation state
1917function getActiveRouteName (navigationState ) {
@@ -34,13 +32,13 @@ const AppContainer = createAppContainer(AppNavigator);
3432export default () => (
3533 < AppContainer
3634 onNavigationStateChange= {(prevState , currentState , action ) => {
37- const currentScreen = getActiveRouteName (currentState);
38- const prevScreen = getActiveRouteName (prevState);
35+ const currentRouteName = getActiveRouteName (currentState);
36+ const previousRouteName = getActiveRouteName (prevState);
3937
40- if (prevScreen !== currentScreen ) {
41- // the line below uses the Google Analytics tracker
38+ if (previousRouteName !== currentRouteName ) {
39+ // the line below uses the @react-native-firebase/analytics tracker
4240 // change the tracker here to use other Mobile analytics SDK.
43- tracker . trackScreenView (currentScreen );
41+ analytics (). setCurrentScreen (currentRouteName, currentRouteName );
4442 }
4543 }}
4644 / >
You can’t perform that action at this time.
0 commit comments