splitbee-js icon indicating copy to clipboard operation
splitbee-js copied to clipboard

Splitbee/react-native expo routing tracking issue

Open AlejandroGutierrezB opened this issue 3 years ago • 2 comments

Hey guys I have an issue with routing tracking. I don't get any data in this regard, dashboard still says "Waiting for data" Envent tracking using splitbee.track() works like a champ though.

I am using "expo": "~42.0.1" and this is how my app.tsx looks:

import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { NavigationContainer } from '@react-navigation/native';
import { navigationRef } from '../services/Navigation';
import splitbee, { useTrackReactNavigation } from '@splitbee/react-native';

splitbee.init('key');
const Stack = createNativeStackNavigator();

export default function App() {
  const [{ onReady, onStateChange }] = useTrackReactNavigation(navigationRef);
  return (
    <>
      <StatusBar style="auto" />
      <NavigationContainer 
          ref={navigationRef}
          onReady={() => {
                 onReady();
           }}
          onStateChange={() => {
              onStateChange();
       }}>
        <Stack.Navigator screenOptions={screenOptions} initialRouteName={INITIAL_ROUTE}>
          {... Stack}
        </Stack.Navigator>
      </NavigationContainer>
    </>
  );
}
import { StackActions, createNavigationContainerRef } from '@react-navigation/native';
export const navigationRef = createNavigationContainerRef<RootStackProps>();

AlejandroGutierrezB avatar Nov 16 '21 17:11 AlejandroGutierrezB

Hey @AlejandroGutierrezB

It seems like you forgot to add onReady and onStateChange properties to NavigationContainer

<NavigationContainer 
    ref={navigationRef}  
    onReady={() => {
       onReady();
    }}
    onStateChange={() => {
        onStateChange();
    }}>

Please follow our docs: https://splitbee.io/docs/react-native-expo-analytics

tobiaslins avatar Nov 17 '21 14:11 tobiaslins

Hey @tobiaslins thanks for the quick response, I added it now and build from 0 but still got the issue. Will update my initial message with the right code.

AlejandroGutierrezB avatar Nov 17 '21 19:11 AlejandroGutierrezB