# QBCore Event Inspector: Private Test Event Feed

This viewer displays events that you explicitly submit to your own ingest endpoint. It does not
automatically connect to a QBCore server, trace event handlers, or measure execution time.

Starting a session creates a feed that only your browser can read, plus an ingest key that only
writes into that feed. Other visitors cannot read your entries, and you cannot read theirs.

> Treat the ingest key like a password. Anyone who has it can post into your feed. Even so, send
> redacted labels and aggregate timings rather than player identifiers, coordinates, inventory, or
> chat. This is a scratch pad for shaping payloads, not a telemetry pipeline.

## What the viewer does

- Issues a session, scoped to your browser by an `HttpOnly`, `SameSite=Strict` cookie.
- Loads the in-memory buffer for that session only.
- Opens a Server-Sent Events connection for new entries in that session only.
- Filters locally by search text and event type.
- Shows submitted status, source, data, and response-time fields without verifying them.
- Downloads the currently displayed client-side data as JSON.

## Endpoints

| Method | Path | Auth | Behavior |
| --- | --- | --- | --- |
| `POST` | `/api/tools/event-debugger/session` | none | Create a session and return an ingest key. |
| `DELETE` | `/api/tools/event-debugger/session` | session cookie | Drop the session and its buffer. |
| `GET` | `/api/tools/event-debugger?limit=200` | session cookie | Read your own recent entries. |
| `GET` | `/api/tools/event-debugger/stream` | session cookie | Subscribe to your own new entries. |
| `POST` | `/api/tools/event-debugger` | ingest key | Submit an entry to the key owner feed. |
| `DELETE` | `/api/tools/event-debugger` | session cookie | Clear your own buffer. |

Requests without the matching credential are rejected with `401`. The ingest endpoint deliberately
does not accept the session cookie, so another site cannot post into your feed using your browser's
ambient credentials.

## Posting an event

Send the key as the `x-qbcore-debug-key` header, an `Authorization: Bearer` value, or a `?key=`
query parameter.

```bash
curl -X POST "https://qbcore.net/api/tools/event-debugger" \
  -H "Content-Type: application/json" \
  -H "x-qbcore-debug-key: YOUR_KEY" \
  -d '{"name":"qb-garages:server:park","type":"server","status":"success","responseTime":12,"data":{"slot":3}}'
```

## Limits

- A session lasts one hour, then its key stops working and its buffer is dropped.
- A session holds at most 200 entries. Older entries fall off the end.
- Ingest is rate limited to 60 requests per minute per session.
- Entries live in server memory only. They are never written to disk, and a restart clears them.

Use a local, authenticated collector for real server diagnostics. Prefer aggregate timings and
redacted labels over raw event payloads.
