Skip to the page

Developer GuideMobile apps

React Native SDK

Add venbit.js to an Expo or bare React Native app, call Venbit.start once at launch, and report sign-ups and purchases. Every function, with examples.


The React Native SDK is a single file, venbit.js, with no dependencies of its own. Drop it into your project, import it, and call Venbit.start once at launch. From then on the app reports its install on iOS and Android, a daily "opened today" note, and whatever events you send.

JavaScript
import { Venbit } from "./venbit";

Venbit.start({ appKey: "vba_YOUR_APP_KEY" });

Your real key is on the app's Install tab in the dashboard, under React Native. If you haven't added the app yet, see App tracking overview.

Add the file

  1. Download venbit.js, or use Download venbit.js on the Install tab.
  2. Put it in your project, for example at src/venbit.js.
  3. Import it where your app starts.

You won't find an npm package, and there's nothing to link. The file imports react-native itself and nothing else.

TypeScript projects need "allowJs": true in tsconfig.json to import a .js file. If TypeScript complains it can't find a declaration for ./venbit, that setting fixes it.

Optional packages it uses if you have them

None of these is required. The file looks for packages your project may already have and uses the first one it finds.

ForIt tries, in orderWithout any of them
Keeping the install idexpo-secure-store, then react-native-keychain, then @react-native-async-storage/async-storageThe id lives in memory, and every app start looks like a new install. Install one of the three.
The bundle idexpo-constants, then react-native-device-infoThe bundle id isn't sent, and Venbit can't find your store listing from the app on its own.
The app versionexpo-constantsThe version is sent empty, so the dashboard has no version adoption figures.

How well a reinstall is recognised depends on which storage you have. On iOS, expo-secure-store and react-native-keychain keep the id in the keychain, and that survives a delete and reinstall. AsyncStorage gets wiped with the app, so someone who reinstalls counts as a new install.

Where the install id is kept. The file uses the first package it finds

In an Expo app, installing expo-secure-store and expo-constants covers all three:

Terminal
npx expo install expo-secure-store expo-constants

Call start at launch

Call it once, at module load, before the first screen renders. A complete App.tsx looks like this:

TypeScript
import React from "react";
import { SafeAreaView, Text } from "react-native";
import { Venbit } from "./venbit";

Venbit.start({ appKey: "vba_YOUR_APP_KEY" });

export default function App() {
  return (
    <SafeAreaView>
      <Text>Harbor Roofing</Text>
    </SafeAreaView>
  );
}

Keeping the call outside the component stops it running again on every render. It's safe to call on every launch, because once the install has been reported it won't be reported again. Don't bother putting the key in an environment variable or a secret store. All it does is name which app is reporting, and it's meant to ship inside the app.

For a coding agent working in your React Native project:

Add Venbit install tracking to this React Native app. Download https://venbit.com/sdk/venbit.js to src/venbit.js (there is no npm package). In the entry file, at module load outside any component, call Venbit.start({ appKey: "[your vba_ key]" }). If this is Expo, run npx expo install expo-secure-store expo-constants. Call Venbit.event("signup") right after an account is created, and Venbit.event("purchase", { valueCents, currency, meta: { txn } }) where a purchase completes. In TypeScript, set "allowJs": true.

Venbit.start

JavaScript
Venbit.start({ appKey, endpoint, onAttribution, sandbox })
OptionDefaultWhat it does
appKeyrequiredYour app key, starting vba_. Without it, start does nothing.
endpoint"https://venbit.com"Where reports are sent. Leave the default.
onAttributionnoneCalled once, after the first launch has been reported, with { campaign, confidence, deepLink }.
sandboxfalsePass true to mark this build as a test build. See below.

You get back a promise, though you don't need to await it. On the launch that reports the install it resolves to Venbit's answer. Every other launch, or a report that couldn't be delivered, resolves to null.

Open a screen after install

Smart links can name a screen inside your app (the Opens field when you make the link), and onAttribution hands it to you on first launch.

JavaScript
import { Linking } from "react-native";
import { Venbit } from "./venbit";

Venbit.start({
  appKey: "vba_YOUR_APP_KEY",
  onAttribution: ({ campaign, deepLink }) => {
    // deepLink is the Opens value, e.g. "/estimates/new"
    if (deepLink) Linking.openURL("harborroofing:/" + deepLink);
  },
});

This assumes the app has registered the harborroofing URL scheme. If you use a navigation library, call its navigate there instead.

FieldMeaning
campaignThe name of the smart link that was tapped, or null.
deepLinkThe screen that link asked to open, or null.
confidence"high", "likely" or "none". "none" means the install wasn't matched to a link.

