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

@product-intelligence-hub/sdk-react-native

v0.2.0

Published

React Native SDK for Product Intelligence Hub

Readme

@product-intelligence-hub/sdk-react-native

React Native SDK for Product Intelligence Hub.

Installation

npm install @product-intelligence-hub/sdk-react-native
# or
yarn add @product-intelligence-hub/sdk-react-native
# or
pnpm add @product-intelligence-hub/sdk-react-native

Peer Dependencies

npm install @react-native-async-storage/async-storage

Optional for screen tracking:

npm install @react-navigation/native

Quick Start

import PIH from "@product-intelligence-hub/sdk-react-native";

// Initialize the SDK
const pih = PIH.init({
  apiKey: "your-api-key",
  projectId: "proj_xxx",
  environment: "production",
});

// Track an event
pih.track("button_pressed", {
  button_id: "checkout",
  screen: "Cart",
});

// Identify a user
pih.identify("user_123", {
  email: "[email protected]",
  subscription: "premium",
});

Configuration Options

PIH.init({
  // Required
  apiKey: string;           // Environment API key
  projectId: string;        // Project ID (proj_xxx)
  environment: string;      // Environment name

  // Optional
  apiUrl?: string;          // Ingest API URL (has default, override for self-hosted)
  tenantId?: string;        // Tenant ID for multi-tenant apps
  debug?: boolean;          // Enable debug logging (default: false)
  flushInterval?: number;   // Batch flush interval in ms (default: 10000)
  flushAt?: number;         // Flush when queue reaches this size (default: 20)
  maxQueueSize?: number;    // Max events to queue (default: 1000)
  sessionTimeout?: number;  // Session timeout in ms (default: 1800000)
  trackLifecycle?: boolean; // Track app lifecycle events (default: true)

  // Callbacks
  onError?: (error: PIHError) => void;
});

API

PIH.init(config)

Initialize the SDK. Returns the client instance.

pih.track(eventName, properties?, options?)

Track an event.

pih.track("item_added_to_cart", {
  product_id: "prod_123",
  quantity: 2,
  price: 29.99,
});

pih.identify(userId, traits?)

Identify the current user.

pih.identify("user_123", {
  email: "[email protected]",
  name: "Jane Doe",
});

pih.trackScreen(screenName, params?)

Manually track a screen view.

pih.trackScreen("ProductDetail", { product_id: "prod_123" });

pih.flush()

Force flush the event queue.

await pih.flush();

pih.reset()

Reset identity (for logout).

await pih.reset();

Screen Tracking with React Navigation

import { NavigationContainer } from "@react-navigation/native";
import PIH from "@product-intelligence-hub/sdk-react-native";

function App() {
  const navigationRef = useNavigationContainerRef();
  const pih = PIH.getInstance();

  useEffect(() => {
    if (pih) {
      const cleanup = pih.setupScreenTracking(navigationRef, {
        // Optional: transform screen names
        getScreenName: (route) => route.name,
        // Optional: include route params
        includeParams: true,
      });
      return cleanup;
    }
  }, []);

  return (
    <NavigationContainer ref={navigationRef}>
      {/* ... */}
    </NavigationContainer>
  );
}

Lifecycle Tracking

By default, the SDK tracks app lifecycle events:

  • app_opened - App comes to foreground
  • app_backgrounded - App goes to background

Disable with:

PIH.init({
  // ...
  trackLifecycle: false,
});

// Or at runtime
pih.disableLifecycleTracking();
pih.enableLifecycleTracking();

Platform Detection

The SDK automatically detects the platform (ios or android) from React Native.

TypeScript Support

Full TypeScript support included:

import type {
  RNPIHConfig,
  TrackEvent,
  ScreenTrackerOptions,
} from "@product-intelligence-hub/sdk-react-native";

Related