mage-os/module-admin-activity-log 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mage-os/module-admin-activity-log

Composer 安装命令:

composer require mage-os/module-admin-activity-log

包简介

The Admin Activity extension makes it easy to track all admin activity with comprehensive audit logging.

README 文档

README

Latest Stable Version License Total Downloads

A comprehensive admin activity logging extension for Mage-OS and Magento 2 that provides complete audit trails for administrative actions, login attempts, and page visits.

Huge thanks to KiwiCommerce for publishing this extension, and for their support and contributions. This extension is a fork of the original Magento Admin Activity Log by KiwiCommerce.

✨ Key Features

  • Admin Action Logging: Track all admin activities including add, edit, delete, print, view, and mass update operations
  • Login Monitoring: Record successful and failed login attempts with detailed information
  • Field-Level Changes: Track specific field modifications with before/after values
  • IP Address Logging: Capture IP addresses and user agent information for security analysis
  • Extensible Configuration: Customize tracked entities and skip fields via XML configuration

📋 Requirements

Component Version
Magento Open Source 2.4.x
Mage-OS 1.0+
PHP 8.1+

🚀 Installation

composer require mage-os/module-admin-activity-log
php bin/magento setup:upgrade

⚙️ Configuration

Basic Configuration

Navigate to Stores → Configuration → Advanced → Admin → Admin Activity

General Settings

  • Enable Admin Activity Logs: Enable/disable the extension
  • Record Login Activity: Track login and logout activities
  • Record Page Visits: Monitor admin page navigation
  • Clear Admin Activity Logs After: Set how many days to keep logs (default: 90 days)

📖 Usage Guide

Viewing Activity Logs

Navigate to System → Admin Activity → Admin Activity Logs

Click View on any log entry to see detailed info.

Login Activity Monitoring

Go to System → Admin Activity → Admin Login Logs

Architecture

The module is built around interface-driven services for clean extensibility:

Interface Description
ActivityConfigInterface Configuration settings (enabled state, log retention)
FieldTrackerInterface Tracks field-level changes with before/after values
ModelResolverInterface Resolves and loads models for activity logging
ActivityRepositoryInterface CRUD operations for activity log entries
LoginRepositoryInterface CRUD operations for login log entries

All interfaces are marked @api and can be customized via DI preferences.

Extensibility

Customizing Tracked Entities

The module uses adminactivity.xml to define which entities are tracked and which fields are skipped during logging. Third-party modules can extend this configuration by creating their own etc/adminactivity.xml file.

Example configuration to add a custom entity:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:MageOS_AdminActivityLog:etc/adminactivity.xsd">
    <modules>
        <module name="customer_group">
            <label translate="true">Customer Group</label>
            <models>
                <class name="Magento\Customer\Model\Group" />
            </models>
            <events>
                <event controller_action="customer_group_save" action_alias="save" />
                <event controller_action="customer_group_delete" action_alias="delete" />
            </events>
            <config>
                <skip_fields>
                    <field>customer_group_id</field>
                    <field>check_if_is_new</field>
                </skip_fields>
                <configpath constant="MODULE_CUSTOMER" />
                <editurl url="{{module}}/{{controller}}/edit/id/{{id}}" />
                <itemfield field="customer_group_code" />
            </config>
        </module>
    </modules>
</config>

Skip Fields

To exclude specific fields from being logged (e.g., timestamps, internal IDs), add them to the skip_fields node for the relevant module in your adminactivity.xml.

Protected Fields

Sensitive fields (passwords, tokens, payment data) are automatically excluded from logging. To add custom protected fields:

<type name="MageOS\AdminActivityLog\Model\FieldChecker">
    <arguments>
        <argument name="protectedFields" xsi:type="array">
            <item name="my_secret_field" xsi:type="string">my_secret_field</item>
        </argument>
    </arguments>
</type>

Security

  • Model Allowlist: Only explicitly allowed model classes can be loaded during activity logging, preventing arbitrary class instantiation.
  • Protected Fields: Sensitive data (passwords, API keys, tokens, payment info) is never logged, configured via DI.
  • ACL Permissions: Control access to activity logs via permission rules.
  • CSRF Protection: All admin actions are protected with form keys.

Performance Notes

  • Page Visit Logging: Disabled by default. Enable only if needed, as it creates a log entry for every admin page view.
  • Database Indexes: The module includes indexes on frequently queried columns for optimal filtering performance.
  • Bulk Operations: Log cleanup and activity logging use bulk database operations to minimize overhead.
  • Field Truncation: Large values are truncated at ~64KB to prevent database bloat.

Contributing

Issues and pull requests welcome on GitHub.

License

This module is licensed under the Open Software License 3.0.

Support

For bugs or feature requests, please open an issue in the GitHub repository.

mage-os/module-admin-activity-log 适用场景与选型建议

mage-os/module-admin-activity-log 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.08k 次下载、GitHub Stars 达 29, 最近一次更新时间为 2025 年 10 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「log」 「admin」 「backend」 「activity」 「magento2」 「magento 2」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 mage-os/module-admin-activity-log 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mage-os/module-admin-activity-log 我们能提供哪些服务?
定制开发 / 二次开发

基于 mage-os/module-admin-activity-log 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 5.08k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 29
  • 点击次数: 7
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 29
  • Watchers: 3
  • Forks: 93
  • 开发语言: PHP

其他信息

  • 授权协议: OSL-3.0
  • 更新时间: 2025-10-13