# `PhoenixReplay.Capture.Pointer`
[🔗](https://github.com/elixir-vibe/phoenix_replay/blob/v0.6.2/lib/phoenix_replay/capture/pointer.ex#L1)

Records the pointer, touches and scrolling the browser sends, when
`:pointer` is configured.

`PhoenixReplay.Recorder` tells the browser to record, and with which
`:pointer` settings, on the connected mount, with its
`"phx_replay:record"` event. The client module's
`replayRecorder/1` then samples positions and scroll offsets and sends
them in batches as an `"phx_replay:pointer"` event, which the recorder
hands here and halts, so the view never sees it. A batch is:

  * `"span"` — milliseconds from the batch's first sample to sending it
  * `"m"` — moves, flattened `[dt, x, y, slot]` tuples
  * `"p"` — presses, `[dt, kind, x, y, slot, type, target, fx, fy]`:
    `kind` is `0` for down and `1` for up, `type` `0` for a mouse, `1`
    for touch and `2` for a pen, and `target` the id of the pressed
    element, with `fx`, `fy` the point within it in thousandths
  * `"s"` — scroll offsets, flattened `[dt, x, y]` tuples

`dt` counts milliseconds from the batch's first sample, `x` and `y` are
CSS pixels in the viewport, and `slot` tells concurrent touches apart.
Batches come from the browser, so anything malformed is dropped, numbers
are clamped and each batch holds at most `:max_points` entries. Each is
recorded as a `:pointer` event, outside `:max_events`, up to `:limit` per
session.

# `capture`

```elixir
@spec capture(pid(), map(), PhoenixReplay.Config.pointer()) :: :ok | :dropped | :error
```

Records a batch sent by the browser for the session `pid` records.

# `event`

```elixir
@spec event() :: String.t()
```

The event name batches arrive as.

# `parse`

```elixir
@spec parse(map(), pos_integer()) :: {:ok, map()} | :error
```

Validates a batch: returns its moves, presses and scrolls, each within
`max_points`, or `:error` when nothing usable is in it.

# `settings`

```elixir
@spec settings(PhoenixReplay.Config.pointer()) :: map()
```

The settings the browser records with, for `Phoenix.LiveView.push_event/3`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
