GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — splitbee-js/splitbee-react-native at master · splitbee/splitbee-js

Expand file tree

/

splitbee-react-native

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
/

splitbee-react-native

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
src
src
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
package.json
package.json
 
 
tsconfig.json
tsconfig.json
 
 
yarn.lock
yarn.lock
 
 

README.md

Outline

Splitbee Analytics for React Native Apps

Used to track screen views & events of React Native & Expo Apps using Splitbee.

Usage with Expo

Install following expo dependencies:

expo install @splitbee/react-native expo-device expo-constants @react-native-async-storage/async-storage

We need those for getting the device data & persisting the user on a device.

Usage with React Native

Install following dependencies: @react-native-async-storage/async-storage & react-native-device-info

yarn add @splitbee/react-native react-native-device-info @react-native-async-storage/async-storage
npx pod-install

Please follow the official documentation of those libraries on how to link them correctly.

Usage

Initialize Splitbee

First of all you need to initialize the Splitbee SDK. For that, run splitbee.init with your token.

import splitbee from '@splitbee/react-native';

splitbee.init('YOUR_TOKEN'); // Take the token from the project settings in the Splitbee dashboard

Screen Tracking

Usage with react-navigation

In this example we are using react-navigation to screen views automatically.

import splitbee, { useTrackReactNavigation } from '@splitbee/react-native';

export default function Navigation() {
  const [{ onReady, onStateChange }, navigationRef] = useTrackReactNavigation();

  return (
    <NavigationContainer
      linking={LinkingConfiguration}
      ref={navigationRef}
      onReady={() => {
        onReady();
      }}
      onStateChange={() => {
        onStateChange();
      }}
    >
      <RootNavigator />
    </NavigationContainer>
  );
}

If you already have a ref set for the NavigationContainer, just pass it to useTrackReactNavigation

const navigationRef = useRef(null)
const [{ onReady, onStateChange }] = useTrackReactNavigation(navigationRef);

Usage with react-native-navigation

To setup automated screen tracking you need to add following code to your index.js

Navigation.events().registerComponentDidAppearListener(
  async ({ componentName, componentType }) => {
    if (componentType === 'Component') {
      await splitbee.screen(componentName);
    }
  }
);
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.