respectlytics-react-native
v1.0.1
Published
Official Respectlytics SDK for React Native. Privacy-first analytics with automatic session management, offline event queuing, and zero device identifier collection.
Downloads
110
Maintainers
Readme
Respectlytics React Native SDK
Official Respectlytics SDK for React Native. Privacy-first analytics with automatic session management, offline event queuing, and zero device identifier collection.
Features
- 🔒 Privacy-First: No device identifiers (IDFA, GAID, Android ID)
- ⚡ Simple Integration: 3 lines of code to get started
- 📡 Offline Support: Events queue automatically and sync when online
- 🔄 Automatic Sessions: 30-minute inactivity timeout, handled internally
- 🎯 Cross-Session Tracking: Optional persistent user IDs
- 📱 Cross-Platform: iOS and Android support
Requirements
- React Native 0.70+
- iOS 15.0+ / Android API 21+
- Node.js 16+
Installation
npm install respectlytics-react-native @react-native-async-storage/async-storage @react-native-community/netinfoor with Yarn:
yarn add respectlytics-react-native @react-native-async-storage/async-storage @react-native-community/netinfoiOS Setup
cd ios && pod installAndroid Setup
No additional setup required - autolinking handles everything.
Quick Start
import Respectlytics from 'respectlytics-react-native';
// 1. Configure at app startup
Respectlytics.configure('your-api-key');
// 2. Enable user tracking (optional)
Respectlytics.identify();
// 3. Track events
Respectlytics.track('purchase');
Respectlytics.track('view_product', 'ProductScreen');API Reference
configure(apiKey: string)
Initialize the SDK with your API key. Call once at app startup.
Respectlytics.configure('your-api-key');track(eventName: string, screen?: string)
Track an event with an optional screen name.
Respectlytics.track('button_clicked');
Respectlytics.track('checkout_started', 'CartScreen');identify()
Enable cross-session user tracking. Generates and persists a random user ID.
Respectlytics.identify();reset()
Clear the user ID. Call when user logs out.
Respectlytics.reset();flush()
Force send all queued events immediately. Rarely needed - the SDK auto-flushes.
await Respectlytics.flush();Privacy by Design
| What we DON'T collect | Why | |----------------------|-----| | IDFA / GAID | Device advertising IDs can track users across apps | | Device fingerprints | Can be used to identify users without consent | | IP addresses | Used only for geolocation lookup, then discarded | | Custom properties | Prevents accidental PII collection |
| What we DO collect | Purpose | |-------------------|---------| | Event name | Analytics | | Screen name | Navigation analytics | | Random session ID | Group events in a session | | Random user ID (opt-in) | Cross-session analytics | | Platform, OS version | Debugging | | App version | Debugging |
Automatic Behaviors
The SDK handles these automatically - no developer action needed:
| Feature | Behavior | |---------|----------| | Session Management | New session ID generated on first event, rotates after 30 min inactivity | | Event Batching | Events queued and sent in batches (max 10 events or 30 seconds) | | Offline Support | Events queued when offline, sent when connectivity returns | | Retry Logic | Failed requests retry with exponential backoff (max 3 attempts) | | Background Sync | Events flushed when app enters background |
Offline Support
Events are automatically queued when offline and sent when connectivity returns:
- Events are immediately persisted to AsyncStorage
- Network status is monitored via NetInfo
- Queue is flushed when connectivity is restored
- Failed sends are retried with exponential backoff
Session Management
Sessions are managed automatically:
- New session starts on first event
- Session rotates after 30 minutes of inactivity
- No developer action required
License
This SDK is provided under a proprietary license. See LICENSE for details.
Support
- Documentation: https://respectlytics.com/docs/
- Issues: https://github.com/respectlytics/respectlytics-react-native/issues
- Email: [email protected]
