Référence API SDK
Référence complète des méthodes exposées par @pionne/react-native v0.3.0+.
Pionne.init(options)
Section intitulée « Pionne.init(options) »Initialise le SDK. À appeler une seule fois, au démarrage de l’app.
import { Pionne } from '@pionne/react-native';
Pionne.init({ token: 'pio_live_...', release: '1.0.0', environment: 'production', tags: { tier: 'pro' }, sampleRate: 1, scrubPii: true, captureScreenshot: false, breadcrumbs: true,});PionneOptions
Section intitulée « PionneOptions »| Champ | Type | Default | Description |
|---|---|---|---|
token | string | — | Requis. Token projet pio_live_... |
release | string? | auto | Version release, par défaut récupère expo-application |
environment | string? | 'production' | production, development, staging… |
tags | Record<string, string | number | boolean>? | {} | Tags ajoutés à chaque event |
sampleRate | number? | 1 | Entre 0 et 1, fraction d’events envoyés |
scrubPii | boolean | Array<{re: RegExp, replace: string}>? | true | Voir PII |
captureScreenshot | boolean? | false | Voir Screenshots |
screenshotQuality | number? | 0.5 | JPG quality 0..1 |
breadcrumbs | boolean | { console?: boolean; fetch?: boolean }? | true | Voir Breadcrumbs |
beforeSend | (event) => event | null | — | Hook de filtre/transformation |
enabled | boolean? | true | Désactive complètement l’envoi si false |
apiUrl | string? | 'https://api.pionne.app' | Override pour self-host |
Pionne.captureException(err, extra?)
Section intitulée « Pionne.captureException(err, extra?) »Capture une erreur explicitement. Retourne void.
try { await fetchUser();} catch (err) { Pionne.captureException(err, { userId: 42, screen: 'Profile' });}Pionne.captureMessage(msg, extra?)
Section intitulée « Pionne.captureMessage(msg, extra?) »Envoie un event level: 'info' (ou personnalisable via extra.level).
Pionne.captureMessage('Cart abandoned', { items: 3, level: 'warning' });Pionne.setUser(idAnon)
Section intitulée « Pionne.setUser(idAnon) »Associe un identifiant anonyme à tous les events suivants. N’envoie jamais d’email/nom.
Pionne.setUser('user_a8f2c1');Pour reset : Pionne.setUser(null).
Pionne.setTags(tags)
Section intitulée « Pionne.setTags(tags) »Merge des tags globaux.
Pionne.setTags({ ab_test: 'variant_b', plan: 'pro' });Pionne.setEnabled(bool)
Section intitulée « Pionne.setEnabled(bool) »Active/désactive l’envoi à chaud (utile pour un consent banner RGPD).
Pionne.setEnabled(false); // plus aucun event envoyéPionne.addBreadcrumb(crumb)
Section intitulée « Pionne.addBreadcrumb(crumb) »Ajoute un breadcrumb manuel. Voir Breadcrumbs.
Pionne.addBreadcrumb({ category: 'navigation', message: 'Navigated to Checkout', data: { from: 'Cart' },});Pionne.wrap(fn, tags?)
Section intitulée « Pionne.wrap(fn, tags?) »Wrappe une fonction (sync ou async) avec un try/catch. L’erreur est capturée puis re-throw.
const safeSubmit = Pionne.wrap(async (form) => { await api.submit(form);}, { feature: 'checkout' });Pionne.setRootRef(ref)
Section intitulée « Pionne.setRootRef(ref) »Définit la ref racine pour la capture d’écran.
const rootRef = useRef(null);useEffect(() => Pionne.setRootRef(rootRef), []);
return <View ref={rootRef} style={{ flex: 1 }}>...</View>;<PionneErrorBoundary>
Section intitulée « <PionneErrorBoundary> »Composant React Error Boundary. Voir Error Boundary.
Type PionneEvent
Section intitulée « Type PionneEvent »Forme du payload envoyé à /api/ingest (résumé) :
type PionneEvent = { exception_type: string; message: string; stack: string | null; level: 'fatal' | 'error' | 'warning' | 'info'; release?: string; environment?: string; tags?: Record<string, unknown>; user?: { id?: string }; contexts?: { device?: object; app?: object; os?: object }; mechanism?: { type: string; handled: boolean }; breadcrumbs?: Array<{ category: string; message: string; ts: number; data?: object }>; screenshot?: string; // base64 JPG extra?: Record<string, unknown>;};