Privacy-first analytics for React Native
Two calls add analytics to a React Native app: configure once, then track events. No IDFA, no Advertising ID, no device fingerprints. Works with Expo and bare React Native.
Free for one app and 20,000 events a month, no card needed. Source on GitHub
import Respectlytics from 'respectlytics-react-native';
// 1. Configure once at app startup
Respectlytics.configure('your-api-key');
// 2. Track events anywhere
Respectlytics.track('purchase_completed');
Install
Add the package and NetInfo with npm or Yarn, then install the iOS pods. Android needs nothing more: autolinking handles it.
npm install respectlytics-react-native @react-native-community/netinfo
yarn add respectlytics-react-native @react-native-community/netinfo
cd ios && pod install
With Expo, you may need to run expo prebuild so the NetInfo native module is installed.
Configure once, track anywhere
Call configure() once when the app starts, then track() wherever something happens.
import React, { useEffect } from 'react';
import { View, Button, StyleSheet } from 'react-native';
import Respectlytics from 'respectlytics-react-native';
export default function App() {
useEffect(() => {
Respectlytics.configure('your-api-key');
}, []);
return (
<View style={styles.container}>
<Button
title="Sign Up"
onPress={() => Respectlytics.track('signup_started')}
/>
<Button
title="Purchase"
onPress={() => Respectlytics.track('purchase_completed')}
/>
</View>
);
}
const styles = StyleSheet.create({
container: { flex: 1, justifyContent: 'center', alignItems: 'center', gap: 16 },
});
Hosting the server yourself? Pass its address to configure(). The open source edition runs the same server.
Respectlytics.configure('your-api-key', {
apiEndpoint: 'https://analytics.example.com/api/v1/events/',
});
The whole API
Three methods. An event carries its name, and on a paid plan the properties you declared.
configure(apiKey: string, options?)- Starts the SDK. Call it once when the app starts.
track(eventName, properties?)- Records an event. On a paid plan it may carry properties you declared in the app's Settings, such as an A/B test variant:
Respectlytics.track('paywall_viewed', { paywall: 'b' }). Anything undeclared is dropped. flush(): Promise<void>- Sends queued events now. Rarely needed: the SDK sends every 30 seconds or when 10 events are queued, and as soon as the device is back online.
What leaves the app
Five fields per event and only the properties you declare, the same in every SDK. The API refuses unknown fields.
Stored for each event
event_name- the name you pass to track()
timestamp- when it happened
session_id- random, kept in memory, replaced every two hours and on each launch
platform- the operating system
country- looked up on the server from the IP address, which is then discarded
Never collected
- the IDFA, the Advertising ID or any other device identifier
- a fingerprint of the device
- user IDs, names or emails
- free-text properties on events (why)
- anything written to the device
Filling in the App Store privacy label and the Google Play Data Safety form? The privacy disclosure guide walks through each question for the data Respectlytics handles.
Coming from Firebase Analytics
The calls map one to one. The parameters and the user IDs go away.
Replace each analytics().logEvent() with Respectlytics.track() and drop its parameters. Remove setUserId() and setUserProperty() calls: Respectlytics has no user IDs and no user properties.
Questions developers ask
What the SDK does, and what it leaves out on purpose.
Does the SDK read the IDFA or the Advertising ID?
No. It never reads the IDFA, the Android Advertising ID or any other device identifier, and it does not fingerprint the device. The only ID is a random session ID kept in memory, replaced every two hours and on each launch.
Does it work with Expo?
Yes, with the managed workflow and with bare React Native. In a managed Expo project you may need to run expo prebuild so the NetInfo native module is installed.
Does it work offline?
Events wait in memory and are sent in batches of up to 10 or every 30 seconds. Offline, they stay in memory until NetInfo reports a connection. Nothing is written to the device, so events not yet sent are lost if the app is force-quit or crashes.
What are the peer dependencies?
Only @react-native-community/netinfo, which the SDK uses to know when the device is back online. AsyncStorage is not needed since version 3.0.0, because the queue lives in memory.
Why can't I attach any property I like to an event?
Because properties are where personal data slips into analytics: an email in a parameter, a name in a label. The API refuses unknown fields, and keeps a property only when it was declared for your app, with a value declared for it, on a paid plan, so free text cannot get in by accident. On the free plan, put the detail you need in the event name instead, such as premium_plan_selected.
Other SDKs
The same five fields, the same declared properties and the same three calls in each.
What sets the SDK apart
The choices behind it, and what each one means for your app.
What to track
Event plans for common funnels, with the calls in each SDK.
Try it on your own app
Free for one app and 20,000 events a month, no card needed. Unlimited apps on every paid plan.