# ActionsRecorder

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:

```typescript
ClassicEditor
		.create( {
			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:

```typescript
ClassicEditor
		.create( {
			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](module_watchdog_actionsrecorderconfig-ActionsRecorderConfig.md) for more details.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-watchdog/src/actionsrecorder.ts#L103)

<a id="properties">

## Properties

<a id="member-editor">

### `editor: Editor` _(readonly)_

The editor instance.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-watchdog/src/actionsrecorder.ts#L107)

<a id="member-_entries">

### `_entries: Array<ActionsRecorderEntry>` _(private)_

Array storing all recorded action entries with their context and state snapshots.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-watchdog/src/actionsrecorder.ts#L112)

<a id="member-_errorCallback">

### `_errorCallback?: ActionsRecorderErrorCallback` _(private)_

Error callback.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-watchdog/src/actionsrecorder.ts#L132)

<a id="member-_errors">

### `_errors: Set<Error>` _(private)_

Set of already reported errors used to notify only once for each error (not on every try-catch nested block).

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-watchdog/src/actionsrecorder.ts#L122)

<a id="member-_filterCallback">

### `_filterCallback?: ActionsRecorderFilterCallback` _(private)_

Filter function to determine which entries should be stored.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-watchdog/src/actionsrecorder.ts#L137)

<a id="member-_frameStack">

### `_frameStack: Array<ActionsRecorderEntry>` _(private)_

Stack tracking nested action frames to maintain call hierarchy.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-watchdog/src/actionsrecorder.ts#L117)

<a id="member-_maxEntries">

### `_maxEntries: number` _(private)_

Maximum number of action entries to keep in memory.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-watchdog/src/actionsrecorder.ts#L127)

<a id="member-_maxEntriesCallback">

### `_maxEntriesCallback: ActionsRecorderMaxEntriesCallback` _(private)_

Callback triggered every time count of recorded entries reaches maxEntries.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-watchdog/src/actionsrecorder.ts#L142)

#### Static properties

<a id="static-member-isOfficialPlugin">

### `isOfficialPlugin: true` _(readonly)_

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-watchdog/src/actionsrecorder.ts#L154)

<a id="static-member-pluginName">

### `pluginName: 'ActionsRecorder'` _(readonly)_

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-watchdog/src/actionsrecorder.ts#L147)

<a id="methods">

## Methods

<a id="function-constructor">

### `constructor( editor )`

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-watchdog/src/actionsrecorder.ts#L161)

#### Parameters

* `editor: Editor`

<a id="function-flushEntries">

### `flushEntries() → void`

Flushes all recorded entries.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-watchdog/src/actionsrecorder.ts#L192)

#### Returns

* `void`

<a id="function-getEntries">

### `getEntries() → Array<ActionsRecorderEntry>`

Returns all recorded action entries.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-watchdog/src/actionsrecorder.ts#L184)

#### Returns

* `Array<ActionsRecorderEntry>`

<a id="function-_buildStateSnapshot">

### `_buildStateSnapshot() → ActionsRecorderEntryEditorSnapshot` _(private)_

Builds a snapshot of the current editor state including document version, read-only status, focus state, and model selection.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-watchdog/src/actionsrecorder.ts#L269)

#### Returns

* `ActionsRecorderEntryEditorSnapshot`

  An object containing the current editor state snapshot.

<a id="function-_callErrorCallback">

### `_callErrorCallback( error? ) → void` _(private)_

Triggers error callback.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-watchdog/src/actionsrecorder.ts#L486)

#### Parameters

* `error?: any`

#### Returns

* `void`

<a id="function-_enterFrame">

### `_enterFrame( action, params? ) → ActionsRecorderEntry` _(private)_

Creates a new action frame and adds it to the recording stack.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-watchdog/src/actionsrecorder.ts#L203)

#### 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.

<a id="function-_leaveFrame">

### `_leaveFrame( callFrame, result?, error? ) → void` _(private)_

Closes an action frame and records its final state and results.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-watchdog/src/actionsrecorder.ts#L230)

#### 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`

<a id="function-_maxEntriesDefaultHandler">

### `_maxEntriesDefaultHandler() → void` _(private)_

The default handler for maxEntries callback.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-watchdog/src/actionsrecorder.ts#L505)

#### Returns

* `void`

<a id="function-_tapCommand">

### `_tapCommand( commandName, command ) → void` _(private)_

Sets up recording for a specific command execution.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-watchdog/src/actionsrecorder.ts#L365)

#### Parameters

* `commandName: string`

  The name of the command to record.

* `command: Command`

  The command instance to tap into.

#### Returns

* `void`

<a id="function-_tapCommands">

### `_tapCommands() → void` _(private)_

Sets up recording for all editor commands, both existing and future ones. Taps into the command execution to track when commands are run.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-watchdog/src/actionsrecorder.ts#L284)

#### Returns

* `void`

<a id="function-_tapComponentFactory">

### `_tapComponentFactory() → void` _(private)_

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

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-watchdog/src/actionsrecorder.ts#L385)

#### Returns

* `void`

<a id="function-_tapFireMethod">

### `_tapFireMethod( emitter, eventNames, context ) → void` _(private)_

Sets up recording for specific events fired by an emitter object.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-watchdog/src/actionsrecorder.ts#L461)

#### 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`

<a id="function-_tapModelMethods">

### `_tapModelMethods() → void` _(private)_

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

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-watchdog/src/actionsrecorder.ts#L329)

#### Returns

* `void`

<a id="function-_tapModelSelection">

### `_tapModelSelection() → void` _(private)_

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

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-watchdog/src/actionsrecorder.ts#L351)

#### Returns

* `void`

<a id="function-_tapOperationApply">

### `_tapOperationApply() → void` _(private)_

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

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-watchdog/src/actionsrecorder.ts#L304)

#### Returns

* `void`

<a id="function-_tapViewDocumentEvents">

### `_tapViewDocumentEvents() → void` _(private)_

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

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-watchdog/src/actionsrecorder.ts#L423)

#### Returns

* `void`

---

Full index of the CKEditor 5 API reference: [llms.txt](llms.txt)
