PhoenixReplay.Catalog (PhoenixReplay v0.6.2)

Copy Markdown View Source

Reads and deletes recordings across the live buffer and storage.

A recording is in exactly one place: PhoenixReplay.Session.Buffer while its session runs and until it is saved, storage afterwards. Changes are broadcast on PhoenixReplay.PubSub so the dashboard can refresh without polling.

Stored recordings were redacted when they were saved. Sessions still in the buffer are redacted here, with their session's PhoenixReplay.Redactor, so everything read through this module shows the same values.

Summary

Types

How many sessions started in each stretch of a time range, for a chart: buckets are {start, sessions, with_errors}, every size milliseconds from from to to, empty ones included.

Functions

Counts the buffered and stored sessions matching filter by when they started, over the stretch of time it covers; see PhoenixReplay.Recording.Filter.time_range/2. Takes :now and :allow as query/3 does, and :utc_offset, how far the viewer's time zone is ahead of UTC in milliseconds, so stretches begin at its midnights and hours.

Notifies subscribers that the set of recordings changed.

Deletes every stored recording.

Deletes a stored recording.

Fetches a recording from the buffer or storage.

Lists buffered then stored recordings, each most recent first.

Summaries of the sessions still recording that match filter, most recent first.

Returns true while the session id is in the buffer and has not been saved.

Reads a page of stored recordings matching filter, most recent first, and counts every match. See PhoenixReplay.Recording.Filter.page_opts/0.

Subscribes the caller to :recordings_changed messages.

The values of a filter's field among buffered and stored recordings matching the rest of filter, with how many recordings have each, the most common first, for suggesting filter values. Takes :now, :limit and :allow as query/3 does.

Types

activity()

@type activity() :: %{
  from: integer(),
  to: integer(),
  size: pos_integer(),
  buckets: [PhoenixReplay.Recording.Filter.bucket() | {integer(), 0, 0}]
}

How many sessions started in each stretch of a time range, for a chart: buckets are {start, sessions, with_errors}, every size milliseconds from from to to, empty ones included.

Functions

activity(config, filter, opts)

Counts the buffered and stored sessions matching filter by when they started, over the stretch of time it covers; see PhoenixReplay.Recording.Filter.time_range/2. Takes :now and :allow as query/3 does, and :utc_offset, how far the viewer's time zone is ahead of UTC in milliseconds, so stretches begin at its midnights and hours.

broadcast_change()

@spec broadcast_change() :: :ok

Notifies subscribers that the set of recordings changed.

clear(config)

@spec clear(PhoenixReplay.Config.t()) :: :ok | {:error, term()}

Deletes every stored recording.

delete(config, id)

@spec delete(PhoenixReplay.Config.t(), PhoenixReplay.Recording.id()) ::
  :ok | {:error, term()}

Deletes a stored recording.

fetch(config, id, opts \\ [])

Fetches a recording from the buffer or storage.

A buffered session is redacted first, which can take a while with a detecting PhoenixReplay.Redactor. Pass progress: fun to be called with the number of events redacted so far and the total.

list(config)

Lists buffered then stored recordings, each most recent first.

live(filter, now)

Summaries of the sessions still recording that match filter, most recent first.

live?(id)

@spec live?(PhoenixReplay.Recording.id()) :: boolean()

Returns true while the session id is in the buffer and has not been saved.

query(config, filter, opts)

Reads a page of stored recordings matching filter, most recent first, and counts every match. See PhoenixReplay.Recording.Filter.page_opts/0.

Storage pages the recordings itself, unless :allow is given: a function that decides which summaries the reader may see. Every summary is then read and checked, so the count stays exact.

subscribe()

@spec subscribe() :: :ok | {:error, term()}

Subscribes the caller to :recordings_changed messages.

values(config, field, filter, opts)

The values of a filter's field among buffered and stored recordings matching the rest of filter, with how many recordings have each, the most common first, for suggesting filter values. Takes :now, :limit and :allow as query/3 does.