Builds a recording's client context: the browser's viewport and tab from
LiveView's connect params and event metadata, the user agent, and the
request context PhoenixReplay.Plug keeps for the visit.
PhoenixReplay's client module sends them when the host app passes its
helpers to LiveSocket:
import { replayParams, replayMetadata } from "phoenix_replay"
const liveSocket = new LiveSocket("/live", Socket, {
params: () => ({ _csrf_token: csrfToken, ...replayParams() }),
metadata: replayMetadata
})The connect params give the viewport and tab when the LiveView connects.
While the page is recorded, replayRecorder/1 sends the viewport as it
changes, a resized window or a rotated phone, once it settles, and it is
recorded as a :viewport event; see viewport/1. The metadata also adds
the viewport to each click and key press as a "_replay" param, which
catches changes when replayRecorder/1 does not run. The host's
handle_event/3 sees the extra param; it is left out of recorded params.
The last viewport seen is kept in the LiveView's process dictionary,
since both the recorder's hooks and the telemetry handlers run there.
Only the media settings the :client config keeps are recorded, as the
session's row in PhoenixReplay.Session.Buffer lists them.
Summary
Functions
Returns the client context of a connecting LiveView, from its connect
params, the User-Agent in its connect info, and the request context
PhoenixReplay.Plug kept for the visit. media lists the media
settings to keep, from the :client config, for this viewport and those
the LiveView reports after it.
Records a :viewport event when an event's params carry a viewport that
differs from the last one seen, and returns the params without it.
Parses a viewport sent by the client, or returns nil, keeping the
media settings listed in kept.
Records a :viewport event when the browser reports a viewport that
differs from the last one seen: sent on its own as the window is resized
or the phone rotated, or with a click or key press as a fallback.
The event name the browser sends viewport changes as, while it is recorded.
Functions
@spec build(map() | nil, String.t() | nil, map() | nil, [PhoenixReplay.Config.media()]) :: PhoenixReplay.Recording.Client.t()
Returns the client context of a connecting LiveView, from its connect
params, the User-Agent in its connect info, and the request context
PhoenixReplay.Plug kept for the visit. media lists the media
settings to keep, from the :client config, for this viewport and those
the LiveView reports after it.
Records a :viewport event when an event's params carry a viewport that
differs from the last one seen, and returns the params without it.
@spec parse(term(), [PhoenixReplay.Config.media()]) :: PhoenixReplay.Recording.viewport() | nil
Parses a viewport sent by the client, or returns nil, keeping the
media settings listed in kept.
@spec viewport(map()) :: :ok
Records a :viewport event when the browser reports a viewport that
differs from the last one seen: sent on its own as the window is resized
or the phone rotated, or with a click or key press as a fallback.
@spec viewport_event() :: String.t()
The event name the browser sends viewport changes as, while it is recorded.