Exports recordings as videos of the replayed page and the pointer.
A recording holds no pixels: the player renders it again from recorded assigns. An export does the same in a headless browser and films it.
PhoenixReplay.Export.Scheduleplans the video: a constant frame rate from the first render, idle stretches shortened, and a screenshot only where the picture changes.PhoenixReplay.Export.Screenshotsloads the replay into Chromium throughplaywright_ex, at the recorded viewport and pixel ratio, steps it through the plan with the player's own pointer overlay, and screenshots each change.PhoenixReplay.Export.Encoderencodes the screenshots withffmpeginto an H.264 MP4, run by MuonTrap so it never outlives the export.
The browser loads the replay from PhoenixReplay.Web.Export.Endpoint, a
private endpoint on 127.0.0.1 started with the first export, so it
needs no route or login in your app.
Exports wait their turn in a PhoenixReplay.Export.Queue: by default
PhoenixReplay.Export.Queue.Local, in memory, one at a time or
:max_concurrency at once; or PhoenixReplay.Export.Queue.Oban, in
your Oban queue. Each job's progress is broadcast; the player's Export
video and mix phoenix_replay.export both follow it. Finished videos
are deleted after :ttl.
Setup
Add {:playwright_ex, "~> 0.14"} and {:muontrap, "~> 1.6"}, install
Playwright's Chromium (npx playwright install chromium) and ffmpeg,
and name your endpoint. MuonTrap runs on Linux and macOS.
config :phoenix_replay, export: [endpoint: MyAppWeb.Endpoint]See :export in PhoenixReplay.Config for the other options. Only
saved recordings are exported, not sessions still running.
Summary
Types
Why exporting is not possible.
Functions
Whether videos can be exported with config, or why not.
Whether videos can be exported with config.
Cancels an export that is queued or running. A running one closes its
browser and stops encoding first, and ends :cancelled.
Explains why exporting is not possible.
The export with id, if it is still kept.
The latest export of a recording, if one is kept.
Exports a saved recording with options, by default those the
configuration sets, or returns the export of it already queued or
running. See PhoenixReplay.Export.Options.
Subscribes the caller to the exports of a recording: each change to one
arrives as {PhoenixReplay.Export, %PhoenixReplay.Export.Job{}}.
Types
Functions
@spec available(PhoenixReplay.Config.t()) :: :ok | {:error, unavailable()}
Whether videos can be exported with config, or why not.
@spec available?(PhoenixReplay.Config.t()) :: boolean()
Whether videos can be exported with config.
@spec cancel(PhoenixReplay.Export.Job.id(), PhoenixReplay.Config.t()) :: :ok
Cancels an export that is queued or running. A running one closes its
browser and stops encoding first, and ends :cancelled.
@spec describe(unavailable()) :: String.t()
Explains why exporting is not possible.
@spec get(PhoenixReplay.Export.Job.id(), PhoenixReplay.Config.t()) :: PhoenixReplay.Export.Job.t() | nil
The export with id, if it is still kept.
@spec latest(PhoenixReplay.Recording.id(), PhoenixReplay.Config.t()) :: PhoenixReplay.Export.Job.t() | nil
The latest export of a recording, if one is kept.
@spec start( PhoenixReplay.Recording.id(), PhoenixReplay.Config.t(), PhoenixReplay.Export.Options.t() | nil ) :: {:ok, PhoenixReplay.Export.Job.t()} | {:error, unavailable()}
Exports a saved recording with options, by default those the
configuration sets, or returns the export of it already queued or
running. See PhoenixReplay.Export.Options.
@spec subscribe(PhoenixReplay.Recording.id()) :: :ok | {:error, term()}
Subscribes the caller to the exports of a recording: each change to one
arrives as {PhoenixReplay.Export, %PhoenixReplay.Export.Job{}}.