league-sentry
v1.0.0
Published
Setup a project to initialize and use Sentry to send error events within a cloud node function
Downloads
3
Readme
Node package to Initialize Sentry and also Send an error event to Sentry
This package is designed to Initialize Sentry and also Send an error event to Sentry.
To Send an error event to Sentry the caller has to ensure they have prepared the required custom fields for this package.
Required fields { sentryDsn, sentryEnv, fingerPrint, tags } See the definition of logException for more details:
/**
logException captures an error/exception and forwards it to Sentry as an event.
@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 sentryDsn - The Sentry Data Source Name where we want to send events to.
@param sentryEnv - The Sentry environment to attribute this Sentry event to.
@param fingerPrint - An array of string, used to build custom grouping of events.
@param tags - A simple key-value pair object, holding additional context about the error or event. See Sentry's scope.setTags for more info.
@returns {Promise} */ async function logException( exception, severity, userId, { sentryDsn, sentryEnv, fingerPrint, tags } ) * Example: ``` const sentry = require("auth0-sentry"); try{ // doSomething(); }catch(err){ // Build logData which can be forwarded to Sentry // See how custom logData can be built using
auth0-build-sentry-data
npm package. const logData = { sentryEnv, sentryDsn, tags, fingerPrint }; // required fields await sentry.logException(err, "fatal", userId, logData); }```