# Send your first bug

Before you rely on BugTape, make it catch one error on purpose. Setup tells you when it arrives.

## Option 1: send a test event from Setup

In **Setup**, step 5 has a **Send a test event** button. It creates a sample bug in your project so you can see what a report looks like. It checks your workspace. To check your install, use option 2.

## Option 2: throw an error on your own site

Open your site in a browser, open the developer console and run:

```js
setTimeout(() => { throw new Error('BugTape install test'); });
```

Within a few seconds a new issue called **BugTape install test** appears in **Issues**. Open it to see the page, the console and the stack.

If you named and tracked your app in Setup, Setup also confirms the first report from that exact install.

## Send a test bug

Pick one snippet, paste it into the developer console on a page where the BugTape script is installed, and press Enter. In the console, **Setup → step 5** shows **Waiting for your first bug…** and changes to **Received** with a link to the issue when it lands. An identical message is reported once a minute, so change the text to send it again.

Each snippet uses `setTimeout` so the error is uncaught. Errors thrown directly in the developer console are not reported.

JavaScript TypeError:

```js
setTimeout(() => { const cart = undefined; cart.total; }, 0)
```

Unhandled promise rejection:

```js
setTimeout(() => Promise.reject(new Error('BugTape test: unhandled rejection')), 0)
```

Failed request (HTTP 500):

```js
fetch('https://httpbin.org/status/500').then(r => { if (!r.ok) throw new Error('BugTape test: HTTP ' + r.status); })
```

A failed request on its own is only context unless you just clicked or typed in the page. This snippet also throws, so the unhandled rejection is what creates the bug. The 500 shows in the network waterfall.

console.error:

```js
setTimeout(() => { console.error('BugTape test: checkout failed'); throw new Error('BugTape test: checkout failed'); }, 0)
```

`console.error` is recorded as console context. It does not create a bug by itself, so this snippet also throws.

To test from a terminal or a server, post to the ingest route. Replace `YOUR_PROJECT_KEY` with a capture key for the project.

```sh
curl -X POST https://app.bugtape.ai/v1/ingest \
  -H 'Content-Type: application/json' \
  -H 'X-BugTape-Key: YOUR_PROJECT_KEY' \
  -d '{"title":"BugTape test: curl","description":"Sent from the command line","severity":"low","platform":"server"}'
```

## The example bug

Every new project starts with one example bug, marked **Example**. It shows a full capture: error, console, network, breadcrumbs and environment. It is not from your app. It never sends a notification, does not count toward your first bug and is not charged. Resolve or delete it any time.

An existing project can add one from the empty inbox (**Add example bug**) or from **Settings**.

## If nothing arrives

- Check the page loads `https://app.bugtape.ai/bugtape.mjs` (Network tab in the developer tools).
- Check the key in the script matches a key in **Settings → API keys** and has not been revoked.
- If you only call `init` after consent, accept the consent banner first.
- If your site has a Content Security Policy, allow `https://app.bugtape.ai` in `script-src` and `connect-src`.

## Next

Decide whether your users see the bug-report button.
