Skip to content

BugSplat-Git/my-javascript-crasher

Repository files navigation

bugsplat-github-banner-basic-outline

BugSplat

Crash and error reporting built for web developers.

my-javascript-crasher

This sample project demonstrates how to use the bugsplat package to report JavaScript errors in web applications. Before continuing with the tutorial please make sure you have completed the following checklist:

  • Sign Up as a new BugSplat user.
  • Log In using your email address.

⚙️ Integrating

Import bugsplat from esm.sh

<script type="module">
    import { BugSplat } from 'https://esm.sh/bugsplat@8.0.1';
</script>

Create a new instance of BugSplat with your database, application, and version

const bugsplat = new BugSplat('fred', 'my-javascript-crasher', '1.0.0');

Configure bugsplat to listen to window.onerror and window.onunhandledrejection events

window.onerror = function (message, source, lineno, colno, error) {
    bugsplat.post(error);
};

window.addEventListener('unhandledrejection', function (event) {
    bugsplat.post(event.reason);
});

Trigger an error to see it reported in BugSplat

throw new Error('todo bg');

🧪 Sample

Clone the my-javascript-crasher repository

git clone https://github.com/BugSplat-Git/my-javascript-crasher

Install the dependencies

cd my-javascript-crasher
npm i

Start the server

npm start

Open your browser and navigate to http://localhost:8080, then click the button to trigger an error.

📈 Viewing Reports

Navigate to the BugSplat Crashes page to view your report.

Crashes page

Click on the ID of the most recent error to view the details of your report.

Crash page