PhoenixReplay.Recording.Timeline (PhoenixReplay v0.6.2)

Copy Markdown View Source

Navigates a recording's events by index, and knows what the replay shows at each: the view's assigns, its LiveComponents' assigns, the page URL and the browser viewport.

A timeline is a cursor. seek/2 moves it forward by applying only the events in between, so playing a recording event by event costs one event a step; moving back starts over from the beginning.

Summary

Types

An event with its index in the recording.

An event that starts an interaction, and the events it caused.

t()

A position in a recording

Functions

A timeline of recording at the event at index.

Offset of the last event in milliseconds.

Index of the first event after which the view can be rendered.

Lays a recording out for playback, the same way for the player and its frame, so an index means the same event in both: the pointer track is taken out, to be drawn over the frame, and client state is spread into an event per entry. See PhoenixReplay.Recording.PointerTrack.split/1 and PhoenixReplay.Recording.State.spread/1.

Index of the last event at or before time, in milliseconds, but not before the first render: where the player stands at that moment.

Groups events into interactions: a mount, user event, navigation or message, followed by the renders, component updates and collected events it caused. Events before the first one form an interaction of their own.

Index of the last event, or 0 for an empty recording.

A timeline of recording, before its first event.

The event after the current one, or nil after the last.

Moves to the event at index, clamped to the recording's range.

Types

indexed()

An event with its index in the recording.

interaction()

@type interaction() :: {indexed(), [indexed()]}

An event that starts an interaction, and the events it caused.

t()

@type t() :: %PhoenixReplay.Recording.Timeline{
  assigns: map(),
  before: map(),
  components: %{required({module(), term()}) => map()},
  event: PhoenixReplay.Recording.Event.t() | nil,
  events: tuple(),
  index: integer(),
  start: %{
    url: String.t() | nil,
    viewport: PhoenixReplay.Recording.viewport() | nil
  },
  url: String.t() | nil,
  viewport: PhoenixReplay.Recording.viewport() | nil
}

A position in a recording:

  • :index — the current event's index, -1 before the first
  • :event — the current event, or nil
  • :assigns — the view's assigns after it, with the client state reported up to it merged into the reserved PhoenixReplay.Recording.State.assign/0
  • :before — the view's assigns before it, which the event changed into :assigns
  • :components — LiveComponent assigns after it, keyed by {module, id}
  • :url — the page URL: the last navigation up to it, or the URL the session started on
  • :viewport — the last :viewport event up to it, or the viewport the session connected with, if known

Functions

at(recording, index)

@spec at(PhoenixReplay.Recording.t(), integer()) :: t()

A timeline of recording at the event at index.

duration_ms(recording)

@spec duration_ms(PhoenixReplay.Recording.t()) :: non_neg_integer()

Offset of the last event in milliseconds.

first_render_index(recording)

@spec first_render_index(PhoenixReplay.Recording.t()) :: non_neg_integer()

Index of the first event after which the view can be rendered.

The recorder attaches before the view's own mount/3 runs, so the view's assigns first appear with the initial render.

for_playback(recording)

Lays a recording out for playback, the same way for the player and its frame, so an index means the same event in both: the pointer track is taken out, to be drawn over the frame, and client state is spread into an event per entry. See PhoenixReplay.Recording.PointerTrack.split/1 and PhoenixReplay.Recording.State.spread/1.

index_at(recording, time)

Index of the last event at or before time, in milliseconds, but not before the first render: where the player stands at that moment.

interactions(events)

@spec interactions([PhoenixReplay.Recording.Event.t()]) :: [interaction()]

Groups events into interactions: a mount, user event, navigation or message, followed by the renders, component updates and collected events it caused. Events before the first one form an interaction of their own.

last_index(arg1)

@spec last_index(PhoenixReplay.Recording.t() | t()) :: non_neg_integer()

Index of the last event, or 0 for an empty recording.

new(recording)

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

A timeline of recording, before its first event.

next(timeline)

@spec next(t()) :: PhoenixReplay.Recording.Event.t() | nil

The event after the current one, or nil after the last.

seek(timeline, index)

@spec seek(t(), integer()) :: t()

Moves to the event at index, clamped to the recording's range.