Automatically reports Node crashes to Sentry if SENTRY_URL is in the environment
npm i -S node-sentry-error-reporter
The goal is to have zero configuration reporter that handles global or app's errors automatically.
Set environment variable
SENTRY_URL if you need exception reporting.
Then just require the module and pass (if needed) a server object, for example an Express app.
const reporter =// or if inside Express appconst app =
NODE_ENV is 'production' the errors will be forwarded to the Sentry server,
otherwise just printed to the console error stream.
Report an error
The module returns a function you can use to report instances of error.
const init =const report =
init is memoized, thus you can call it from multiple modules, and it will
only init once.
You can pass additional details object after the error
Release / version
This package tries to send "release" or "version" string with each error.
It is looked up from the environment settings under
RELEASE, etc. names,
or if not found, from the current folder's
See src/find-version.js source file.
How to exit
If you are reporting an error and then exiting the Node process, you need to give the reporter enough time to make HTTP post to the crash server. I would recommend at least 1 second delay.
Author: Gleb Bahmutov <email@example.com> © 2016
License: MIT - do anything with the code, but don't blame me if it does not work.
Support: if you find any problems with this module, email / tweet / open issue on Github
Copyright (c) 2016 Gleb Bahmutov <firstname.lastname@example.org>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.