BugSplat's bugsplat-node package provides error reporting for Node.js and Electron applications.
To add the bugsplat package to your application, run the following shell command at the root of your project’s directory:
Require bugsplat at the entry point of your application (usually main.js) by adding the following code snippet:
Create a new instance of the BugSplat class being sure to replace DatabaseName, AppName and the version number with the correct values for your application:
Set the bugsplat.post function as an event handler for uncaught exceptions:
You will also want to listen for unhandled promise rejections. Please note that this will only work for native promises:
Throw an exception after the event handler has been added:
You can also use bugsplat-node to post errors from non-fatal promise rejections and errors that originate inside of try-catch blocks:
After posting an error with bugsplat-node, navigate to the Crashes page in BugSplat and you should see a new crash report for the application you just configured. Click the link in the ID column to see details about your crash on the Crash page:
That’s it! Your application is now configured to post crash reports to BugSplat.
In addition to the configuration demonstrated above, there are a few public methods that can be used to customize your BugSplat integration:
Additionally you can use domains to handle errors differently across various parts of your application. Domains are pending deprecation according the the Node.js documentation, however a suitable replacement has not been added yet.
More information regarding domain deprecation can be found here.
BugSplat loves open source software! Please check out our project on GitHub and send us a pull request.