Code Monkey home page Code Monkey logo

bugsplat-node's Introduction

bugsplat-github-banner-basic-outline

BugSplat

Crash and error reporting built for busy developers.


πŸ‘‹ Introduction

BugSplat-node is a JavaScript error reporting system for Node.js and Electron applications. Before continuing with the tutorial please make sure you have completed the following checklist:

βš™οΈ Configuration

To add the bugsplat package to your application, run the following shell command at the root of your project’s directory:

npm install --save bugsplat-node

Require the bugsplat module at the entry point of your application.

const { BugSplatNode } = require("bugsplat-node");

Create a new instance of the BugSplat class with the name of your BugSplat database, the name of your application and the version of your application:

const bugsplat = new BugSplatNode("DatabaseName", "AppName", "1.0.0.0");

Set the bugsplat.post function as an event handler for uncaught exceptions:

process.on("uncaughtException", bugsplat.postAndExit);

If your application uses promises you will also want to listen for unhandled promise rejections. Please note that this will only work for native promises:

process.on("unhandledRejection", bugsplat.postAndExit);

Throw an exception after the event handler has been added.

throw new Error("BugSplat!");

You can also use bugsplat-node to post errors from non-fatal promise rejections and errors that originate inside of try-catch blocks:

Promise.reject(new Error("BugSplat!")).catch(error => bugsplat.post(error, {}));
try {
    throw new Error("BugSplat");
} catch(error) {
    await bugsplat.post(error, {});
}

After posting an error with bugsplat-node, navigate to the Crashes page. 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:

Crashes

Crash

That’s it! Your application is now configured to post crash reports to BugSplat.

🧩 API

In addition to the configuration demonstrated above, there are a few public methods that can be used to customize your BugSplat integration:

bugsplat.setDefaultAppKey(appKey); // Additional metadata that can be queried via BugSplat's web application
bugsplat.setDefaultUser(user); // The name or id of your user
bugsplat.setDefaultEmail(email); // The email of your user
bugsplat.setDefaultDescription(description); // Additional info about your crash that gets reset after every post
bugsplat.setDefaultAdditionalFilePaths(paths); // Paths to files to be added at post time (limit 10MB)
bugsplat.postAndExit(error); // Wrapper for post that calls process.exit(1) after posting error to BugSplat
bugsplat.post(error, options); // Posts an arbitrary Error object to BugSplat
// If the values options.appKey, options.user, options.email, options.description, options.additionalFilePaths are set the corresponding default values will be overwritten
// Returns a promise that resolves with properties: error (if there was an error posting to BugSplat), response (the response from the BugSplat crash post API), and original (the error passed by bugsplat.post)

πŸ€” Additional Considerations

It is recommended that you exit and restart your application after an uncaughtException or unhandledRejection occurs. Packages such as pm2 and forever can be configured to restart your application.

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.

πŸ§‘β€πŸ’» Contributing

BugSplat loves open source software! Please check out our project on GitHub and send us a pull request. Found an bug or have a feature request? Open an issue and we'll address it.

bugsplat-node's People

Contributors

bobbyg603 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

bugsplat-node's Issues

Update bugsplat-js

Our macduff fleet is throwing errors without a stack, the new version of bugsplat-js will create a new Error object if an error does not have a stack

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.