npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

event-sdk-react-native

v1.0.33

Published

This React Native SDK helps with tracking events and user behaviors automatically or manually, as well as identifying users and managing their groupings. It provides features like tracking events, user identification, SDK opt-out, and reset functionalitie

Downloads

2,299

Readme

Event SDK for React Native

This React Native SDK helps with tracking events and user behaviors automatically or manually, as well as identifying users and managing their groupings. It provides features like tracking events, user identification, SDK opt-out, and reset functionalities.

Installation

To install the package:

npm install your-package-name

## Usage
Initialization
Before using any of the features, you must initialize the SDK with your API key. This is typically done in your App component's useEffect.

## REQUIRED DEPENDENCIES TO USE: 
- npm install @react-native-async-storage/async-storage
- npm install react-native-device-info
- npm install @react-navigation/native
- npm install @react-navigation/stack
- npm install react-native-gesture-handler
- npm install react-native-safe-area-context
- npm install react-native-screens

import React, { useEffect, useRef } from 'react';
import EventSDK from 'your-package-name';
import { NavigationContainer } from '@react-navigation/native';

const App = () => {
  const navigationRef = useRef(null);

  useEffect(() => {
    const apiKey = 'your-api-key';
    EventSDK.initializeSDK(apiKey, { trackScreenViews: true });

    if (navigationRef.current) {
      EventSDK.setNavigationRef(navigationRef.current);
    }
  }, []);

  return (
    <NavigationContainer ref={navigationRef}>
      {/* Your navigation setup */}
    </NavigationContainer>
  );
};

export default App;


## initializeSDK(apiKey, options)
Initializes the SDK with the provided API key. Options can be used to enable automatic screen tracking.

## trackEvent(eventName, eventData)
Tracks a manual event with a specific event name and additional data.

## setNavigationRef(navigationRef)
Sets the navigation reference for tracking screen views automatically.

## getAnalyticsContext()
Fetches the current analytics context.

## group(groupId, traits)
Groups users under a specific group (e.g., a team or role).

## reset()
Resets the SDK, clearing any stored data or settings.

## optOut(isOptOut)
Opts the user out of tracking, passing true for opt-out or false for opt-in.

## identify(userId, traits)
Identifies a user by their unique ID and associated traits.


## COMPLETE CODE EXAMPLE: 

import React, { useState, useEffect, useRef } from 'react';
import EventSDK from 'your-package-name';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';

const Stack = createStackNavigator();

const HomeScreen = ({ navigation }) => {
  return (
    <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
      <Text>Home Screen</Text>
      <Button title="Go to Form" onPress={() => navigation.navigate('Form')} />
    </View>
  );
};

const FormScreen = () => {
  const [userId, setUserId] = useState('');
  const [firstName, setFirstName] = useState('');
  const [lastName, setLastName] = useState('');

  const handleIdentifyEvent = () => {
    const traits = { firstName, lastName };
    EventSDK.identify(userId, traits);
  };

  return (
    <View style={{ flex: 1 }}>
      {/* Form UI */}
      <Button title="Identify User" onPress={handleIdentifyEvent} />
    </View>
  );
};

const App = () => {
  const navigationRef = useRef(null);

  useEffect(() => {
    const apiKey = 'your-api-key';
    EventSDK.initializeSDK(apiKey, { trackScreenViews: true }); // For automatic Tracking
    if (navigationRef.current) { // For automatic Tracking 
      EventSDK.setNavigationRef(navigationRef.current);
    }
  }, []);

  return (
    <NavigationContainer ref={navigationRef}>
      <Stack.Navigator initialRouteName="Home">
        <Stack.Screen name="Home" component={HomeScreen} />
        <Stack.Screen name="Form" component={FormScreen} />
      </Stack.Navigator>
    </NavigationContainer>
  );
};

export default App;