what-works-global

activity log

by what-works-global
payload-packages
Logging & monitoring
v3
>=3.27.0 <4

Overview

Summary generated from the README

Records who did what and when across collections and globals, including creates, updates, trashes, restores, deletes, logins and logouts. Entries link to the version a change produced instead of storing full document snapshots. Registered as a plugin, it adds an append-only Activity Log collection to the admin panel and requires Payload 3.27 or newer.

Features

  • Logs create, update, trash, restore and delete events plus user logins and logouts
  • Stores document titles and user labels at event time so they survive deletion
  • Links each entry to the version diff and records changed field names without values
  • Configurable snapshot modes for permanent deletes and unversioned entities
  • Optional IP address and request host tracking
  • Optional retention pruning of old entries

Use cases

  • Review a site-wide feed of editorial changes made by content team members
  • Recover data from a permanently deleted document using its stored snapshot
  • Attribute activity across multi-tenant or multi-domain deployments for compliance review

From the author

Payload plugin that records a chronological activity feed — document creates, updates, deletes, and user logins/logouts — with links to the affected document and version instead of full data snapshots.

Installation

npm i @whatworks/payload-activity-log

16

Stars

1

Forks

2

Open Issues

3 days ago

Last Updated

185

Weekly Downloads

v0.3.0

npm Version

160.0 KB

Unpacked Size

0

Dependencies

Repository stars

16+1 since Sep 7

Show data
Repository stars by day (UTC)
DateStars
Dec 6, 202616
Dec 5, 202616
Dec 4, 202616
Dec 3, 202616
Dec 2, 202616
Dec 1, 202616
Nov 30, 202616
Nov 29, 202616
Nov 28, 202616
Nov 27, 202616
Nov 26, 202616
Nov 25, 202616
Nov 24, 202616
Nov 23, 202616
Nov 22, 202616
Nov 21, 202616
Nov 20, 202616
Nov 19, 202616
Nov 18, 202616
Nov 17, 202615
Nov 16, 202615
Nov 15, 202615
Nov 14, 202615
Nov 13, 202615
Nov 12, 202615
Nov 11, 202615
Nov 10, 202615
Nov 9, 202615
Nov 8, 202615
Nov 7, 202615
Nov 6, 202615
Nov 5, 202615
Nov 4, 202615
Nov 3, 202615
Nov 2, 202615
Nov 1, 202615
Oct 31, 202615
Oct 30, 202615
Oct 29, 202615
Oct 28, 202615
Oct 27, 202615
Oct 26, 202615
Oct 25, 202615
Oct 24, 202615
Oct 23, 202615
Oct 22, 202615
Oct 21, 202615
Oct 20, 202615
Oct 19, 202615
Oct 18, 202615
Oct 17, 202615
Oct 16, 202615
Oct 15, 202615
Oct 14, 202615
Oct 13, 202615
Oct 12, 202615
Oct 11, 202615
Oct 10, 202615
Oct 9, 202615
Oct 8, 202615
Oct 7, 202615
Oct 6, 202615
Oct 5, 202615
Oct 4, 202615
Oct 3, 202615
Oct 2, 202615
Oct 1, 202615
Sep 30, 202615
Sep 29, 202615
Sep 28, 202615
Sep 27, 202615
Sep 26, 202615
Sep 25, 202615
Sep 24, 202615
Sep 23, 202615
Sep 22, 202615
Sep 21, 202615
Sep 20, 202615
Sep 19, 202615
Sep 18, 202615
Sep 17, 202615
Sep 16, 202615
Sep 15, 202615
Sep 14, 202615
Sep 13, 202615
Sep 12, 202615
Sep 11, 202615
Sep 10, 202615
Sep 9, 202615
Sep 8, 202615
Sep 7, 202615

Shared by 12 plugins in what-works-global/payload-packages.

npm weekly downloads

