react-native-puree
A log collector for React Native.
Features:
- Buffering: Store logs to AsyncStorage and send them later
- Batching: Send logs in a single request
- Retrying: Retry to send logs after backoff time if sending logs fails
{ return Math} const puree = puree; puree puree pureestart // send logpuree
Usage
Configure
const puree = flushInterval: 2 * 60 * 1000 // the interval to flush logs in milli second maxRetry: 5 // try to send logs until max retry count firstRetryInterval: 1 * 1000 // the interval between the fail to send logs and the first retry
Record logs
puree
A log is stored into persistent storage ( AsyncStorage ) after applying filters to it.
Flush logs
You can automatically send logs every interval with puree.start()
.
pureestart
or manually:
puree
Recipe
Flush logs on resume
Use AppState
and puree.flush()
.
See also: https://facebook.github.io/react-native/docs/appstate.html
Component { superprops; thisstate = appState: AppStatecurrentState ; } { AppState; } { AppState; } { puree; } // https://facebook.github.io/react-native/docs/appstate.html { if thisstateappState && nextAppState === 'active' this; this; } { return <App/> ; }
Link
License
MIT