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 🙏

© 2026 – Pkg Stats / Ryan Hefner

track-react-native

v0.1.10

Published

React Native SDK for Track - User Behavior Analytics Platform

Readme

Track React Native SDK

A simple React Native SDK for tracking events.

Installation

npm install track-react-native @react-native-async-storage/async-storage
# or
yarn add track-react-native @react-native-async-storage/async-storage

Quick Start

import { Track, EventTypes } from 'track-react-native';

// Initialize the SDK
const track = Track.initialize({
  apiKey: 'your-api-key',
  apiUrl: 'https://your-api-url.com', // Optional
  debug: true, // Enable debug mode for detailed logging
});

// Set user ID - this will persist between app sessions
await track.setUserId('user123');

// Track events
await track.trackEvent({
  name: EventTypes.SCREEN_VIEW,
  path: '/home',
  pageTitle: 'Home Page'
});

// Track purchase
await track.trackEvent({
  name: EventTypes.PURCHASE,
  value: 99.99,
  itemId: 'premium-plan',
  itemName: 'Premium Plan',
  properties: {
    currency: 'USD'
  }
});

// Clear user ID when user logs out
await track.clearUserId();

User ID Management

The SDK automatically persists the user ID between app sessions using AsyncStorage. This ensures that events are properly associated with users even after app restarts.

// Set user ID
await track.setUserId('user123');

// Get current user ID
const userId = track.getUserId();

// Clear user ID (e.g., on logout)
await track.clearUserId();

Event Properties

interface TrackEvent {
  name: string;                   // Required: Event name
  properties?: object;            // Optional: Custom properties
  path?: string;                  // Optional: Page/screen path
  pageTitle?: string;             // Optional: Page/screen title
  value?: number;                 // Optional: Numeric value
  itemId?: string;                // Optional: Item ID
  itemName?: string;              // Optional: Item name
  itemCategory?: string;          // Optional: Item category
  userId?: string;                // Optional: User ID
  category?: string;              // Optional: Event category
  action?: string;                // Optional: Action performed
}

Available Event Types

const EventTypes = {
  // Page/Screen Events
  SCREEN_VIEW: 'screen_view',
  
  // User Events
  LOGIN: 'login',
  LOGOUT: 'logout',
  
  // Conversion Events
  PURCHASE: 'purchase',
  SIGNUP: 'signup',
  SUBSCRIBE: 'subscribe',
  
  // Action Events
  BOOK: 'book',
  CANCEL: 'cancel',
  VIEW_ITEM: 'view_item',
  BEGIN_CHECKOUT: 'begin_checkout',
  ADD_TO_CART: 'add_to_cart'
}

Event Categories

type EventCategory = 
  | 'engagement'    // User interactions (clicks, form submissions)
  | 'conversion'    // Business goals (purchases, signups)
  | 'navigation'    // Page/screen views
  | 'error'         // Error tracking
  | 'performance'   // Performance metrics
  | 'custom'        // Custom events

Event Actions

type EventAction = 
  | 'view'      // Viewing content
  | 'click'     // Clicking elements
  | 'submit'    // Form submissions
  | 'scroll'    // Scrolling behavior
  | 'search'    // Search actions
  | 'filter'    // Filtering content
  | 'sort'      // Sorting content
  | 'download'  // File downloads
  | 'share'     // Content sharing
  | 'custom'    // Custom actions

Error Handling

The SDK provides detailed error information when debug mode is enabled. Common errors include:

  1. API Connection Issues

    • Check if the apiUrl is correct
    • Verify network connectivity
    • Ensure the API endpoint is accessible
  2. Authentication Errors

    • Verify your apiKey is correct
    • Check if the API key has proper permissions
  3. Request Format Issues

    • Ensure event names are strings
    • Properties should be a valid JSON object
    • Timestamp should be a valid ISO string

Example of error handling with debug mode:

Track.initialize({
  apiKey: 'your-api-key',
  debug: true, // Enable debug mode
  apiUrl: 'https://your-api-url.com'
});

const track = Track.getInstance();

try {
  await track.trackEvent({
    name: EventTypes.SCREEN_VIEW,
    path: '/home',
    pageTitle: 'Home Page',
    properties: {
      test: 'value'
    }
  });
} catch (error) {
  // Debug mode will show:
  // - The API URL being used
  // - The event data being sent
  // - Detailed error message from the server
  console.error('Full error details:', error);
}

License

MIT