@datacanva/react-native-tracker
v0.1.9
Published
Datacanva web tracker API for react native.
Downloads
95
Readme
React Native Tracker
A lightweight, configurable tracking library for React Native applications. Automatically collects device information, tracks navigation with visit depth and duration, and provides a React hook for app state changes (land/leave events).
Installation
npm install @datacanva/react-native-tracker
# or
yarn add @datacanva/react-native-trackerOptional Peer Dependencies
For enhanced device information collection, you can optionally install:
npm install react-native-uuid react-native-device-info react-native-localize react-native-ad-id
# or
yarn add react-native-uuid react-native-device-info react-native-localize react-native-ad-idNote: These dependencies are completely optional. If you want to disable device info collection or only use core tracking features, you can skip this step. However, if installed, some packages may require native configuration. Please follow their respective setup guides.
Quick Start
import { Tracker, useAppStateTracker } from "@datacanva/react-native-tracker";
// 1. Initialize the tracker
const tracker = new Tracker("https://datacanva.com", "your-tracker-id");
// 2. Track App State (Land/Leave) with React Hook
function App() {
useAppStateTracker(tracker);
// your app content...
}
// 3. Track navigation
tracker.trackNavigation("HomeScreen");
tracker.trackNavigation("ProfileScreen");
// 4. Track custom events
await tracker.track({ action: "button_click" });