PhoenixReplay.Recording.Client (PhoenixReplay v0.6.2)

Copy Markdown View Source

The browser and the visit a recording came from, when the browser told PhoenixReplay (see PhoenixReplay.Capture.Browser):

  • :viewport — %{width: integer, height: integer, dpr: number} when the LiveView connected; later changes are :viewport events
  • :user_agent — the User-Agent header, when the endpoint's socket lists :user_agent in its :connect_info
  • :tab — an id of the browser tab, shared by the tab's sessions
  • :navigated_from — the URL of the LiveView that live-navigated here
  • :headers — request headers listed in the :client config, kept by PhoenixReplay.Plug
  • :landing — the visit's first request, when the :client config asks for it; see PhoenixReplay.Recording.Client.Landing

Its functions describe the device, named from its user agent with UAParser, and where the visit came from.

Summary

Types

The kind of device a session ran on, by its viewport's width; see device_type/1.

t()

Functions

The browser in a user agent, without its version, such as "Mobile Safari", or nil when it is not recognized.

Describes a landing's campaign as "google / cpc / spring_sale", from its UTM source, medium and campaign, or returns nil without them.

Reads a viewport written by encode_viewport/1, or nil.

The viewport a recording without one is shown at, such as in an export.

Names the browser, with its major version, and the system in a user agent, such as "Mobile Safari 18 on iOS", or returns nil when neither is recognized.

The kind of device a viewport belongs to, by its width in CSS pixels: "phone" below 640, "tablet" below 1024, "desktop" otherwise, or nil without a viewport.

The kinds of device device_type/1 tells apart.

Writes a viewport as "390x844@3", compact for storing alongside a summary, or nil.

A viewport's media settings as the CSS media features they are, for the replay to apply to the replayed page's media rules: %{"pointer" => "coarse", "prefers-color-scheme" => "dark", ...}, with those the browser did not report left out.

A viewport's orientation as CSS's orientation media feature tells it: portrait when it is at least as tall as it is wide.

The host of a referrer URL, such as "news.ycombinator.com", or nil.

Where the visit came from, as Google Analytics tells it; see PhoenixReplay.Recording.Traffic.

Brings a client context stored by an earlier version up to date: plain maps before 0.6, which named :navigated_from :referer.

Types

device_type()

@type device_type() :: String.t()

The kind of device a session ran on, by its viewport's width; see device_type/1.

t()

@type t() :: %PhoenixReplay.Recording.Client{
  headers: %{required(String.t()) => String.t()},
  landing: PhoenixReplay.Recording.Client.Landing.t() | nil,
  navigated_from: String.t() | nil,
  tab: String.t() | nil,
  user_agent: String.t() | nil,
  viewport: PhoenixReplay.Recording.viewport() | nil
}

Functions

browser_family(user_agent)

@spec browser_family(String.t() | nil) :: String.t() | nil

The browser in a user agent, without its version, such as "Mobile Safari", or nil when it is not recognized.

campaign(params)

@spec campaign(map()) :: String.t() | nil

Describes a landing's campaign as "google / cpc / spring_sale", from its UTM source, medium and campaign, or returns nil without them.

decode_viewport(encoded)

@spec decode_viewport(String.t() | nil) :: PhoenixReplay.Recording.viewport() | nil

Reads a viewport written by encode_viewport/1, or nil.

default_viewport()

@spec default_viewport() :: PhoenixReplay.Recording.viewport()

The viewport a recording without one is shown at, such as in an export.

device(user_agent)

@spec device(String.t() | nil) :: String.t() | nil

Names the browser, with its major version, and the system in a user agent, such as "Mobile Safari 18 on iOS", or returns nil when neither is recognized.

device_type(arg1)

@spec device_type(PhoenixReplay.Recording.viewport() | nil) :: device_type() | nil

The kind of device a viewport belongs to, by its width in CSS pixels: "phone" below 640, "tablet" below 1024, "desktop" otherwise, or nil without a viewport.

device_types()

@spec device_types() :: [device_type()]

The kinds of device device_type/1 tells apart.

encode_viewport(arg1)

@spec encode_viewport(PhoenixReplay.Recording.viewport() | nil) :: String.t() | nil

Writes a viewport as "390x844@3", compact for storing alongside a summary, or nil.

media(viewport)

@spec media(PhoenixReplay.Recording.viewport() | nil) :: %{
  required(String.t()) => String.t()
}

A viewport's media settings as the CSS media features they are, for the replay to apply to the replayed page's media rules: %{"pointer" => "coarse", "prefers-color-scheme" => "dark", ...}, with those the browser did not report left out.

orientation(arg1)

@spec orientation(%{
  :width => pos_integer(),
  :height => pos_integer(),
  optional(atom()) => term()
}) ::
  :portrait | :landscape

A viewport's orientation as CSS's orientation media feature tells it: portrait when it is at least as tall as it is wide.

referrer_host(url)

@spec referrer_host(String.t() | nil) :: String.t() | nil

The host of a referrer URL, such as "news.ycombinator.com", or nil.

traffic(client)

@spec traffic(t()) :: PhoenixReplay.Recording.Traffic.t()

Where the visit came from, as Google Analytics tells it; see PhoenixReplay.Recording.Traffic.

upgrade(client)

@spec upgrade(t() | map()) :: t()

Brings a client context stored by an earlier version up to date: plain maps before 0.6, which named :navigated_from :referer.