katyayani-core-react-native
v2.0.1
Published
Katyayani Core React Native SDK — event tracking, attribution (platform-wise revenue), deferred deep linking, and push notifications.
Maintainers
Readme
katyayani-core-react-native
Katyayani Core React Native SDK — event tracking, attribution (platform-wise revenue), deferred deep linking, and push notifications. Talks to the same Katyayani Core backend as the web and Flutter SDKs.
Install
npm install katyayani-core-react-native @react-native-async-storage/async-storage
# optional — only if you want push / install-referrer attribution
npm install @react-native-firebase/app @react-native-firebase/messaging react-native-play-install-referrer
cd ios && pod install # iOS
@react-native-async-storage/async-storageis recommended so identity/events persist across launches. Without it the SDK falls back to in-memory (non-persistent).
Initialize (App.tsx)
import { KatyayaniCore } from 'katyayani-core-react-native';
await KatyayaniCore.init({
siteId: 'nc_live_YOUR_KEY', // Dashboard → Settings → App Management
apiBase: 'https://8.231.80.238.nip.io',
enablePush: true, // optional
debug: __DEV__,
});Identify
await KatyayaniCore.identify('user_123', { name: 'Rahul', email: '[email protected]', phone: '+9198...' });
KatyayaniCore.reset(); // on logoutTrack events
KatyayaniCore.track('product_viewed', { productId: 'SKU-001', price: 499 });
KatyayaniCore.screen('ProductDetail', { productId: 'SKU-001' });Revenue + attribution
// on a successful payment — attributes revenue to the acquiring source
await KatyayaniCore.capturePayment(1499, { orderId: 'ORD-1', currency: 'INR' });Deferred deep linking
After an install via a Smart Link, route the user to the campaign's target page:
KatyayaniCore.onDeferredDeepLink((route, attribution) => {
navigation.navigate(route); // e.g. "/cart"
console.log('came from', attribution.source);
});Push notifications
Requires @react-native-firebase/messaging configured for your app.
import { KCPush } from 'katyayani-core-react-native';
await KCPush.requestPermission(); // asks + registers FCM token
KCPush.onNotificationOpened((data) => { /* navigate using data.actionUrl */ });
KCPush.onMessage((msg) => { /* foreground message */ });API
| Method | Purpose |
|---|---|
| KatyayaniCore.init(config) | Start the SDK |
| KatyayaniCore.identify(userId, traits?) | Identify the user |
| KatyayaniCore.reset() | Clear identity (logout) |
| KatyayaniCore.track(event, props?) | Track a custom event |
| KatyayaniCore.screen(name, props?) | Track a screen view |
| KatyayaniCore.capturePayment(amount, { orderId?, currency?, properties? }) | Revenue + attribution |
| KatyayaniCore.trackAttribution(type, props?) | Funnel event (e.g. signup) |
| KatyayaniCore.onDeferredDeepLink(cb) | Deferred deep link after install |
| KatyayaniCore.flush() | Force-send queued events |
| KCPush.requestPermission() | Push permission + token register |
| KCPush.onNotificationOpened(cb) | Notification tap handler |
