Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

My screen names aren't appearing in Firebase Analytics Dashboard

I am trying to track screen names on react-native-firebase in conjunction with react-navigation.

Here is my code.

const tracker = firebase.analytics()

function getCurrentRouteName(navigationState) {
  if (!navigationState) {
    return null;
  }
  const route = navigationState.routes[navigationState.index];
	// dive into nested navigators
  if (route.routes) {
    return getCurrentRouteName(route);
  }
  return route.routeName;
}

export default class AppNavigation extends Component {

	render() {
		StatusBar.setBarStyle('light-content');

		return (
			<MainScreenNavigator 
				onNavigationStateChange={(prevState, currentState) => {
					const currentScreen = getCurrentRouteName(currentState);
					const prevScreen = getCurrentRouteName(prevState);
		
					if (prevScreen !== currentScreen) {
						// the line below uses the Google Analytics tracker
						// change the tracker here to use other Mobile analytics SDK.
						tracker.setCurrentScreen(currentScreen);
					}
				}}
			/>
		);
	}
}

When I console log the screen names, they appear as desired. However, I'm not seeing the results in Firebase console. When I filter screen by name it just says (not set). Am I doing something wrong in my code? I am importing firebase from 'react-native-firebase' as well.

like image 774
myself Avatar asked Mar 20 '18 20:03

myself


People also ask

How long does it take for my Firebase Analytics data to show up?

But on Android devices with Play Services, this one hour timer is across all apps using Firebase Analytics. In addition, Firebase Analytics will send down all of its data from the client if your user triggers a conversion event (like making an in-app purchase).

How do I know if Firebase Analytics is working?

In the Firebase console, open your project. Select Analytics from the menu to view the Analytics reporting dashboard. The Events tab shows the event reports that are automatically created for each distinct type of event logged by your app. Read more about the Analytics reporting dashboard in the Firebase Help Center.

Is Firebase replacing Google Analytics?

tl;dr: Google Analytics for Firebase, formerly Firebase Analytics, is now known as Google Analytics. It works great for your mobile apps! Oh, but Google Analytics for Mobile has been deprecated; they recommend you use Firebase Analytics, which, as you'll recall, is now Google Analytics.


1 Answers

The code above is solid. It turns out you have to wait a half a day or so before data is populated. Not sure if I missed that in the docs. If you're using react-navigation and firebase, this code works!

like image 118
myself Avatar answered Oct 18 '22 02:10

myself