> ## Documentation Index
> Fetch the complete documentation index at: https://piyushvyas.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# bap watch

> Stream live browser events to the terminal. Monitor console errors, network failures, dialogs, and downloads in real time.

# bap watch

Long-running command that subscribes to browser events and streams them to the terminal. Runs until Ctrl+C.

## Usage

<CodeGroup>
  ```bash All events theme={null}
  bap watch
  ```

  ```bash Console messages only theme={null}
  bap watch --filter=console
  ```

  ```bash Network errors only theme={null}
  bap watch --filter=network
  ```

  ```bash Multiple filters theme={null}
  bap watch --filter=console,network
  ```

  ```bash JSON output for piping theme={null}
  bap watch --format=json
  ```
</CodeGroup>

<ParamField path="--filter" type="string">
  Comma-separated list of event types to show. Options: `page`, `console`, `network`, `dialog`,
  `download`. When omitted, all events are shown.
</ParamField>

<ParamField path="--format" type="string" default="pretty">
  Output format: `pretty` (color-coded, human-readable) or `json` (NDJSON for piping).
</ParamField>

## Event Types

<AccordionGroup>
  <Accordion title="page">
    Page lifecycle events: load, navigation, close.

    ```
    14:30:42 PAGE     load https://example.com
    14:30:45 PAGE     navigation https://example.com/dashboard
    ```
  </Accordion>

  <Accordion title="console">
    Browser console output with log level (error, warn, log, debug). `14:30:43 CONSOLE ERROR
          Uncaught TypeError: Cannot read properties of null 14:30:43 CONSOLE WARN Deprecation: Feature X
          will be removed in v3`
  </Accordion>

  <Accordion title="network">
    HTTP requests and responses. Responses show status codes, color-coded by range.

    ```
    14:30:42 NET     -> GET  https://api.example.com/users
    14:30:42 NET     <- 200  https://api.example.com/users
    14:30:43 NET     <- 404  https://api.example.com/missing
    14:30:43 NET     x  https://api.example.com/timeout (net::ERR_TIMED_OUT)
    ```
  </Accordion>

  <Accordion title="dialog">
    Browser dialogs: alert, confirm, prompt. `14:30:44 DIALOG alert: Are you sure you want to
          leave?`
  </Accordion>

  <Accordion title="download">
    File downloads with state and filename.

    ```
    14:30:45 DOWNLOAD started report.pdf
    14:30:47 DOWNLOAD completed report.pdf
    ```
  </Accordion>
</AccordionGroup>

## JSON Output

With `--format=json`, each event is emitted as a single JSON line (NDJSON), suitable for piping to other tools:

```json theme={null}
{"eventType":"console","level":"error","text":"Uncaught TypeError","timestamp":1711036243000}
{"eventType":"network","type":"response","status":404,"url":"https://api.example.com/missing","timestamp":1711036243500}
```

## Use Cases

<CardGroup cols={2}>
  <Card title="Debug failing interactions">
    Run `bap watch --filter=console` in one terminal while running BAP commands in another. Console
    errors often explain why clicks or fills fail.
  </Card>

  <Card title="Monitor API calls">
    Use `bap watch --filter=network` to see what API calls a page makes. Useful for understanding
    SPA behavior.
  </Card>

  <Card title="Pipe to log aggregator">
    `bap watch --format=json | jq '.text'` to extract console message text, or pipe to any
    NDJSON-compatible tool.
  </Card>

  <Card title="Catch unexpected dialogs">
    Use `bap watch --filter=dialog` to detect alert/confirm/prompt dialogs that might block
    automation.
  </Card>
</CardGroup>

<Note>
  `bap watch` requires a running browser session. If no session exists, start one first with `bap
      open` or `bap goto`.
</Note>