222+135 since Sep 7

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 6, 2026222
Dec 5, 2026267
Dec 4, 2026302
Dec 3, 2026270
Dec 2, 2026279
Dec 1, 2026309
Nov 30, 2026308
Nov 29, 2026263
Nov 28, 2026211
Nov 27, 2026179
Nov 26, 2026198
Nov 25, 2026207
Nov 24, 2026220
Nov 23, 2026220
Nov 22, 2026249
Nov 21, 2026254
Nov 20, 2026344
Nov 19, 2026313
Nov 18, 2026380
Nov 17, 2026340
Nov 16, 2026348
Nov 15, 2026358
Nov 14, 2026386
Nov 13, 2026326
Nov 12, 2026303
Nov 11, 2026258
Nov 10, 2026291
Nov 9, 2026296
Nov 8, 2026268
Nov 7, 2026243
Nov 6, 2026208
Nov 5, 2026205
Nov 4, 2026197
Nov 3, 2026167
Nov 2, 2026155
Nov 1, 2026143
Oct 31, 2026130
Oct 30, 2026125
Oct 29, 202697
Oct 28, 202631
Oct 27, 202629
Oct 26, 202628
Oct 25, 202640
Oct 24, 202634
Oct 23, 202623
Oct 22, 202638
Oct 21, 202646
Oct 20, 202643
Oct 19, 202642
Oct 18, 202640
Oct 17, 202686
Oct 16, 202689
Oct 15, 202695
Oct 14, 2026113
Oct 13, 2026110
Oct 12, 2026110
Oct 11, 2026123
Oct 10, 202685
Oct 9, 2026103
Oct 8, 202694
Oct 7, 202672
Oct 6, 202676
Oct 5, 202676
Oct 4, 202651
Oct 3, 202653
Oct 2, 202632
Oct 1, 202631
Sep 30, 202630
Sep 29, 202627
Sep 28, 202627
Sep 27, 202628
Sep 26, 202622
Sep 25, 202623
Sep 24, 202618
Sep 23, 202625
Sep 22, 202625
Sep 21, 202629
Sep 20, 202629
Sep 19, 202628
Sep 18, 202629
Sep 17, 202625
Sep 16, 202636
Sep 15, 202665
Sep 14, 202661
Sep 13, 202681
Sep 12, 202681
Sep 11, 202681
Sep 10, 2026118
Sep 9, 202698
Sep 8, 202685
Sep 7, 202687

Each point is npm's rolling 7-day download count.

Health Score

