shaadcode

payload auditor

by shaadcode
Logging & monitoring
v3
^3.76.1
MIT

Overview

Summary generated from the README

Payload Auditor records events from Payload collection and global hooks into an internal audit log collection. You choose which collections, hooks and operations to track, and can customize log output, collection config and access to logs. Logs can be buffered by size or time, and old logs can be cleaned up through the Payload Jobs system. It targets Payload 3 and has no external dependencies.

Features

  • Track collections and globals by slug with per-hook and per-operation toggles
  • Custom logger function to shape the log output for any hook or operation
  • Debug mode that prints logs to the console and can skip database saves
  • Buffered log flushing by size, time or real time
  • Automatic log cleanup scheduled with Payload Jobs and cron
  • Customize the built-in log collection through a config function

Use cases

  • Monitor critical changes such as user logins and document updates in a multi-user admin
  • Add an audit trail to a SaaS or enterprise product built on Payload
  • Limit log growth by cleaning up old entries on a schedule

From the author

Simple, fast and customizable plugin for payload cms

Installation

npm i payload-auditor

82

Stars

7

Forks

2

Open Issues

1 months ago

Last Updated

1.4k

Weekly Downloads

v2.0.3

npm Version

89.1 KB

Unpacked Size

0

Dependencies

GitHub stars

82+5 since Sep 6

Show data
GitHub stars by day (UTC)
DateStars
Dec 5, 202682
Dec 4, 202682
Dec 3, 202682
Dec 2, 202682
Dec 1, 202682
Nov 30, 202682
Nov 29, 202682
Nov 28, 202682
Nov 27, 202682
Nov 26, 202682
Nov 25, 202682
Nov 24, 202682
Nov 23, 202682
Nov 22, 202682
Nov 21, 202682
Nov 20, 202682
Nov 19, 202682
Nov 18, 202682
Nov 17, 202682
Nov 16, 202682
Nov 15, 202682
Nov 14, 202682
Nov 13, 202682
Nov 12, 202682
Nov 11, 202682
Nov 10, 202681
Nov 9, 202681
Nov 8, 202681
Nov 7, 202681
Nov 6, 202681
Nov 5, 202681
Nov 4, 202681
Nov 3, 202680
Nov 2, 202680
Nov 1, 202680
Oct 31, 202680
Oct 30, 202680
Oct 29, 202679
Oct 28, 202679
Oct 27, 202679
Oct 26, 202679
Oct 25, 202679
Oct 24, 202679
Oct 23, 202679
Oct 22, 202679
Oct 21, 202679
Oct 20, 202679
Oct 19, 202679
Oct 18, 202679
Oct 17, 202679
Oct 16, 202679
Oct 15, 202679
Oct 14, 202679
Oct 13, 202679
Oct 12, 202679
Oct 11, 202678
Oct 10, 202678
Oct 9, 202678
Oct 8, 202678
Oct 7, 202678
Oct 6, 202678
Oct 5, 202678
Oct 4, 202678
Oct 3, 202678
Oct 2, 202678
Oct 1, 202678
Sep 30, 202678
Sep 29, 202678
Sep 28, 202678
Sep 27, 202678
Sep 26, 202678
Sep 25, 202678
Sep 24, 202678
Sep 23, 202678
Sep 22, 202678
Sep 21, 202678
Sep 20, 202678
Sep 19, 202678
Sep 18, 202678
Sep 17, 202678
Sep 16, 202678
Sep 15, 202678
Sep 14, 202678
Sep 13, 202678
Sep 12, 202678
Sep 11, 202678
Sep 10, 202677
Sep 9, 202677
Sep 8, 202677
Sep 7, 202677
Sep 6, 202677
npm weekly downloads

