ActionsRecorder
A plugin that records user actions and editor state changes for debugging purposes. It tracks commands execution, model operations, UI interactions, and document events. It just collects data locally, and does not send it anywhere, integrator is responsible for gathering data from this plugin for further processing.
Important! ActionsRecorder
is an experimental feature, and may become deprecated.
By default, plugin stores latest 1000 action entries. Integrator can register an onError
callback to collect those entries
in case of exception. Integrator should augment this data with application specific data such as page-id or session-id,
depending on the application. Augmented data should be processed by the integrator, for example integrator should send it
to some data collecting endpoint for later analysis.
Example:
ClassicEditor
.create( editorElement, {
plugins: [ ActionsRecorder, ... ],
actionsRecorder: {
maxEntries: 1000, // This is the default value and could be adjusted.
onError( error, entries ) {
console.error( 'ActionsRecorder - Error detected:', error );
console.warn( 'Actions recorded before error:', entries );
this.flushEntries();
// Integrator should send and store the entries. The error is already in the last entry in serializable form.
}
}
} )
.then( ... )
.catch( ... );
Alternatively integrator could continuously collect actions in batches and send them to theirs endpoint for later analysis:
ClassicEditor
.create( editorElement, {
plugins: [ ActionsRecorder, ... ],
actionsRecorder: {
maxEntries: 50, // This is the batch size.
onMaxEntries() {
const entries = this.getEntries();
this.flushEntries();
console.log( 'ActionsRecorder - Batch of entries:', entries );
// Integrator should send and store the entries.
},
onError( error, entries ) {
console.error( 'ActionsRecorder - Error detected:', error );
console.warn( 'Actions recorded before error:', entries );
this.flushEntries();
// Integrator should send and store the entries. The error is already in the last entry in serializable form.
}
}
} )
.then( ... )
.catch( ... );
See plugin configuration for more details.
Properties
-
module:watchdog/actionsrecorder~ActionsRecorder#editor
The editor instance.
-
_entries : Array<ActionsRecorderEntry>
privatemodule:watchdog/actionsrecorder~ActionsRecorder#_entries
Array storing all recorded action entries with their context and state snapshots.
-
_errorCallback : ActionsRecorderErrorCallback | undefined
privatemodule:watchdog/actionsrecorder~ActionsRecorder#_errorCallback
Error callback.
-
_errors : Set<Error>
privatemodule:watchdog/actionsrecorder~ActionsRecorder#_errors
Set of already reported errors used to notify only once for each error (not on every try-catch nested block).
-
_filterCallback : ActionsRecorderFilterCallback | undefined
privatemodule:watchdog/actionsrecorder~ActionsRecorder#_filterCallback
Filter function to determine which entries should be stored.
-
_frameStack : Array<ActionsRecorderEntry>
privatemodule:watchdog/actionsrecorder~ActionsRecorder#_frameStack
Stack tracking nested action frames to maintain call hierarchy.
-
_maxEntries : number
privatemodule:watchdog/actionsrecorder~ActionsRecorder#_maxEntries
Maximum number of action entries to keep in memory.
-
module:watchdog/actionsrecorder~ActionsRecorder#_maxEntriesCallback
Callback triggered every time count of recorded entries reaches maxEntries.
Static properties
-
isOfficialPlugin : true
readonlystaticmodule:watchdog/actionsrecorder~ActionsRecorder.isOfficialPlugin
-
pluginName : 'ActionsRecorder'
readonlystaticmodule:watchdog/actionsrecorder~ActionsRecorder.pluginName
Methods
-
constructor( editor )
module:watchdog/actionsrecorder~ActionsRecorder#constructor
-
flushEntries() → void
module:watchdog/actionsrecorder~ActionsRecorder#flushEntries
-
getEntries() → Array<ActionsRecorderEntry>
module:watchdog/actionsrecorder~ActionsRecorder#getEntries
-
module:watchdog/actionsrecorder~ActionsRecorder#_buildStateSnapshot
Builds a snapshot of the current editor state including document version, read-only status, focus state, and model selection.
Returns
ActionsRecorderEntryEditorSnapshot
An object containing the current editor state snapshot.
-
_callErrorCallback( [ error ] ) → void
privatemodule:watchdog/actionsrecorder~ActionsRecorder#_callErrorCallback
-
_enterFrame( action, [ params ] ) → ActionsRecorderEntry
privatemodule:watchdog/actionsrecorder~ActionsRecorder#_enterFrame
Creates a new action frame and adds it to the recording stack.
Parameters
action : string
The name/type of the action being recorded.
[ params ] : Array<unknown>
Optional parameters associated with the event.
Returns
ActionsRecorderEntry
The created call frame object.
-
_leaveFrame( callFrame, [ result ], [ error ] ) → void
privatemodule:watchdog/actionsrecorder~ActionsRecorder#_leaveFrame
Closes an action frame and records its final state and results.
Parameters
callFrame : ActionsRecorderEntry
The call frame to close.
[ result ] : any
Optional result value from the action.
[ error ] : any
Optional error that occurred during the action.
Returns
void
-
_maxEntriesDefaultHandler() → void
privatemodule:watchdog/actionsrecorder~ActionsRecorder#_maxEntriesDefaultHandler
-
_tapCommand( commandName, command ) → void
privatemodule:watchdog/actionsrecorder~ActionsRecorder#_tapCommand
Sets up recording for a specific command execution.
Parameters
commandName : string
The name of the command to record.
command : Command
The command instance to tap into.
Returns
void
-
_tapCommands() → void
privatemodule:watchdog/actionsrecorder~ActionsRecorder#_tapCommands
Sets up recording for all editor commands, both existing and future ones. Taps into the command execution to track when commands are run.
Returns
void
-
_tapComponentFactory() → void
privatemodule:watchdog/actionsrecorder~ActionsRecorder#_tapComponentFactory
Sets up recording for UI component factory creation and component interactions. Tracks when components are created and their execute events.
Returns
void
-
_tapFireMethod( emitter, eventNames, context ) → void
privatemodule:watchdog/actionsrecorder~ActionsRecorder#_tapFireMethod
Sets up recording for specific events fired by an emitter object.
Parameters
emitter : any
The object that fires events to be recorded.
eventNames : Array<string>
Array of event names to record.
context : Record<string, any>
Additional context to include with recorded events.
Defaults to
{}
Returns
void
-
_tapModelMethods() → void
privatemodule:watchdog/actionsrecorder~ActionsRecorder#_tapModelMethods
Sets up recording for key model methods like insertContent, insertObject, and deleteContent. These methods represent high-level model manipulation operations.
Returns
void
-
_tapModelSelection() → void
privatemodule:watchdog/actionsrecorder~ActionsRecorder#_tapModelSelection
Sets up recording for model selection changes. Tracks when the selection range, attributes, or markers change.
Returns
void
-
_tapOperationApply() → void
privatemodule:watchdog/actionsrecorder~ActionsRecorder#_tapOperationApply
Sets up recording for model operation applications. Tracks when operations are applied to the model document.
Returns
void
-
_tapViewDocumentEvents() → void
privatemodule:watchdog/actionsrecorder~ActionsRecorder#_tapViewDocumentEvents
Sets up recording for view document events like clicks, keyboard input, selection changes, and other user interactions.
Returns
void