Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

@analyticsdrop/react-native

Screen-journey analytics for React Native — the AnalyticsDrop iOS SDK behavior and wire format, on RN.

Install

npm install @analyticsdrop/react-native
# recommended for persistence across launches (optional):
npm install @react-native-async-storage/async-storage

If AsyncStorage isn't installed the SDK falls back to in-memory storage (events still upload; the anonymous id just won't survive a cold start).

Usage

import { AnalyticsDrop } from "@analyticsdrop/react-native";

// App entry, as early as possible:
AnalyticsDrop.start("ad_test_…", { endpoint: "http://localhost:3100", debug: true });

AnalyticsDrop.identify("cust_123");
AnalyticsDrop.track("purchase", { value: 9.99, plan: "pro" });

Automatic screen capture (React Navigation)

import { NavigationContainer, useNavigationContainerRef } from "@react-navigation/native";
import { createNavigationTracker } from "@analyticsdrop/react-native";

function App() {
  const navigationRef = useNavigationContainerRef();
  const tracker = createNavigationTracker(navigationRef);
  return (
    <NavigationContainer
      ref={navigationRef}
      onReady={tracker.onReady}
      onStateChange={tracker.onStateChange}
    >
      {/* … */}
    </NavigationContainer>
  );
}

The active route name becomes the screen id (analogous to a UIKit controller class name on iOS).

Manual naming

import { useAnalyticsDropScreen, AnalyticsDrop } from "@analyticsdrop/react-native";

function Checkout() {
  useAnalyticsDropScreen("Checkout"); // emits a `manual` screen view on mount
  // …
}

// or imperatively:
AnalyticsDrop.setScreenName("Checkout");

API

Method Description
AnalyticsDrop.start(apiKey, options?) Initialize. options: endpoint, debug, flushThreshold, flushInterval, sessionGrace, debounceInterval, storage.
AnalyticsDrop.identify(userId) Link an external user id.
AnalyticsDrop.track(name, properties?) Manual event; properties are string/number/boolean.
AnalyticsDrop.setScreenName(name) Manual screen view.
createNavigationTracker(ref) { onReady, onStateChange } for NavigationContainer.
useAnalyticsDropScreen(name) Hook: manual screen view on mount.

Sessions, batching (20 events / 30 s / on background), crash recovery, and the POST /v1/events transport are handled by @analyticsdrop/core, identical to iOS.

License

MIT — see LICENSE.


AnalyticsDrop is a product of Flywheel Studio.