@avibra/pulse-rn-sdk
v1.1.4
Published
Pulse React Native SDK — AI voice survey widget for mobile apps
Readme
@avibra/pulse-rn-sdk
AI-powered voice feedback SDK for React Native apps. Surfaces conversational voice prompts when users perform significant actions.
How It Works
- Trigger -- SDK polls backend or receives triggers from event tracking
- Prompt -- Animated FAB + tooltip card appears
- Accept -- User taps "Yes, let's go" -- browser opens the voice call page
- Voice Call -- Handled by the Pulse web SDK on
connect-pulse.avibra.com
Installation
npm install @avibra/pulse-rn-sdkPeer Dependencies
npm install @react-native-async-storage/async-storage @react-native-community/netinfoiOS
cd ios && pod installAndroid
No additional setup needed.
Usage
import React, { useEffect } from 'react';
import { PulseProvider, Pulse } from '@avibra/pulse-rn-sdk';
export default function App() {
useEffect(() => {
Pulse.init({
partnerId: 'your_partner_id',
userId: 'current_user_id',
mode: 'prod',
returnUrl: 'myapp://',
debug: true,
theme: {
primary: '#4338CA',
onPrimary: '#FFFFFF',
background: '#FFFFFF',
},
});
return () => Pulse.destroy();
}, []);
return (
<PulseProvider>
<YourNavigator />
</PulseProvider>
);
}Track Events
Pulse.trackEvent('ACCOUNT_CLOSE_CLICKED', { plan: 'pro' });Identify Users
Pulse.identifyUser({
first_name: 'Jane',
last_name: 'Doe',
email: '[email protected]',
});Configuration
| Option | Type | Default | Description |
|---|---|---|---|
| partnerId | string | required | Partner application ID |
| userId | string | required | Current user's unique identifier |
| apiKey | string | -- | Sent as X-Api-Key on all API requests |
| mode | 'staging' \| 'st2' \| 'prod' | 'prod' | Target environment |
| baseUrl | string | -- | Override API base URL (takes precedence over mode) |
| connectUrl | string | https://connect-pulse.avibra.com | Voice call page URL |
| returnUrl | string | -- | Deep link to return to after call ends (e.g. avibra://home) |
| theme | Partial<ThemeConfig> | -- | UI theme customization |
| debug | boolean | false | Enable verbose logging |
| pollIntervalMs | number | 30000 | Trigger polling interval |
| maxOfflineQueueSize | number | 100 | Offline event buffer size |
Environments
| mode | Base URL |
|---|---|
| prod (default) | https://pulse.avibra.com/api/v1 |
| staging | https://pulse.avibra.com/staging/api/v1 |
| st2 | https://pulse.avibra.com/st2/api/v1 |
Callbacks
Pulse.init(config, {
onPromptShown: (triggerId, signalId) => { /* FAB appeared */ },
onSurveyAccepted: (signalId) => { /* User accepted, browser opening */ },
onSurveyDeclined: (signalId) => { /* User declined */ },
onError: (code, message) => { /* Something went wrong */ },
});Theme Customization
Pulse.init({
partnerId: '...',
userId: '...',
theme: {
primary: '#6366F1',
onPrimary: '#FFFFFF',
background: '#1E1E2E',
borderRadius: 16,
},
});Peer Dependencies
| Package | Purpose |
|---|---|
| @react-native-async-storage/async-storage | Offline event queue persistence |
| @react-native-community/netinfo | Online/offline detection |
Requirements
- React Native 0.73+
- iOS 14+
- Android minSdk 24+
Troubleshooting
Widget not appearing
- Ensure
Pulse.init()completed without errors (debug: truelogs all activity). - Verify trigger rules are configured in the Pulse dashboard.
Events not reaching backend
- Enable
debug: trueand check console logs. - Verify
partnerIdis correct and the backend is reachable.
Browser not opening on accept
- Ensure your app can handle
Linking.openURL(). On Android, no extra config needed. On iOS, ensure URL schemes are not restricted.
