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

@snapshot-labs/snapshot-sentry

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@snapshot-labs/snapshot-sentry

`snapshot-sentry` is an npm package that contains the Sentry setup files and configurations for Snapshot backend projects. It simplifies the process of setting up Sentry for error tracking in any Snapshot service.

  • 1.5.1
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

Snapshot-sentry

snapshot-sentry is an npm package that contains the Sentry setup files and configurations for Snapshot backend projects. It simplifies the process of setting up Sentry for error tracking in any Snapshot service.

Install

yarn add @snapshot-labs/snapshot-sentry

Configure

Set the following env variables:

  • SENTRY_DSN (required)
  • SENTRY_TRACE_SAMPLE_RATE (Optional, default to 0.01)

Usage

Instantiate

For express

Import the library in your root file

import { initLogger, fallbackLogger } from '@snapshot-labs/snapshot-sentry'

Init sentry just after creating your express instance, before any middleware

const app = express();
initLogger(app);

Set the fallthrough error handler after all controllers, but before any other error middleware

fallbackLogger(app);

Note: If you have a catch-all route, set fallbackLogger() before it.

All uncaught errors, with code >= 500, will be handled automatically by Sentry. See Capture exception for how to handle caught exceptions.

For vanilla js

Import the library in your root file

import { initLogger } from '@snapshot-labs/snapshot-sentry'

Init sentry, as soon as possible to catch all errors.

initLogger()

See Capture exception for how to handle exceptions.

Capture exception

To capture an exception, use the capture function:

import { capture } from '@snapshot-labs/snapshot-sentry'

try { 
  throw new Error('Ooops, someting went wrong');
} catch (e: any) {
  // Send the error to sentry
  capture(e)
}

You can also pass additional context data to the capture function:

import { capture } from '@snapshot-labs/snapshot-sentry'

let url = '';
try { 
  url = getUrlFromSomewhere('argOne')
  throw new Error('Ooops, someting went wrong');
} catch (e: any) {
  // Send the error to sentry
  capture(e, { contexts: { input: { url: url } } })
}

When sentry is disabled, the capture function will fallback to a simple console.log, so no code change will be required when toggling this library on/off.

More info

License

Snapshot-sentry is open-sourced software licensed under the © MIT license.

FAQs

Package last updated on 26 Sep 2023

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