Basic Usage
Configure the Ensora SDK and track events
Basic Usage
Configure the SDK and start tracking events in your React Native or Expo app.
Provider Setup
import { EnsoraProvider } from '@ensora/react-native';
export default function RootLayout() {
return (
<EnsoraProvider
apiKey="your_api_key"
projectId="your_project_id"
>
<Stack />
</EnsoraProvider>
);
}Enable Touch Capture
<EnsoraProvider
apiKey="your_api_key"
projectId="your_project_id"
touchCapture={true}
>
<Stack />
</EnsoraProvider>Touch capture records taps and swipes for heatmap generation.
Track Custom Events
import { track } from '@ensora/react-native';
// Track a button press
track('button_pressed', { screen: 'home', label: 'Sign Up' });
// Track a purchase
track('purchase_completed', { amount: 29.99, currency: 'USD', plan: 'pro' });Auto-Captured Events
Ensora automatically captures the following events with no configuration:
| Event | Trigger |
|---|---|
session_start | App foreground / first launch |
nav | Expo Router pathname change |
error | Unhandled JS exception |
touch | User tap / swipe (requires touchCapture: true) |
Custom Ingest URL
<EnsoraProvider
apiKey="your_api_key"
projectId="your_project_id"
ingestUrl="https://your-ingest-endpoint.example.com"
>
<Stack />
</EnsoraProvider>Error Tracking
Unhandled exceptions are captured automatically. Add context to errors with custom events:
try {
await riskyOperation();
} catch (error) {
track('error_caught', { message: error.message, screen: 'checkout' });
}Best Practices
Event Naming
- Use
snake_casefor event names - Be descriptive:
checkout_completedoverdone - Group related events with a prefix:
onboarding_step_1,onboarding_step_2
Performance
touchCaptureadds minimal overhead but only enable it if you need heatmaps- Batch properties into a single
track()call rather than firing multiple events
Next Steps
- Session Replay — how recordings work
- Heatmaps — touch visualization
- API Reference — complete SDK reference
Last updated on