Sign up (with export icon)

ActionsRecorder

Api-class icon class

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( ... );
Copy code

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( ... );
Copy code

See plugin configuration for more details.

Properties

Static properties

Methods

  • Chevron-right icon

    constructor( editor )

  • Chevron-right icon

    flushEntries() → void

    Flushes all recorded entries.

    Returns

    void
  • Chevron-right icon

    Returns all recorded action entries.

    Returns

    Array<ActionsRecorderEntry>
  • Chevron-right icon

    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.

  • Chevron-right icon

    _callErrorCallback( [ error ] ) → void
    Lock icon private

    Triggers error callback.

    Parameters

    [ error ] : any

    Returns

    void
  • Chevron-right icon

    _enterFrame( action, [ params ] ) → ActionsRecorderEntry
    Lock icon private

    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.

  • Chevron-right icon

    _leaveFrame( callFrame, [ result ], [ error ] ) → void
    Lock icon private

    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
  • Chevron-right icon

    _maxEntriesDefaultHandler() → void
    Lock icon private

    The default handler for maxEntries callback.

    Returns

    void
  • Chevron-right icon

    _tapCommand( commandName, command ) → void
    Lock icon private

    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
  • Chevron-right icon

    _tapCommands() → void
    Lock icon private

    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
  • Chevron-right icon

    _tapComponentFactory() → void
    Lock icon private

    Sets up recording for UI component factory creation and component interactions. Tracks when components are created and their execute events.

    Returns

    void
  • Chevron-right icon

    _tapFireMethod( emitter, eventNames, context ) → void
    Lock icon private

    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
  • Chevron-right icon

    _tapModelMethods() → void
    Lock icon private

    Sets up recording for key model methods like insertContent, insertObject, and deleteContent. These methods represent high-level model manipulation operations.

    Returns

    void
  • Chevron-right icon

    _tapModelSelection() → void
    Lock icon private

    Sets up recording for model selection changes. Tracks when the selection range, attributes, or markers change.

    Returns

    void
  • Chevron-right icon

    _tapOperationApply() → void
    Lock icon private

    Sets up recording for model operation applications. Tracks when operations are applied to the model document.

    Returns

    void
  • Chevron-right icon

    _tapViewDocumentEvents() → void
    Lock icon private

    Sets up recording for view document events like clicks, keyboard input, selection changes, and other user interactions.

    Returns

    void