@voidpulse/react-native
v2.2.0
Published
React Native (Expo) SDK for Voidpulse event ingest and experiment assignment.
Readme
@voidpulse/react-native
React Native (Expo) SDK for Voidpulse event ingest and experiment assignment.
Company setup (multi-project)
Each Voidpulse project has its own ingest API key. Ship one key per app/project (Dungeon prod, Dungeon sandbox, Garden, …). The wrong key loads another project's experiment config.
| Setting | Value |
| --------------- | ----------------------------------------------------------------------------------------- |
| hostUrl | API origin only: https://api.voidpulse.ai (prod) or http://localhost:4001 (local API) |
| apiKey | Project key from Voidpulse → Project settings (vp_…) |
| Config endpoint | GET {hostUrl}/experiments/config with header x-api-key: {apiKey} |
Do not pass the Voidpulse web origin, a trailing slash, or /trpc. The SDK normalizes those to the API origin.
import { Voidpulse } from "@voidpulse/react-native";
const voidpulse = new Voidpulse({
apiKey: DUNGEON_VOIDPULSE_API_KEY,
hostUrl: "https://api.voidpulse.ai",
skipInitialization: true, // common on Android; then call init()
experimentsEnabled: true,
});
await voidpulse.init();
// init() loads the disk cache then fetches /experiments/config once.
// Foreground AppState transitions force another ETag-cached check.
const variant = voidpulse.getExperimentVariant("checkout-redesign", {
fallbackVariant: "control",
});getExperimentVariant never performs network I/O. Call prefetchExperiments(true) before a render-sensitive flow when you need a forced refresh. Disable assignment with experimentsEnabled: false without turning off event tracking.
If you see silence
Misconfig fails soft. The SDK never crashes the host app, never rejects new Voidpulse(...) / init(), and never turns a bad key or URL into an uncaught throw. You get console.warn once per issue kind, plus an optional debugBeacon callback for structured events.
| Symptom / warn kind | What to fix |
| ------------------- | --------------------------------------------------------------------------------------------------------------------- |
| Missing apiKey | Pass the project key from Voidpulse → Project settings (vp_…). |
| Wrong hostUrl | Use https://api.voidpulse.ai (or local http://localhost:4001). Do not use the web app origin, /trpc, or a path. |
| CORS / fetch block | Rare on native. Still confirm hostUrl is the API origin and the device can reach it. |
| HTTP 401 | Wrong or rotated project key. |
| HTTP 413 | Batch too large. Flush more often or shrink event properties. |
| Network silence | No HTTP response. Check connectivity and hostUrl. Events requeue when possible. |
| Batch drop | Non-retryable HTTP error. That flush's events will not retry. |
const voidpulse = new Voidpulse({
apiKey: DUNGEON_VOIDPULSE_API_KEY,
hostUrl: "https://api.voidpulse.ai",
skipInitialization: true,
debugBeacon: (event) => {
// Optional: forward structured misconfig events to your own debug sink.
console.debug("voidpulse-debug", event);
},
});Recoverable errors
The SDK keeps its queues in memory, so a failed kv-store write or remove only costs persistence across a restart and never rejects or throws. Pass onError to see those failures, for example in Sentry:
const voidpulse = new Voidpulse({
apiKey: DUNGEON_VOIDPULSE_API_KEY,
hostUrl: "https://api.voidpulse.ai",
onError: (error, { operation, key }) => {
Sentry.captureException(error, { level: "warning", tags: { voidpulse_operation: operation, voidpulse_key: key } });
},
});onError must not throw; the SDK ignores errors from it.
Local verification
pnpm --filter @voidpulse/react-native test
pnpm --filter @voidpulse/react-native typecheck