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:
<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');
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.
Navigate to the BugSplat Crashes page to view your report.
Click on the ID of the most recent error to view the details of your report.