Deno

๐Ÿ‘€ Getting Started

Adding BugSplat error reporting to your Deno application, web worker, or serverless function only takes a few lines of code. Once integrated, BugSplat will capture stack traces, logs, and other valuable insight when your code encounters a problem. BugSplat's bugsplat-js package is fully typed and easily imported via esm.sh.

โš™๏ธ Integrating

Add an import from bugsplat-js via esm.sh:

import { BugSplat } from 'https://esm.sh/[email protected]';

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 BugSplat('DatabaseName', 'AppName', '1.0.0');

Use the bugsplat instance to capture errors that originate inside of try-catch blocks:

try {
  throw new Error("BugSplat");
} catch (error) {
  await bugsplat.post(error);
}

Use bugsplat to post errors from promise rejections:

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

You can also attach a file to your error post by passing a BugSplatOptions object containing with a value for additionalFormDataParams property.

await bugsplat.post(error, getAdditionalOptionsWithLogFile());

function getAdditionalOptionsWithLogFile() {
  const filename = 'log.txt';
  return {
    additionalFormDataParams: [{
      key: 'file',
      value: new File([Deno.readFileSync(filename)], filename),
      filename: filename,
    }],
  };
}

๐Ÿงช Sample

Clone the my-deno-crasher repository:

Set your current directory to my-deno-crasher.

Run the sample with the --allow-net and --allow-read flags to allow BugSplat to post an error to our backend and read the log file respectively.

๐Ÿ“ˆ Viewing Reports

After posting an error, 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 Crashes page:

Deno Error Reports
Deno Error Report

Thatโ€™s it! Your application is now configured to post error 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:

๐Ÿค Contributing

BugSplat loves open-source software! Please check out our project on GitHub and send us a Pull Request.

Last updated

Was this helpful?