Core 1.0.0-rc.1
Replay Plugin
The replay plugin records machine activity into an in-memory session you can inspect or export.
It is useful for debugging, QA capture, support tickets, and test tooling where you want to preserve the order of runtime snapshots and lifecycle events without changing machine behavior.
Install And Use
import { createJourneyMachine } from "@rxova/journey-core";
import { createReplayPlugin } from "@rxova/journey-core/replay";
const machine = createJourneyMachine(journey, {
plugins: [
createReplayPlugin({
maxEntries: 250
})
]
});
await machine.start();
const session = machine.getReplaySession();
const exported = machine.exportReplaySession({ pretty: true });
What You Get
The plugin augments the machine with:
type JourneyReplayMachineExtension = {
getReplaySession: () => JourneyReplaySession;
clearReplaySession: () => void;
exportReplaySession: (options?: JourneyReplayExportOptions) => string;
};
getReplaySession() returns:
type JourneyReplaySession = {
version: 1;
initialSnapshot: JourneySnapshot | null;
entries: JourneyReplayEntry[];
truncated: boolean;
};
Entries are ordered and come in two forms:
snapshot: a committed snapshot plus the snapshot-changereasonevent: an observation event emitted by the machine
Options
maxEntries: replay buffer size, default500captureEvents: include observation events, defaulttruecaptureSnapshots: include snapshot entries, defaulttrue
When the buffer fills, the oldest entries are dropped and truncated becomes true.
Runtime Behavior
hydrateSnapshot(...)captures the starting snapshot asinitialSnapshot- later snapshot commits are recorded when
captureSnapshotsis enabled - lifecycle events are recorded through
subscribeEvent(...)whencaptureEventsis enabled clearReplaySession()resets the buffer and uses the current machine snapshot as the new replay baseline
Export Behavior
exportReplaySession() returns JSON safe for logs or attachment workflows.
The serializer normalizes values that are awkward or invalid in JSON:
bigintbecomes a stringundefinedbecomesnull- functions and symbols become placeholder strings
Datebecomes ISO textErrorbecomes a plain object withname,message, and optionalstack- circular references are replaced with
[circular]
Use pretty: true when you want readable output for local debugging.