ndla-error-reporter
Error reporter for NDLA. Listens to window.onerror and sends client errors to Loggly.
N.B. Number of messages is limited to 10 per session (reset by browser refresh).
Installation
$ npm install ndla-error-reporter
A polyfill for fetch is needed for cross-browser support.
Usage
; const reduxStore = ; windowerrorReporter = ErrorReporter; ReactDOM;
ErrorReporter is a singleton:
// After initial instantiation; ErrorReporter;
API(functions)
ErrorReporter.captureError(error, [additionalInfo])
Processes error and sends error info to Loggly with optional additional info.
try // some "dangerous" code catch e errorReporter;
Parameters:
Name | Type | Description |
---|---|---|
error |
Object |
Required. Error object to process and send to Loggy. |
additionalInfo |
Object |
Optional. Additional information you want to send to Loggly. |
ErrorReporter.captureMessage(msg)
Sends a text/message to Loggly with log level info
errorReporter;
Parameters:
Name | Type | Description |
---|---|---|
msg |
String |
Required. The message you want to send to Loggly. |
ErrorReporter.refresh()
Reset remaining messages to 10.
errorReporter;