PhoenixReplay.Recording.Summary (PhoenixReplay v0.6.2)

Copy Markdown View Source

Lightweight description of a recording, used for listings and filtering.

Storage backends return summaries without decoding full recordings. event_names are the distinct handle_event/3 names, sorted, and marks the moments the session reached, by name, with how many times; see PhoenixReplay.Recording.Event.mark_name/1. error_count counts the events for which PhoenixReplay.Recording.Event.error?/1 holds. tab is the browser tab the session ran in, when the client sent it, shared by the sessions of one journey. viewport, device, device_type and browser describe the browser, and source, medium and campaign where the visit came from, as PhoenixReplay.Recording.Client names them. saved_at is when storage saved the recording, in Unix milliseconds, or nil before it is saved and for recordings saved before PhoenixReplay 0.5. live? is true while the recorded LiveView process is still running.

Summary

Types

t()

What a summary counts of a recording's events; see totals/2.

Functions

Adds one reaching of the mark name to marks, as totals/2 counts them.

How one event adds to totals/2: 1 or 0 to the event count and to the error count, its handle_event/3 name, if it has one, and its name as a mark, if it is one. PhoenixReplay.Session.Buffer keeps running totals with it as events are written.

Summarizes a recording.

Orders summaries most recent first. Sessions that started in the same millisecond are ordered by id, so pages never repeat or skip them.

When the recording reached storage: saved_at, or connected_at for recordings saved before PhoenixReplay 0.5 recorded it. Lists are read as of a moment by this time, so recordings saved later wait instead of shifting the rows.

Counts events into totals, which start at zero: every event but pointer batches and client state, which are not shown as events; the events for which PhoenixReplay.Recording.Event.error?/1 holds; the distinct handle_event/3 names, sorted; the marks reached, by name, with how many times; and the time of the last event.

Brings a summary saved by an earlier version up to date. Before 0.6, source held the campaign as "google / cpc / spring", now split into source, medium and campaign, and there was no device_type. The browser's family cannot be told from the device saved then, so browser stays nil.

Types

t()

@type t() :: %PhoenixReplay.Recording.Summary{
  browser: String.t() | nil,
  campaign: String.t() | nil,
  connected_at: integer(),
  device: String.t() | nil,
  device_type: PhoenixReplay.Recording.Client.device_type() | nil,
  duration_ms: non_neg_integer(),
  error_count: non_neg_integer(),
  event_count: non_neg_integer(),
  event_names: [String.t()],
  id: PhoenixReplay.Recording.id(),
  live?: boolean(),
  marks: %{required(String.t()) => pos_integer()},
  medium: String.t() | nil,
  release: String.t() | nil,
  saved_at: integer() | nil,
  source: String.t() | nil,
  tab: String.t() | nil,
  url: String.t() | nil,
  view: String.t(),
  viewport: PhoenixReplay.Recording.viewport() | nil
}

totals()

@type totals() :: %{
  event_count: non_neg_integer(),
  error_count: non_neg_integer(),
  event_names: [String.t()],
  marks: %{required(String.t()) => pos_integer()},
  duration_ms: non_neg_integer()
}

What a summary counts of a recording's events; see totals/2.

Functions

add_mark(marks, name)

@spec add_mark(%{required(String.t()) => pos_integer()}, String.t() | nil) :: %{
  required(String.t()) => pos_integer()
}

Adds one reaching of the mark name to marks, as totals/2 counts them.

counts(event)

@spec counts(PhoenixReplay.Recording.Event.t()) ::
  {0 | 1, 0 | 1, String.t() | nil, String.t() | nil}

How one event adds to totals/2: 1 or 0 to the event count and to the error count, its handle_event/3 name, if it has one, and its name as a mark, if it is one. PhoenixReplay.Session.Buffer keeps running totals with it as events are written.

new(recording, opts \\ [])

@spec new(PhoenixReplay.Recording.t(), keyword()) :: t()

Summarizes a recording.

sort(summaries)

@spec sort([t()]) :: [t()]

Orders summaries most recent first. Sessions that started in the same millisecond are ordered by id, so pages never repeat or skip them.

stored_at(summary)

@spec stored_at(t()) :: integer()

When the recording reached storage: saved_at, or connected_at for recordings saved before PhoenixReplay 0.5 recorded it. Lists are read as of a moment by this time, so recordings saved later wait instead of shifting the rows.

totals(events, totals \\ %{duration_ms: 0, error_count: 0, event_count: 0, event_names: [], marks: %{}})

@spec totals([PhoenixReplay.Recording.Event.t()], totals()) :: totals()

Counts events into totals, which start at zero: every event but pointer batches and client state, which are not shown as events; the events for which PhoenixReplay.Recording.Event.error?/1 holds; the distinct handle_event/3 names, sorted; the marks reached, by name, with how many times; and the time of the last event.

A recording flushed to storage in chunks is counted chunk by chunk.

upgrade(summary)

@spec upgrade(t()) :: t()

Brings a summary saved by an earlier version up to date. Before 0.6, source held the campaign as "google / cpc / spring", now split into source, medium and campaign, and there was no device_type. The browser's family cannot be told from the device saved then, so browser stays nil.