Developers · React Native and Expo
React Native and Expo analytics, with an offline queue built in.
Count screens, events and signed-in users from your apps with the same SDK as your website. Nothing secret ships in the app, and what can’t be sent waits until it can.
import { createAppClient } from 'nahnu-analytics-sdk/app';
import { Platform } from 'react-native';
const app = createAppClient({
siteKey: SITE_KEY, // site.site_key
receiveUrl: RECEIVE_URL, // site.install.receive_url
domain: 'app.example.com', // one of the site's domains
platform: Platform.OS,
appVersion: '2.1.0',
});
app.screen('Home');
app.event('Purchase', { revenue: { amount: 12.5, currency: 'EUR' } });What it does
Your app, in the same dashboard.
Each screen counts as a page of the site, so the reports you know work for apps too.
Screens
app.screen() on each screen change, from React Navigation’s state listener.
Events
app.event() for purchases, signups and anything else, with revenue.
Signed-in users
app.identify() names your users by an id of your own.
Nothing secret
The site key and receive address are public. No API key ships in the app.
Offline
No signal? It waits in line.
What can’t be sent waits in order and goes out with the next screen, when the app comes back, or when you flush it.
- Pass AsyncStorage or MMKV to keep the queue across restarts
- Up to 200 items kept by default, the oldest go first
- pending() says how many wait; flush() sends them when NetInfo says you’re back
- Queued items count when they arrive
import AsyncStorage from '@react-native-async-storage/async-storage';
import { AppState } from 'react-native';
const app = createAppClient({ /* … */ storage: AsyncStorage });
AppState.addEventListener('change', (s) =>
s === 'active' ? app.resume() : app.pause(),
);Privacy
An opt-out switch in one line.
setEnabled(false) stops all sending, for the analytics switch in your app’s settings. Visits are counted the same way as on the web: no IP addresses stored.
- setEnabled(false) for an opt-out switch
- The same cookieless counting as your website
- The platform property separates iOS from Android
- Give each app its own site, or its own domain, to tell app and web apart
// The user turns analytics off in your settings
app.setEnabled(false);{"k":"<site key>","n":"v","u":"https://app.example.com/Home","r":"","w":390,"p":{"platform":"ios"}}Does it work with Expo?
Yes. The app client is plain TypeScript with fetch, so it runs in Expo and bare React Native.
Is my API key in the app?
No. The app uses the site key and receive address, which are public. Keep API keys on your server.
What about Swift or Kotlin?
POST JSON as text/plain to the receive address: one line for a screen, an event or leaving a screen.
Can I tell iOS from Android?
Yes. The platform property shows in Goals and events › Properties.
Do queued events keep their time?
They count when they arrive, not when they happened.
Your app and your website, in one dashboard.
Unlimited websites and apps, every feature, one license.