1.5K+220 since Sep 6

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 5, 20261,496
Dec 4, 20261,527
Dec 3, 20261,339
Dec 2, 20261,266
Dec 1, 20261,264
Nov 30, 20261,287
Nov 29, 20261,486
Nov 28, 20261,374
Nov 27, 20261,363
Nov 26, 20261,522
Nov 25, 20261,820
Nov 24, 20261,823
Nov 23, 20261,859
Nov 22, 20261,709
Nov 21, 20261,800
Nov 20, 20261,915
Nov 19, 20261,870
Nov 18, 20261,733
Nov 17, 20261,748
Nov 16, 20261,701
Nov 15, 20261,626
Nov 14, 20261,629
Nov 13, 20261,490
Nov 12, 20261,529
Nov 11, 20261,410
Nov 10, 20261,466
Nov 9, 20261,446
Nov 8, 20261,443
Nov 7, 20261,438
Nov 6, 20261,571
Nov 5, 20261,621
Nov 4, 20261,792
Nov 3, 20261,710
Nov 2, 20261,761
Nov 1, 20261,775
Oct 31, 20261,727
Oct 30, 20261,756
Oct 29, 20261,341
Oct 28, 2026942
Oct 27, 2026952
Oct 26, 2026924
Oct 25, 20261,192
Oct 24, 20261,366
Oct 23, 2026977
Oct 22, 20261,377
Oct 21, 20261,753
Oct 20, 20261,820
Oct 19, 20261,899
Oct 18, 20262,759
Oct 17, 20262,709
Oct 16, 20262,980
Oct 15, 20262,857
Oct 14, 20262,809
Oct 13, 20262,779
Oct 12, 20262,793
Oct 11, 20261,963
Oct 10, 20261,807
Oct 9, 20261,849
Oct 8, 20262,000
Oct 7, 20261,919
Oct 6, 20261,911
Oct 5, 20261,795
Oct 4, 20261,458
Oct 3, 20261,554
Oct 2, 20261,630
Oct 1, 20261,544
Sep 30, 20261,658
Sep 29, 20261,633
Sep 28, 20261,620
Sep 27, 20261,663
Sep 26, 20261,660
Sep 25, 20261,452
Sep 24, 20261,372
Sep 23, 20261,337
Sep 22, 20261,363
Sep 21, 20261,384
Sep 20, 20261,386
Sep 19, 20261,419
Sep 18, 20261,469
Sep 17, 20261,439
Sep 16, 20261,265
Sep 15, 20261,231
Sep 14, 20261,228
Sep 13, 20261,179
Sep 12, 20261,033
Sep 11, 2026965
Sep 10, 2026941
Sep 9, 20261,095
Sep 8, 20261,196
Sep 7, 20261,205
Sep 6, 20261,276

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

Health Score