62/100Good

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/1064440892-activity-log.svg)](https://payloaddirectory.dev/plugins/1064440892-activity-log)
HTML
<a href="https://payloaddirectory.dev/plugins/1064440892-activity-log"><img src="https://payloaddirectory.dev/badge/1064440892-activity-log.svg" alt="Payload Directory"></a>
Updated Dec 2, 2026Created Sep 26, 2025Published Jul 21, 2026

README

@whatworks/payload-activity-log

Activity Log

 

Payload plugin that records a chronological activity feed for your whole CMS — who did what, when, across every collection and global. Think WordPress's Simple History, for Payload.

  • Logs document creates, updates, trashes, restores, and deletes, plus user logins and logouts (opt-out, not opt-in).
  • Shows document titles and user emails, not IDs — both captured at event time, so they survive deletion.
  • No full-document snapshots by default. Each entry links to the version the change produced (when versions are enabled) instead of duplicating document data. Only permanent deletes store a snapshot — the one moment the data would otherwise be lost, since Payload deletes a document's versions with it.
  • Records the changed field names on updates ("title, content") without storing values.
  • Supports multiple auth collections — actors are stored as a polymorphic reference plus a label.
  • Composes with @whatworks/payload-audit-fields: reuses its resolveUserLabel automatically so both plugins display users identically, and keeps its attribution fields out of the changed-fields noise.

Demo

Activity Log collection

Activity Log entry

Installation

pnpm add @whatworks/payload-activity-log

Usage

import { activityLogPlugin } from '@whatworks/payload-activity-log'
import { buildConfig } from 'payload'

export default buildConfig({
  // ...
  plugins: [
    // Register last so collections added by other plugins are logged too.
    activityLogPlugin(),
  ],
})

Then regenerate the import map so the admin panel can resolve the plugin's components:

payload generate:importmap

An Activity Log collection appears in the admin panel: a reverse-chronological feed with linked users, linked documents, the operation, and a link to the version diff for each change.

Options

activityLogPlugin({
  // Which collections to log. Defaults to all (the log collection itself is
  // always excluded).
  // - true — every collection (default)
  // - ['posts', 'pages'] — only these
  // - { exclude: ['redirects'] } — all except these
  collections: { exclude: ['redirects'] },

  // Which globals to log. Same semantics. Defaults to all.
  globals: true,

  // Per-event toggles (all default true except autosave).
  events: {
    create: true,
    update: true,
    trash: true, // moving to the trash (collections with trash: true)
    restore: true, // restoring from the trash
    delete: true, // permanent deletion
    login: true,
    logout: true,
    autosave: false, // default false — autosaves fire every few seconds while editing
  },

  // When to store a full JSON snapshot of the affected document, configured
  // separately for collections and globals. A snapshot is a fallback for the
  // version link — worth storing only when a durable version won't be there to
  // recover the data from. Each scope takes a single mode, or { default, overrides }
  // to tune individual slugs.
  //   'never'    — never store document data.
  //   'delete'   — (collections only) on permanent delete, the sole surviving record.
  //   'fallback' — on delete, plus every change to an entity with NO versions
  //                enabled; versioned entities rely on the version link instead.
  //   'always'   — on every change (watch your database size).
  // Defaults: collections 'delete', globals 'never'.
  snapshot: {
    collections: 'delete',
    globals: { default: 'never', overrides: { 'site-settings': 'always' } },
  },

  // Opt-in IP address tracking. When enabled, an `ipAddress` field is added to
  // the log collection and every entry stores the requester's address.
  // `true` reads the standard reverse-proxy headers (`cf-connecting-ip` →
  // `x-real-ip` → first `x-forwarded-for` entry); pass a function to resolve it
  // yourself when your proxy chain makes those untrustworthy. IP addresses are
  // personal data under most privacy regimes — consider pairing with `retention`.
  ipAddress: false,

  // Opt-in request host tracking. When enabled, a `requestHost` field is added
  // to the log collection and every entry stores the host the request was
  // addressed to. `true` reads the standard headers (`x-forwarded-host` →
  // `host`); pass a function to resolve it yourself when your proxy chain makes
  // those untrustworthy. Handy for multi-tenant / multi-domain deployments.
  requestHost: false,

  // Delete entries older than this. Off by default — nothing is pruned unless
  // you opt in. Pruning runs after log writes, at most once per hour.
  retention: { maxAgeDays: 90 },

  // Slug of the log collection. Default 'activity-log'.
  collectionSlug: 'activity-log',

  // Escape hatch for the generated collection — access control, labels, admin
  // options, extra fields.
  collectionOverride: (collection) => ({
    ...collection,
    access: { ...collection.access, read: ({ req }) => req.user?.role === 'admin' },
  }),

  // Auth collections whose users can appear as actors (and whose logins/logouts
  // are logged). Defaults to every auth-enabled collection in your config.
  userCollections: ['users'],

  // Custom actor resolution, e.g. attribute job/webhook writes to a bot user.
  // Return null/undefined to skip logging that event.
  resolveUser: ({ req }) =>
    req.user ? { relationTo: req.user.collection, value: req.user.id } : null,

  // Label stored for the acting user at event time. May be async.
  // Defaults to email → username → ID, or to audit-fields' resolveUserLabel
  // when that plugin is registered.
  resolveUserLabel: ({ user }) => user.email as string,

  // Title stored for the affected document at event time. May be async.
  // Defaults to the collection's useAsTitle value → title → name → email →
  // username → ID; for globals, the global's label.
  resolveDocumentLabel: ({ doc }) => doc.title as string,
})

Behaviour

  • Actors. Events are attributed to req.user. Writes without a user (seeds, migrations, job runners, local API calls without user) are not logged — pass resolveUser to attribute them to a dedicated system user instead.
  • What each entry stores. The actor (polymorphic reference + label), the operation, the affected collection/global and document ID, the document's title, the ID of the version the change produced (entities with versions), and the changed field names (updates). Labels and titles are captured at event time, so the feed stays readable after users or documents are deleted — at the cost of not reflecting later renames.
  • Trash. On collections with trash: true, moving to the trash logs trash (linked to the document under the trash route), restoring logs restore, and emptying the trash logs delete with a snapshot. Payload introduced trash in 3.49 — on older versions within the supported peer range these events simply never occur (there is no trash), and everything else works as described.
  • Autosave. Skipped by default; manual draft saves and publishes are logged. Set events.autosave: true to log every autosave.
  • IP addresses. Nothing is stored unless you opt in with ipAddress. When enabled, every entry (all operations, not just logins) records the requesting client's address; resolution failures simply leave it unset. Which proxy headers can be trusted depends on your deployment — pass a resolver function if the defaults pick up spoofable values.
  • Request host. Nothing is stored unless you opt in with requestHost. When enabled, every entry records the host the request was addressed to (x-forwarded-host → host by default), which is useful for attributing activity across multi-tenant or multi-domain deployments. As with ipAddress, resolution failures leave it unset and forwarded headers are only as trustworthy as your proxy chain — pass a resolver function if the defaults pick up spoofable values.
  • The log is append-only. All mutating access on the log collection is disabled; entries are written exclusively by the plugin's hooks. Reads default to any authenticated user — tighten via collectionOverride. Note that stored labels/titles are visible to anyone who can read the log, regardless of their access to the source documents.
  • Log writes never break the operation that caused them: failures are logged and swallowed. Entries are written on the operation's request, so they commit and roll back with it.
  • The plugin does not touch Payload's internal collections (they are created after plugins run).

Payload saves a change's version before afterChange hooks run, so each log entry can record the ID of the exact version its change produced. The Version column links straight to that version's diff view. For entities without versions the column shows —, and the entry's changed-field names still tell you what was touched.

Cells only link to destinations that still resolve: once a document is permanently deleted (its versions are deleted with it) the version cell shows a muted "Document deleted" and the document cell shows the stored title without a link; a version pruned by versions.maxPerDoc shows —. The actor gets the same treatment — a deleted user's label loses its link (in the list and on the entry view). Documents and users sitting in the trash link under the trash route. The existence checks are batched per render pass — one query per collection for a whole page of rows, not one per cell — and the actor checks share the same batch.

Snapshots

A snapshot is a full JSON copy of the affected document, stored on the log entry. It's a fallback for the version link — the plugin prefers to link to the version a change produced rather than duplicate data, and only stores a snapshot when a durable version won't be there to recover from. There are exactly two such cases: a permanent delete (Payload deletes a document's versions with it) and an entity with no versions enabled (there's no version to link to).

The four modes form a ladder from least to most stored — never < delete < fallback < always — set per scope:

modeon change (create/update/trash/restore)on permanent delete
never——
delete—snapshot
fallbacksnapshot iff the entity has no versionssnapshot
alwayssnapshotsnapshot
  • Collections default to 'delete' — the version link carries normal change history; the snapshot only fills the one gap deletes leave.
  • Globals default to 'never' — globals can't be deleted, so there's no delete gap to fill, and versioned globals are already covered by the version link. Opt individual globals in with 'fallback' (unversioned globals) or 'always', e.g. globals: { default: 'never', overrides: { 'site-settings': 'always' } }. 'delete' is not a valid global mode.
  • Snapshotting is independent of logging: a global set to 'never' is still logged (actor, changed fields, version link) — it just stores no JSON copy.

Using with @whatworks/payload-audit-fields

The two plugins are independent but designed to compose. Register both (order doesn't matter):

plugins: [auditFieldsPlugin(), activityLogPlugin()]
  • Audit fields answer "who touched this document" on the document itself and per-version; the activity log answers "what happened across the site", including deletes and logins that per-document views can't show.
  • The activity log reuses audit-fields' resolveUserLabel (unless you pass its own), so users display identically everywhere.
  • Audit-fields' createdBy/lastModifiedBy are excluded from changedFields.

Differences from @payload-bites/activity-log

This plugin is a rethink rather than a drop-in replacement (field names and stored shapes differ):

  • Logging is opt-out (all collections/globals by default) instead of a required opt-in map.
  • No data json copy of the whole document on every change — entries link to the version diff instead; snapshots only on permanent delete (configurable).
  • The feed shows document titles and user emails, not raw IDs, and they survive deletion.
  • Actors can belong to any auth collection, not only the admin user collection.
  • Local API writes are logged whenever a user is attached (or resolveUser returns one) — instead of being skipped wholesale.
  • Adds trash/restore classification, changed-field names, logins/logouts, and optional retention pruning.
  • Autosave logging defaults off (was on).
  • Read logging is not supported.

Similar plugins