0.0.3 • Published 6 months ago

@devx-commerce/plugin-audit v0.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

Compatibility

This plugin is compatible with versions >= 2.4.0 of @medusajs/medusa.

Overview

The Medusa Audit Plugin provides comprehensive audit logging capabilities for your Medusa commerce application. Track changes to entities, user actions, and system events to maintain a complete history of activities within your commerce system.

Features

  • Track entity changes (products, orders, customers, etc.)
  • Log user actions and system events
  • Configurable audit retention policies
  • Admin UI integration for viewing audit logs
  • Extensible architecture for custom audit events

Installation

npm install @devx-commerce/plugin-audit
# or
yarn add @devx-commerce/plugin-audit

Configuration

Add the plugin to your medusa-config.js:

const plugins = [
  // ...
  {
    resolve: "@devx-commerce/plugin-audit",
    options: {
      // Plugin options
    }
  }
]

Usage

Once installed, the plugin automatically begins tracking changes to supported entities. You can view audit logs through the admin dashboard or query them programmatically.

Events

The plugin listens to the following events:

EventDescription
audit.customerRecords customer-related audit events
audit.productRecords product-related audit events

To emit audit events from your code:

// Example: Emitting a customer audit event
const eventBusService = container.resolve(Modules.EVENT_BUS)
await eventBusService.emit({
  name: "audit.customer",
  data: {
    customer_id: "cust_123",
    message: "Customer profile updated",
    admin_id: "admin_456" // Optional: ID of admin who performed the action
  }
})

API Endpoints

The plugin exposes the following API endpoints:

EndpointMethodDescription
/admin/audit/customerGETRetrieve customer audit logs with filtering and pagination
/admin/audit/productGETRetrieve product audit logs with filtering and pagination

Example request to retrieve customer audit logs:

curl -X GET 'http://localhost:9000/admin/audit/customer?limit=10&offset=0'

Development

To develop the plugin locally:

yarn install
yarn dev

Building

yarn build
0.0.3

6 months ago

0.0.3-beta.0

6 months ago

0.0.2

6 months ago

0.0.2-beta.1

6 months ago

0.0.2-beta.0

6 months ago