81/100Excellent

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/967626501-root.svg)](https://payloaddirectory.dev/plugins/967626501-root)
HTML
<a href="https://payloaddirectory.dev/plugins/967626501-root"><img src="https://payloaddirectory.dev/badge/967626501-root.svg" alt="Payload Directory"></a>
Updated Oct 26, 2026Created Apr 16, 2025Published Oct 26, 2026

README

Project Cover

NPM Version NPM Downloads NPM License NPM Last Update bundlephobia Zero Dependencies

📦 Payload Auditor

Payload Auditor is a powerful plugin for Payload CMS that provides centralized event tracking, auditing, and security enhancements. This tool is designed for developers and teams looking to monitor critical actions, analyze user behaviors, and enhance backend security within their Payload projects.

📊 Only ~2 kB (minified + gzipped) and has no external dependencies.

⚙️ Installation & Usage

Install with your preferred package manager:

npm install payload-auditor

# or

pnpm add payload-auditor

# or

yarn add payload-auditor

Then, register the plugin in your Payload config:

import { auditorPlugin } from 'payload-auditor'

export default buildConfig({
  plugins: [
    auditorPlugin({
      // your plugin config here
    }),
  ],
})

🔧 Plugin Options

The plugin is designed in a way that allows you to customize it deeply. Of course, the project is fully documented and you can use its documentation well during development.

Customize the plugin with the following configuration(for example):

auditorPlugin({
  automation: {
    logCleanup: {
       cronTime: '* * * * *', // every minute
       queueName: 'john-doe-queue',
    },
  },
  collection: {
    trackCollections: [
      {
        slug: "media",
        hooks: {
          afterChange: {
            update: {
              enabled: true,
            },
          },
        },
      },
    ],
  },
});

✨ Things you can customize:

  • 🔒 You can control the accessibility of logs. Due to the increased security of the plugin, other operations are not available.

  • 🛠️ You can manage how logs are injected into the database.

  • 🏷️ You can customize all the plugin's built-in collection values.

  • 📊 You can specify which collections you want to track.

✨ How to customize logging for each collection:

For logging, we have integrated the entire plugin with Payload CMS hooks for each collection that you allow tracking, so you can track the entire application. payload-auditor does logging not based on the hooks themselves, but on the operations inside each hook. Reading the collection hooks documentation can give you a much better understanding of how the plugin works.

🔍 In summary, for each collection, you can make the following changes:

  • 🏷️ Set the collection slug you want. This is the basis for tracking, which makes the plugin find your collection.
  • ⚙️ Enable the required hooks. As mentioned, this plugin supports all Payload CMS hooks.
  • 🔄 Enable custom operations in each hook. Maybe you need a hook but don't want to use all the operations inside that hook for logging. For example, inside the afterOperation hook, only the create operation creates a log.
  • ⏸️ You can temporarily stop tracking this collection.

🧠 When Should You Use It?

  • You need to track critical collection changes (e.g., user logins, updates)

  • You want additional backend security for your Payload project

  • You work in a multi-user admin environment with role-specific needs

  • You're building a SaaS or enterprise-grade Payload-based product

📚 Docutments

Using the plugin is straightforward. Simply specify the slug of the collection or global you want to track, then configure the hooks and operations you need to monitor.

For quick access to the documentation, simply hover over the main API. You can then use the provided link to navigate directly to the relevant documentation.

automation

Configures the automation features of the plugin.

Currently, the plugin supports automatic log cleanup using Payload CMS's Jobs system.

collections & globals

These are the core sections of the plugin, managing operation tracking. They share a nearly identical API.

Each has a track property that accepts the following configuration:

PropertyDescription
hooksDefines which hooks to track.
hooks["hookName"]The hook name to track. Can be true or a configuration object.
hooks["hookName"]["operationName"]The operation to track within the specified hook. Can be true or a configuration object.
slugThe slug of the collection or global. This value is type-safe.
Important Notes:
  • At both the hook level (hooks["hookName"]) and the operation level (hooks["hookName"]["operationName"]), the following properties are always available:
PropertyDescription
customLoggerA custom function to customize the log output.
debugEnables debugging for the hook or operation. Can be true or an object.
  • When debug: true is enabled for a hook or operation, logs are not saved to the database by default. To override this behavior, set debug.skipDatabaseSave: false. The logs will still be displayed in the console.

  • If the hook you're tracking does not have operations (e.g., afterRead or afterForgotPassword), the plugin will treat the second-level key as the operation name. For example, forgot-password or read.

  • When using customLogger, ensure you include the necessary internal collection fields (or custom fields) in your output. The operation and hook values are always overridden by the plugin and are required. The function must return an object.

  • An enabled property is available at both the hook and operation levels. This allows you to enable or disable tracking for specific hooks or operations.

  • Setting a hook or operation to false will disable it entirely.

buffer

Configures how logs are flushed to the database. You can control flushing based on either time or log count.

PropertyDescription
flushStrategyDefines the flushing strategy. Options:
- size: Flush when the number of logs reaches the specified limit.
- time: Flush after a specified time interval.
- realTime: Flush immediately when logs are created.
sizeA numeric value. When the log count reaches this number, logs are flushed. Works with the size strategy.
timeA numeric value in milliseconds. Logs are flushed at this interval. Works with the time strategy.

configureRootCollection

A function that allows you to customize the internal collection.

The function receives the default collection configuration as an argument and expects you to return your modified configuration.


📄 License

MIT License

Similar plugins