Mark test builds

Development builds (Metro, __DEV__) mark themselves as test launches. TestFlight is harder: it's a release bundle, so the file can't tell it apart from a store build. To keep testers out of the real numbers, pass sandbox: true from your own check.

JavaScript
Venbit.start({
  appKey: "vba_YOUR_APP_KEY",
  sandbox: process.env.EXPO_PUBLIC_BUILD === "beta",
});

Set that variable in whichever build profile you use for betas. Any boolean of your own works.

Venbit.event

JavaScript
Venbit.event(kind, { valueCents, currency, meta })

Call it when something worth counting happens. Keep names short and lower_snake_case, and stick to things your app really has. The promise it returns doesn't need awaiting.

JavaScript
// Right after an account is created. Not on sign-in.
Venbit.event("signup");

// When a free trial begins
Venbit.event("trial_started");

The dashboard builds its sign-up count from signup, so put the call on the line after the account exists.

In React Native, purchases need a call from you, placed where the purchase completes. valueCents is the price times 100, so $49.99 is 4999.

JavaScript
Venbit.event("purchase", {
  valueCents: 4999,
  currency: "USD",
  meta: { txn: transaction.transactionId, product: "pro_yearly" },
});

Include the store's transaction id as meta.txn. With it, Venbit can refuse the same purchase arriving twice while leaving a real repeat purchase alone. For later charges on a subscription use renewal, and for money returned use refund with a negative valueCents. The Swift SDK sends the same names.

Events sent before Venbit.start has run in this launch get dropped, so call start first.

Venbit.installId

JavaScript
const id = await Venbit.installId();

This returns a promise of the random id the install reports under. It's handy for lining Venbit's numbers up with your own records.

What is sent and when

Every request is an HTTPS POST to https://venbit.com with a 10 second timeout. Failed requests aren't queued. Instead, the install report and the daily note get tried again the next time the app opens or comes to the foreground.

WhenWhat is sent
First launch after install, onceApp key, the random install id, device model, OS version, bundle id, platform (ios or android).
At most once a day, on launch or on returning to the foregroundApp key, install id, app version, OS version. Days are UTC.
Each Venbit.event callApp key, install id, the event name, a random event id, and the amount, currency and meta you passed.

The SDK never sends the advertising identifier, the vendor identifier, a name, an email address, contacts, location, or anything about other apps. You don't need a permission prompt, and nothing here calls for App Tracking Transparency.

Differences from the Swift SDK

SwiftReact Native
PlatformsiOSiOS and Android
PurchasesReported for you from StoreKitYou call Venbit.event("purchase", ...)
TestFlight buildsDetectedNot detected. Pass sandbox: true.
Install id storageAlways the keychainWhichever store your project has
Reset for testingVenbit.resetForTesting()None. Clear the app's stored data, or the keychain entry, by hand.
installIdA propertyA function that returns a promise
startReturns nothingReturns a promise

You can put Venbit.swift in the iOS project of a React Native app, and it'll report StoreKit purchases on iOS by itself. Before you run both, though, know that each file makes and keeps its own install id. Call start from JavaScript and from native code and every iPhone shows up as two installs. So start only one of them on iOS. If that's the Swift file, guard the JavaScript call with Platform.OS === "android". See the Swift SDK.

Test your integration

  1. Run the app with Venbit.start in place.
  2. Open the app's Overview in the dashboard. Within about a minute, Waiting for the first report gives way to the app's numbers.
  3. To run the first-launch path again, uninstall the app and, if the id is in the iOS keychain, erase the simulator or remove the stored entry.

Common questions

Does Venbit work with Expo?

Yes. The React Native SDK is a single file, venbit.js, and there's no native code to link. Install expo-secure-store and expo-constants and it keeps the install id in the keychain on iOS and sends the bundle id and app version.

Why does every app start count as a new install in Venbit?

It means the file couldn't find expo-secure-store, react-native-keychain or @react-native-async-storage/async-storage, so the install id only lives in memory. Install one of the three.

Can I use the Venbit Swift SDK and React Native SDK in the same app?

Yes, but start only one of them on iOS. Each file keeps its own install id, so starting both reports every iPhone twice. If you start the Swift file on iOS, guard the JavaScript call with Platform.OS === "android".

Does the Venbit React Native SDK report purchases automatically?

No. In React Native you call Venbit.event("purchase", ...) where a purchase completes, with the store's transaction id as meta.txn. Only the Swift SDK reports StoreKit purchases by itself.

Last updated . Something wrong or missing on this page? Tell us from Settings, then Support.