@leagueutil/sentry-error-logger

1.0.5 • Public • Published

Node package to initialize Sentry and send error events with user and environment breadcrumbs.

  • This package is designed to Initialize Sentry and send an error event to Sentry that contains all the expected user and environment breadcrumbs
  • To Send an error event to Sentry the caller has two options:
    • logExceptionWithConfig - takes a configuration object and uses it to build Sentry attributes for the event.
    • logExceptionWithSentryData - takes custom prebuilt Sentry attributes { sentryDsn, sentryEnv, fingerPrint, tags } and uses for the event. See the definition of logExceptionWithConfig and logExceptionWithSentryData for more details.

/**

  • logExceptionWithConfig captures an error/exception and forwards it to Sentry as an event.
  • This function takes a configuration object and uses it to build Sentry attributes
  • See the implementation of buildLogData for more context.
  • Note: if you need the flexibility of using custom tags and fingerprint generated based your own custom rules, use logExceptionWithSentryData
  • @param exception - The error object to be logged.
  • @param severity - log level or severity level of the failure e.g "fatal", "error"
  • @param userId - A unique user Id, identifying the user who made the failed request.
  • @param configuration - The configuration object required to build customs Sentry tags and fingerprint.
  • @returns {Promise} */ async function logExceptionWithConfig( exception, severity, userId, configuration ) * Example: const sentry = require("@everlong/sentry-error-logging"); const configuration = { tenantId:"tenant", env: "dev", sentryDsn:"https://dsn.string" }; try{ // doSomething(); }catch(err){ await sentry.logExceptionWithConfig(err, "fatal", userId, configuration); }

Readme

Keywords

none

Package Sidebar

Install

npm i @leagueutil/sentry-error-logger

Weekly Downloads

120

Version

1.0.5

License

UNLICENSED

Unpacked Size

22.4 kB

Total Files

4

Last publish

Collaborators

  • eezeh
  • gavinsharp-league