0.3.2 • Published 7 years ago

ndla-error-reporter v0.3.2

Weekly downloads
23
License
GPL-3.0
Repository
github
Last release
7 years ago

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:

NameTypeDescription
errorObjectRequired. Error object to process and send to Loggy.
additionalInfoObjectOptional. 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:

NameTypeDescription
msgStringRequired. The message you want to send to Loggly.

ErrorReporter.refresh()

Reset remaining messages to 10.

errorReporter.refresh();
0.3.2

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.17

7 years ago

0.1.16

8 years ago

0.1.15

8 years ago

0.1.14

8 years ago

0.1.13

8 years ago

0.1.12

8 years ago

0.1.11

8 years ago

0.1.9

8 years ago

0.1.8

8 years ago

0.1.7-0

8 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago