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
@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
@spec activity( PhoenixReplay.Config.t(), PhoenixReplay.Recording.Filter.t(), keyword() ) :: activity()
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.
@spec broadcast_change() :: :ok
Notifies subscribers that the set of recordings changed.
@spec clear(PhoenixReplay.Config.t()) :: :ok | {:error, term()}
Deletes every stored recording.
@spec delete(PhoenixReplay.Config.t(), PhoenixReplay.Recording.id()) :: :ok | {:error, term()}
Deletes a stored recording.
@spec fetch(PhoenixReplay.Config.t(), PhoenixReplay.Recording.id(), keyword()) :: {:ok, PhoenixReplay.Recording.t()} | {:error, term()}
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.
@spec list(PhoenixReplay.Config.t()) :: [PhoenixReplay.Recording.Summary.t()]
Lists buffered then stored recordings, each most recent first.
@spec live(PhoenixReplay.Recording.Filter.t(), integer()) :: [ PhoenixReplay.Recording.Summary.t() ]
Summaries of the sessions still recording that match filter, most recent first.
@spec live?(PhoenixReplay.Recording.id()) :: boolean()
Returns true while the session id is in the buffer and has not been saved.
@spec query(PhoenixReplay.Config.t(), PhoenixReplay.Recording.Filter.t(), keyword()) :: {[PhoenixReplay.Recording.Summary.t()], non_neg_integer()}
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.
@spec subscribe() :: :ok | {:error, term()}
Subscribes the caller to :recordings_changed messages.
@spec values( PhoenixReplay.Config.t(), PhoenixReplay.Recording.Filter.field(), PhoenixReplay.Recording.Filter.t(), keyword() ) :: [{String.t(), pos_integer()}]
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.