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

@exceptionless/react

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@exceptionless/react

JavaScript client for Exceptionless

  • 3.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
121
increased by195.12%
Maintainers
1
Weekly downloads
 
Created
Source

Exceptionless React

The Exceptionless React package provides a native way to handle errors and events in React. This means errors inside your components, which tend to crash your entire app, can be sent to Exceptionless and you can be alerted. Additionally, you can use this package to catch errors throughout your non-component functions such as in Redux actions, utility functions, etc.

Getting Started

To use this package, your must be using ES6 and support ESM modules.

Install

npm install @exceptionless/react --save

Configuration

While your app is starting up, you should call startup on the Exceptionless client. This ensures the client is configured and automatic capturing of unhandled errors occurs.

import { Exceptionless, ExceptionlessErrorBoundary } from "@exceptionless/react";

class App extends Component {
  async componentDidMount() {
    await Exceptionless.startup((c) => {
      c.apiKey = "API_KEY_HERE";
      c.setUserIdentity("12345678", "Blake");

      c.defaultTags.push("Example", "React");
    });
  }

  render() {
    return (
      <ExceptionlessErrorBoundary>
        <div>// YOUR APP COMPONENTS HERE</div>
      </ExceptionlessErrorBoundary>
    );
  }
}

export default App;

Handling Events

While errors within the components themselves are automatically sent to Exceptionless, you will still want to handle events that happen outside the components.

Because the Exceptionless client is a singleton, it is available anywhere in your app where you import it. Here's an example from a file we'll call utilities.js.

export const myUtilityFunction = async () => {
  try {
    //  Handle successful run of code
  } catch (e) {
    //  If there's an error, send it to Exceptionless
    await Exceptionless.submitException(e);
  }
};

You can also sent events and logs that are not errors by simply calling the built-in methods on the Exceptionless class:

await Exceptionless.submitLog("Hello, world!");
await Exceptionless.submitFeatureUsage("New Shopping Cart Feature");

Please see the docs for more information on configuring the client.

Support

If you need help, please contact us via in-app support, open an issue or join our chat on Discord. We’re always here to help if you have any questions!

Keywords

FAQs

Package last updated on 29 Mar 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