Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ndla/error-reporter

Package Overview
Dependencies
Maintainers
0
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ndla/error-reporter

Error reporter for NDLA. Listens to window.onerror and sends client errors to Loggly.

  • 2.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

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

yarn add @ndla/error-reporter
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();

Keywords

FAQs

Package last updated on 17 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc