strapi-plugin-timeline
v0.0.8
Published
Content history and version control plugin for Strapi 5. Track changes, browse history, compare diffs, and restore previous versions.
Maintainers
Readme
Strapi Timeline Plugin
A content history and version control plugin for Strapi 5. Automatically tracks changes to your content entries and lets you browse, compare, and restore previous versions — all from within the Strapi admin panel.
Package Moved
The package has moved from strapi-plugin-timeline to @xbstracts/strapi-plugin-timeline. Please use the new package name for future installs and updates.
Features
- Automatic Change Tracking — Records snapshots on create, update, delete, and publish actions via lifecycle hooks. No manual work required.
- Per-Content-Type Configuration — Choose which content types to track, which actions to log, and set retention limits independently for each.
- Full Snapshot Storage — Each timeline entry stores the complete content payload and the content type schema at that point in time.
- Restore with Diff Preview — Before restoring, see a side-by-side comparison of what will change. One-click restore reverts the entry and logs a "restore" action.
- Homepage Dashboard — Filterable, sortable, paginated table of all timeline entries across content types, users, locales, actions, and date ranges.
- CM Edit View Panel — A sidebar panel in the content manager showing the history of the document you're editing, grouped by date.
- Locale Aware — Tracks i18n locale per entry. Filter by locale. Restores respect locale context.
- Scheduled Cleanup — Configure a cron job to automatically remove entries older than a retention duration (hours, days, weeks, or months).
- Entries Limit — Set a maximum number of entries per content type. Oldest entries are automatically pruned (FIFO).
- Role-Based Permissions — Separate permissions for read, edit, delete, and schedule actions via Strapi's RBAC system.
- User Attribution — Captures the admin user who performed each action, with links to user profiles.
- Schema Migration — Automatically migrates from legacy configuration format.
Requirements
- Strapi v5.x (
>=5.0.0 <6.0.0) - Node.js 18+
Installation
npm install strapi-plugin-timelineOr with yarn:
yarn add strapi-plugin-timelineEnable the Plugin
Add it to your Strapi plugin configuration:
// config/plugins.ts
export default () => ({
timeline: {
enabled: true,
},
});Then rebuild and restart your Strapi application.
Configuration
All configuration is done through the Strapi Admin Panel — no code changes needed.
Settings Page
Navigate to Settings → Timeline in the admin panel to:
- Add content types to track from a dropdown of all available API content types.
- Configure each content type independently:
- Enable/Disable — Toggle tracking on or off.
- Tracked Actions — Select which actions to log:
create,update,delete,publish. Leave empty to track all. - Entries Limit — Maximum entries to keep (0 = unlimited). When exceeded, oldest entries are removed automatically.
- Retention Duration — How long to keep entries before scheduled cleanup removes them. Set the value and unit (hours, days, weeks, months).
- Remove content types — Stop tracking and optionally clean up existing entries.
Scheduled Cleanup
Navigate to Settings → Timeline → Schedule to:
- Enable/Disable automatic cleanup.
- Set the cron expression (default:
0 * * * *— every hour). - Run cleanup manually with the "Run Now" button.
- View last cleanup results including per-content-type deletion counts.
Note: Changes to the cron schedule require a server restart to take effect.
Usage
Homepage
The Timeline homepage (/plugins/timeline) shows a paginated table of all tracked changes. You can:
- Filter by content type, user, action, locale, date range, or document ID.
- Sort by action, content type, user, or date.
- View — Click the eye icon to open a detail modal showing the full snapshot with formatted content (rich text, blocks, relations, media).
- Restore — Click the restore icon to open a diff preview, then confirm to revert the entry to that snapshot.
- Clean — Bulk delete timeline entries by content type.
Content Manager Panel
When editing any tracked content entry, a Timeline panel appears in the sidebar showing:
- Recent changes to this specific document, grouped by date.
- A date picker to browse changes on a specific day.
- Quick view and restore buttons for each entry.
Restore
When you restore a snapshot:
- A diff table shows which fields will change, comparing current values against the snapshot.
- The plugin performs the restore server-side in a single operation.
- A "restore" action is logged in the timeline.
- The entries limit is enforced after the restore.
- The lifecycle
afterUpdatehook is suppressed during restore to avoid a duplicate "update" entry.
Tracked Actions
| Action | Description |
|--------|-------------|
| create | A new entry was created |
| update | An existing draft/entry was modified |
| publish | Content was published |
| delete | An entry was deleted |
| restore | An entry was reverted to a previous snapshot |
| clean | Timeline entries were manually bulk-deleted |
Permissions
The plugin registers its own permissions under Settings → Roles:
| Permission | Description |
|------------|-------------|
| plugin::timeline.read | View timeline entries and history |
| plugin::timeline.edit | Restore entries and modify settings |
| plugin::timeline.delete | Delete / clean timeline entries |
| plugin::timeline.schedule.run | Execute scheduled cleanup |
API Endpoints
All endpoints are admin-only and require authentication.
| Method | Endpoint | Description |
|--------|----------|-------------|
| GET | /timeline/settings | Get plugin settings |
| PUT | /timeline/settings | Update plugin settings |
| GET | /timeline/content-types | List available content types |
| GET | /timeline/entries | Query timeline entries (with filters, pagination, sorting) |
| GET | /timeline/entries/users | Get distinct users |
| GET | /timeline/entries/locales | Get distinct locales |
| GET | /timeline/entries/:contentType/:entryDocumentId | Get history for a specific document |
| POST | /timeline/entries/snapshot-before-restore | Restore an entry to a previous snapshot |
| POST | /timeline/entries/clean | Delete entries for selected content types |
| DELETE | /timeline/entries | Delete all timeline entries |
| GET | /timeline/schedule | Get cleanup schedule status |
| PUT | /timeline/schedule | Update cleanup schedule |
| POST | /timeline/schedule/run | Run cleanup now |
How It Works
The plugin subscribes to Strapi's database lifecycle events (afterCreate, afterUpdate, beforeDelete) at the global level. On each event:
- Checks if the content type is tracked and the action is enabled in settings.
- Extracts the admin user from the request context.
- Resolves relation fields to document IDs.
- Captures the content type schema (attributes, types, relations).
- Stores the full snapshot as a JSON timeline entry.
- Enforces the entries limit by removing the oldest entries if exceeded.
Snapshots are stored in the plugin's own timeline-entry collection type, hidden from the content manager.
License
MIT — Patiparnne Vongchompue
Support
If you find this plugin useful, consider supporting the development:
