An open API service indexing awesome lists of open source software.

https://github.com/bugsplat-git/my-javascript-crasher

Crush your JavaScript bugs by following the example in this repo
https://github.com/bugsplat-git/my-javascript-crasher

browser bugsplat error esmodules javascript js reporting web

Last synced: 3 months ago
JSON representation

Crush your JavaScript bugs by following the example in this repo

Awesome Lists containing this project

README

        

[![bugsplat-github-banner-basic-outline](https://user-images.githubusercontent.com/20464226/149019306-3186103c-5315-4dad-a499-4fd1df408475.png)](https://bugsplat.com)


#

BugSplat

### **
Crash and error reporting built for web developers.
**


Follow @bugsplatco on Twitter


Join BugSplat on Discord

# my-javascript-crasher

This sample project demonstrates how to use the [bugsplat](https://github.com/BugSplat-Git/bugsplat-js) package to report JavaScript errors in web applications. Before continuing with the tutorial please make sure you have completed the following checklist:

* [Sign Up](https://app.bugsplat.com/v2/sign-up) as a new BugSplat user.
* [Log In](https://app.bugsplat.com/cognito/login) using your email address.

## โš™๏ธ Integrating

Import [bugsplat](https://github.com/BugSplat-Git/bugsplat-js) from [esm.sh](https://esm.sh)

```html

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

```

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

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

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

```javascript
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

```javascript
throw new Error('todo bg');
```

## ๐Ÿงช Sample

Clone the [my-javascript-crasher](https://github.com/BugSplat-Git/my-javascript-crasher) repository

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

Install the dependencies

```sh
cd my-javascript-crasher
npm i
```

Start the server

```sh
npm start
```

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

## ๐Ÿ“ˆ Viewing Reports

Navigate to the BugSplat [Crashes](https://app.bugsplat.com/v2/crashes?database=Fred&c0=appName&f0=CONTAINS&v0=my-javascript-crasher) page to view your report.

![Crashes page](https://github.com/BugSplat-Git/my-javascript-crasher/assets/2646053/af6950bb-530b-42da-8679-47f220f08a40)

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

![Crash page](https://github.com/BugSplat-Git/my-javascript-crasher/assets/2646053/acc8fa5c-b93e-4037-a72e-ea39f3437b8e)