Skip to content

Auto-capture

As soon as you call Pionne.init(), the SDK installs three global mechanisms to catch what would normally fall through the cracks.

Pionne hooks into ErrorUtils.setGlobalHandler (standard React Native mechanism). Any exception that bubbles up to the render loop without being caught is captured with mechanism: { type: 'global', handled: false }.

// Captured automatically, no code required
function MyScreen() {
throw new Error('Boom');
}

On Hermes, Pionne enables HermesInternal.enablePromiseRejectionTracker:

// Both of these are captured
fetch('/x').then((r) => r.nopeNotAFunction());
(async () => {
throw new Error('async crash');
})();

Pionne wraps setTimeout, setInterval and requestAnimationFrame to catch exceptions that escape the callback:

setTimeout(() => {
throw new Error('Timer crash'); // captured with mechanism.type = 'timer'
}, 1000);
CaseBehavior
Dev RedBoxShown by RN, the event is also sent
HMR / Fast RefreshHandlers are preserved across reloads
Hermes in devPromise tracker active only after Pionne.init
Metro symbolicationReadable stacks in dev, see source maps for prod

The SDK sends everything by default, even in dev. If you only want prod:

Pionne.init({
token: '...',
enabled: !__DEV__, // no sending in dev
});
<Button title="Crash sync" onPress={() => { throw new Error('sync'); }} />
<Button title="Crash async" onPress={async () => { throw new Error('async'); }} />
<Button title="Crash timer" onPress={() => setTimeout(() => { throw new Error('timer'); }, 100)} />

All three should appear in the dashboard without any try/catch.