tester-analytics-sdk
v1.0.0
Published
Anonymous tester telemetry SDK for Expo and React Native apps, with offline queueing and self-hosted TesterFlow dashboards.
Maintainers
Readme
tester-analytics-sdk
Reusable anonymous tester analytics SDK for Expo / React Native Android apps.
Android App ──> tester-analytics-sdk ──> your dashboard (/api/events)The SDK reports directly to your own dashboard over HTTPS. No Firebase, no
Google Analytics, no PostHog/Mixpanel/Amplitude — no third-party analytics of
any kind except your own server (see hesab-ketab-dashboard/CONNECTING_APPS.md).
The SDK provides:
- Persistent anonymous Tester ID (UUID v4, stored in secure storage, survives app updates).
- Offline event queue (SQLite / in-memory fallback) with retry + backoff.
- Automatic tester/event registration after you create the app.
- Screen, session, and foreground/background tracking.
- Active-usage signals —
session_start/session_resume/session_pauseand a ~60ssession_heartbeatwhile foreground, so the server can measure per-tester per-day active minutes. - Crash / JS-error reporting.
- Expo Go compatible — no dev-client required.
The SDK core has zero dependencies — native modules are injected via thin
adapters (tester-analytics-sdk/expo).
Quickstart (Expo Go)
Works immediately on Android Expo Go with no dev-client build.
1. Install
cd your-app
npm i file:../tester-analytics-sdk
npx expo install expo-secure-store expo-constantsThis package is private and is installed from a local folder, so add a metro.config.js:
const { getDefaultConfig } = require('expo/metro-config');
const path = require('path');
const config = getDefaultConfig(__dirname);
const sdkDir = path.resolve(__dirname, '..', 'tester-analytics-sdk');
config.watchFolders = [...(config.watchFolders ?? []), sdkDir];
config.resolver.nodeModulesPaths = [
path.resolve(__dirname, 'node_modules'),
path.resolve(sdkDir, 'node_modules'),
];
module.exports = config;2. Add config to app.json
{
"expo": {
"extra": {
"testerAnalytics": {
"appId": "my-cool-app",
"apiUrl": "https://saraayab.shop",
"apiKey": "hk_your_key_here"
}
}
}
}3. Initialize (one line)
import { initializeExpoTesterAnalytics } from 'tester-analytics-sdk/expo';
export const tester = initializeExpoTesterAnalytics();appId, apiUrl, and apiKey are read from app.json automatically. Create the
app in the Developer portal first so it has an appId and API key. If apiUrl is
empty/unset the SDK stays dormant and sends nothing anywhere.
4. Wire it in
import './src/tester'; // entry file — boots ID + session// inside NavigationContainer
onReady={() => tester.setScreen(route.name)}
onStateChange={() => {
const r = navigationRef.current?.getCurrentRoute();
if (r?.name) tester.setScreen(r.name);
}}5. Run
npx expo start # opens in Expo GoManual init (no manifest auto-config)
If you prefer explicit options or don't use expo-constants, use the core
initializeTesterAnalytics directly:
import * as SecureStore from 'expo-secure-store';
import { AppState } from 'react-native';
import { initializeTesterAnalytics } from 'tester-analytics-sdk';
import { secureStoreStorage } from 'tester-analytics-sdk/expo';
export const tester = initializeTesterAnalytics({
appId: 'my-app',
dashboard: {
endpoint: 'https://saraayab.shop',
apiKey: 'hk_your_key_here',
appVersion: '1.0.0',
},
storage: secureStoreStorage(SecureStore),
appState: AppState,
});AppBackend API
| Method | Description |
| --- | --- |
| getTesterId() | Persistent anonymous UUID. |
| setScreen(name, screenClass?) | Queue a screen_view. |
| trackEvent(name, params?) | Queue a custom event (reaches /api/events as params). |
| setContactName(name) / getContactName() | Opt-in contact name (shown to you in the dashboard only). |
| setContactChannel(type, value) / getContactChannel() | Opt-in contact channel (telegram/whatsapp/email). |
| setOptedOut(true) / getOptedOut() | Stop sending telemetry. When opted out the SDK sends nothing. |
| markForeground(version?) | App active state: resume/boot a session. |
| markBackground() | Pause the session (background/close). |
| reportBug(message, options?) | Queue a bug_report event with steps/screen/screenshot/params. |
| reportCrash(message, stack?) | Queue a crash event. |
| flush() | Force-flush the local event queue now. |
| eraseMyData() | Clear the local Tester ID + queue, then call the dashboard /api/tester/erase for the old ID. |
Adapter factories (tester-analytics-sdk/expo)
secureStoreStorage(expoSecureStore)—StorageAdapter.expoDefaults()— creates storage + AppState from Expo modules.readTesterAnalyticsConfig()— readsapp.json extra.testerAnalytics.initializeExpoTesterAnalytics(options?)— recommended one-liner.
Session / active-usage model
- Boot sends
session_start(orsession_resumeif a session was left open by a previous force-close/crash — stored underSESSION_ACTIVE_KEY). - Every ~60s while foreground the SDK sends
session_heartbeat. - Backgrounding or app-close sends
session_pause. - The server measures active time from its own clock between those signals, excludes background time, splits per-day totals, and auto-closes stale sessions (force-close/no network). See the dashboard README for full details.
Privacy / GDPR
- Tester ID is a random UUID v4 — no PII.
- Contact name/channel are opt-in only.
- Opt-out stops all telemetry;
eraseMyData()deletes local data and the tester's dashboard record (activity + usage).
Reinstall limitation
The Tester ID lives in secure storage. Uninstalling/reinstalling (or clearing app data) generates a brand-new ID, so analyses keyed on the user ID cannot follow a device across reinstalls. This is an intentional privacy trade-off (no account, no server-side identity).
