Follow the Quickstart to install the SDK and verify your first event. This page covers what comes after: development builds, how tracking works, and the SDK calls you can make.
You usually don't want your own development sessions mixed into your production analytics.
Vexo only starts when you call vexo(...), and nothing is sent before that, so the
recommended way to disable it is to simply make the call conditional:
import { vexo } from 'vexo-analytics';
if (!__DEV__) {
vexo('YOUR_API_KEY');
}
Add the guard after you've seen your first event: a development build with the guard sends nothing.
A few things you can rely on when Vexo has not been initialized:
vexo() is a fully supported way to disable Vexo. There is no background work,
and no data leaves the device.customEvent() calls are safe: the event is queued on the device (in memory, and saved to
storage) and sent only after vexo() is called, in this launch or a later one. If vexo() is
never called, nothing is sent. You don't need to guard every call site.identifyDevice(), enableTracking() and disableTracking() are safe no-ops as well.If you'd rather keep development or staging data instead of dropping it, create a separate app in your dashboard (for example "MyApp — Staging") and pick the API key by environment:
vexo(__DEV__ ? 'STAGING_API_KEY' : 'PRODUCTION_API_KEY');
One line of code? How is this possible?
It's very simple! Vexo is a very lightweight advanced piece of technology that listens to React Native events, such as AppState changes,
packs the data into a buffer and sends it to our servers.
Given that it works in background with your app, there are no code dependencies and it's effortless to integrate!
Events are batched before they leave the device: the SDK sends a group as soon as it has 20 events, or 5 seconds after the first event was queued — whichever comes first. This keeps network and battery usage low without you having to think about it.
Supported events are:
Every one of these — taps, screen changes, requests, errors and your custom events — counts toward your account's monthly event total. See Subscription for the 500,000 events per month free allowance and the pay-as-you-go rates beyond it.
As well as being seamless, privacy is a key focus. We don't store any PII from your devices or users, so we provide a way in which you can identify a user in order to be able to navigate through your dashboards in a personalized way. To achieve this, do the following:
import { Button } from 'react-native';
import { identifyDevice } from 'vexo-analytics';
export function LoginButton({ userId }) {
const onLogin = async () => {
// ...sign the user in, then:
await identifyDevice(userId);
};
return <Button title="Log in" onPress={onLogin} />;
}
It's important to note that the identifier is a string and can be anything you want. We recommend that you identify your device with a token/hash that you can then map it into your users' data to be able to know which user is it. As an example, in SQL a unique ID as a foreign key to your users' table should suffice.
In case you want to make the device anonymous, identifyDevice supports null like in the following example:
import { Button } from 'react-native';
import { identifyDevice } from 'vexo-analytics';
export function LogoutButton() {
const onLogout = async () => {
// ...sign the user out, then:
await identifyDevice(null);
};
return <Button title="Log out" onPress={onLogout} />;
}
You can programmatically enable or disable tracking in your app based on your business logic and requirements. This gives you full control over when analytics data is sent.
import { enableTracking, disableTracking } from 'vexo-analytics';
export async function setTracking(enabled) {
if (enabled) {
await enableTracking();
} else {
await disableTracking();
}
}
Errors that reach the top of your app are captured automatically. To report a caught exception yourself — without crashing the app — call trackError:
import { trackError } from 'vexo-analytics';
export async function loadData() {
try {
await riskyOperation(); // your code
} catch (err) {
trackError(err);
}
}
By default the error is recorded as handled, so it does not count against your crash-free rate. To record it as an unhandled error instead, pass { handled: false } in the catch block:
trackError(err, { handled: false });
This is where the power of out of the box analytics meets the custom needs of your business. You'll be able to send custom events specific to you application's needs, and that data will be enriched with the context data that we provide:
import { Button } from 'react-native';
import { customEvent } from 'vexo-analytics';
export function SubscribeButton({ subscriptionType, amount, description }) {
const onPurchase = () => {
// ...complete the purchase, then:
customEvent(`sale-${subscriptionType}`, { amount, description });
};
return <Button title="Subscribe" onPress={onPurchase} />;
}
We will understand the context about the event that has just happened and infer multiple axis of data, such as:
For further understanding on custom events check out the docs
Work through No events? in the Quickstart.
vexo-analytics 1.12.x and earlier record nothing on Expo SDK 58, with no error in production. Upgrade to 1.14.0 or later and follow Upgrading to Expo SDK 58. If routes still don't arrive, use the explicit setup with <VexoProvider navigationRef> described there.
Some apps saw a brief scroll stutter the first time a list is scrolled after the app comes back from the background to the foreground. This is fixed in vexo-analytics 1.8.0 and later, so upgrading the SDK resolves it for most apps.
If you still see it and don't need session replay, turn replay off on the device with the sessionReplay option (vexo-analytics 1.10.0 and later). All other tracking keeps working:
vexo('YOUR_API_KEY', { sessionReplay: false });
To keep replay but record fewer sessions, pass sessionReplaySampleRate instead, for example { sessionReplaySampleRate: 0.1 } to record about 10% of sessions (1.11.0 and later). You can also turn replay off for the app from your dashboard tracking settings.