@devx-commerce/plugin-audit v0.0.3
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-auditConfiguration
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:
| Event | Description |
|---|---|
audit.customer | Records customer-related audit events |
audit.product | Records 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:
| Endpoint | Method | Description |
|---|---|---|
/admin/audit/customer | GET | Retrieve customer audit logs with filtering and pagination |
/admin/audit/product | GET | Retrieve 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 devBuilding
yarn build6 months ago
6 months ago
6 months ago
6 months ago
6 months ago