0.3.2 • Published 6 years ago
ndla-error-reporter v0.3.2
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
import ErrorReporter from 'ndla-error-reporter');
const reduxStore = configureStore();
window.errorReporter = ErrorReporter.getInstance({ logglyApiKey: 'xxx', store: reduxStore, environment: 'test', componentName: 'ndla-frontend' });
ReactDOM.render(
<Provider store={store} locale={locale}>
...
</Provider>,
document.getElementById('app-container')
);
ErrorReporter is a singleton:
// After initial instantiation
import ErrorReporter from 'ndla-error-reporter');
ErrorReporter.getInstance().captureMessage('Testing');
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.captureError(e, {url: 'http://example.com'});
}
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.captureMessage('Testing');
Parameters:
Name | Type | Description |
---|---|---|
msg | String | Required. The message you want to send to Loggly. |
ErrorReporter.refresh()
Reset remaining messages to 10.
errorReporter.refresh();
0.3.2
6 years ago
0.3.1
6 years ago
0.3.0
6 years ago
0.2.0
6 years ago
0.1.17
6 years ago
0.1.16
6 years ago
0.1.15
6 years ago
0.1.14
6 years ago
0.1.13
7 years ago
0.1.12
7 years ago
0.1.11
7 years ago
0.1.9
7 years ago
0.1.8
7 years ago
0.1.7-0
7 years ago
0.1.6
7 years ago
0.1.5
7 years ago
0.1.4
7 years ago
0.1.3
7 years ago
0.1.2
7 years ago
0.1.1
7 years ago
0.1.0
7 years ago