# Data Change History

Canonical page: https://www.adaptabletools.com/docs/handbook-monitoring-data-change-history

- Data Change History Monitor displays a list of all changes to Grid data (either user or ticking)

The Data Change History Module gives users an overview of cell value changes in the current AdapTable session.

The **Data Changes Monitor** lists those changes (user edits and ticking data) and supports undo and row actions when you configure them.

This is not the same as [Data Change Alerts](https://www.adaptabletools.com/docs/handbook-alerting-data-change/index.md) (rules that fire when data changes) or [Listening to Data Changes](https://www.adaptabletools.com/docs/handbook-managing-grid-data-changed-events/index.md) (AG Grid / AdapTable change events in your app code). Data Change History is the in-product **log and monitor UI**.

### Configuring Data Change History

All five properties on [`DataChangeHistoryOptions`](https://www.adaptabletools.com/docs/reference/datachangehistoryoptions.md) are covered in the handbook:

| Property                                  | Purpose                                                                                                                                                       |
| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `activeByDefault`                         | Start with tracking **Active** instead of waiting for user activation                                                                                         |
| `showDataChange`                          | Filter which changes appear in the monitor                                                                                                                    |
| `showLastDataChangeOnly` | Show only the latest change per cell, or every change                                                                                                         |
| `maxDataChangesInStore`                   | Cap how many changes are kept in memory                                                                                                                       |
| `changeHistoryButton`                     | Buttons on each log row (undo, clear, custom) — see [Data Change History Buttons](https://www.adaptabletools.com/docs/handbook-monitoring-data-change-history-buttons/index.md) |

See [Configuring Data Change History](https://www.adaptabletools.com/docs/handbook-monitoring-data-change-history-configuring/index.md) for the first four properties and demos.

### Data Change Modes

Tracking is **off until activated** (unless you set `activeByDefault`). 

At run-time, [`DataChangeHistoryApi.getDataChangeHistoryMode`](https://www.adaptabletools.com/docs/reference/datachangehistoryapi.md#getdatachangehistorymode) returns one of:

- **ACTIVE** — changes are recorded from when tracking became active
- **SUSPENDED** — new changes are not recorded; existing log entries remain
- **INACTIVE** — new changes are not recorded and the in-memory log is cleared

Users switch mode from the Data Change History toolbar, tool panel, status bar, or Settings Panel (see below).

Set `activeByDefault` to _true_ in [Data Change History Options](https://www.adaptabletools.com/docs/technical-reference-monitoring-data-change-history/index.md) to start in **ACTIVE** mode when the grid loads.

**Example: Data Change History**

Seeing editing activity in Data Change History

- This grid mimics ticking data: every 2 seconds `github_stars` and `github_watchers` update (with [Flashing Cells](https://www.adaptabletools.com/docs/handbook-flashing-cell/index.md) active) and `updated_at` shows the current time
- `activeByDefault` is _true_ in `adaptableOptions.ts`, so changes are tracked from the start

- Click **Show** on the Data Change History toolbar to open the Data Changes Monitor
- Suspend or deactivate tracking and note the grid still ticks, but new edits no longer appear in the log
- Edit a column (for example `language` or `description`) and see *User Edit* in the `Source` column

Demo project (Vanilla); the files without a marker are shown below:

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  gridOptions.ts       [template]
  index.ts             [template]
  onAdaptableReady.ts
  rowData.ts           [template]
  styles.css           [template]
index.html             [template]
package.json           [template]
tsconfig.json          [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vanilla).

**`src/adaptableOptions.ts`**

```ts
import {AdaptableOptions, CellDataChangedInfo} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Data Change History Basic',
  dataChangeHistoryOptions: {
    activeByDefault: true,
  },
  initialState: {
    Dashboard: {
      Tabs: [
        {
          Name: 'Data Change',
          Toolbars: ['DataChangeHistory'],
        },
      ],
    },
    StatusBar: {
      StatusBars: [
        {
          Key: 'Center Panel',
          StatusBarPanels: ['DataChangeHistory'],
        },
      ],
    },
    Theme: {CurrentTheme: 'dark'},
    FormatColumn: {
      FormatColumns: [
        {
          Name: 'formatColumn-updated_at',
          Scope: {
            ColumnIds: ['updated_at'],
          },
          DisplayFormat: {
            Formatter: 'DateFormatter',
            Options: {
              Pattern: 'HH:mm:ss',
            },
          },
        },
      ],
    },
    FlashingCell: {
      FlashingCellDefinitions: [
        {
          Name: 'Flashing_Cell_Github',
          Scope: {
            ColumnIds: ['github_stars', 'github_watchers'],
          },
          Rule: 'ANY_CHANGE()',
        },
      ],
    },
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          Name: 'Standard Layout',
          TableColumns: [
            'name',
            'github_stars',
            'language',
            'github_watchers',
            'updated_at',
            'description',
            'created_at',
            'has_wiki',
            'pushed_at',
            'open_issues_count',
          ],
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```

**`src/onAdaptableReady.ts`**

```ts
import {AdaptableReadyInfo} from '@adaptabletools/adaptable';

export const onAdaptableReady = ({adaptableApi}: AdaptableReadyInfo) => {
  setInterval(() => {
    const node: any =
      adaptableApi.gridApi.getRowNodeForPrimaryKey(getRandomRowNode()); // not sure why not RowNode here?  think some mismatch...

    if (!node) {
      return;
    }
    const data: any = {...node.data};

    // Update the github_stars and github_watchers columns
    data.github_stars = data.github_stars + generateRandomInt(-3, 3);
    data.github_watchers = data.github_watchers + generateRandomInt(-2, 2);

    // Set Updated At to current date
    data.updated_at = Date.now();

    adaptableApi.gridApi.updateGridData([data]);
  }, 2000);
};

function generateRandomInt(minValue: number, maxValue: number): number {
  return Math.floor(Math.random() * (maxValue - minValue + 1) + minValue);
}

function getRandomRowNode(): number {
  const rowNodes = [
    10270250, 24195339, 11730342, 74293321, 224663696, 95797174, 76694515,
    1801829, 82095231, 130884470, 17814354, 167174,
  ];
  return rowNodes[generateRandomInt(0, rowNodes.length)];
}
```

## Using Data Change History

The Data Change History Monitor is designed to be used at run time.

### Opening Data Changes Monitor

Open the monitor ( **Show** ) from:

- Data Change History [Toolbar](https://www.adaptabletools.com/docs/ui-dashboard-tabs-toolbars/index.md) in the [Dashboard](https://www.adaptabletools.com/docs/ui-dashboard/index.md)
- Data Change History [Module Tool Panel](https://www.adaptabletools.com/docs/ui-tool-panel-module-tool-panels/index.md)
- Data Change History [Status Bar](https://www.adaptabletools.com/docs/ui-status-bar/index.md)
- Data Change History page in the [Settings Panel](https://www.adaptabletools.com/docs/ui-settings-panel/index.md)

### Setting Data Change History Mode

Change mode from the toolbar, tool panel, status bar, or Settings Panel.

Each control offers (labels depend on current mode):

- Suspend / Resume
- Activate / Deactivate
- Show

##  UI Entitlements

The [Entitlements](https://www.adaptabletools.com/docs/handbook-permissioning/index.md) for Data Change History are:

- `Full` — everything is available and visible
- `ReadOnly` — the monitor displays changes but cannot be activated, deactivated, or suspended
- `Hidden` — the monitor and related UI controls are hidden

### FAQ

**Can I see other information in the Change History Module other than cell changes?**
The monitor records cell value changes (user edits and ticking data). For other AdapTable activity, use the [Adaptable State Changed Event](https://www.adaptabletools.com/docs/dev-guide-adaptable-state-events/index.md).

**How is this different from Data Change Alerts?**
[Data Change Alerts](https://www.adaptabletools.com/docs/handbook-alerting-data-change/index.md) evaluate rules when data changes and can notify users or run workflows. Data Change History is a **session log** of cell edits with optional undo—not an alerting rule engine.
