PhoenixReplay.Capture.Pointer (PhoenixReplay v0.6.2)

Copy Markdown View Source

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.

Summary

Functions

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

The event name batches arrive as.

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

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

Functions

capture(pid, params, pointer)

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

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

event()

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

The event name batches arrive as.

parse(params, max_points)

@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(pointer)

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

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