{"id":21598117,"url":"https://github.com/matfish2/craft-activity-log","last_synced_at":"2025-04-11T01:01:45.947Z","repository":{"id":38321710,"uuid":"506319030","full_name":"matfish2/craft-activity-log","owner":"matfish2","description":"Record HTTP requests to Craft","archived":false,"fork":false,"pushed_at":"2024-12-21T17:54:48.000Z","size":1281,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-03T20:03:00.951Z","etag":null,"topics":["audit","craftcms-plugin"],"latest_commit_sha":null,"homepage":"https://plugins.craftcms.com/activity-logs?craft4","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matfish2.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-22T16:10:52.000Z","updated_at":"2025-01-24T00:49:29.000Z","dependencies_parsed_at":"2024-02-04T02:41:02.769Z","dependency_job_id":"414d131c-fd40-4b2e-8fd6-175dc215df2d","html_url":"https://github.com/matfish2/craft-activity-log","commit_stats":{"total_commits":59,"total_committers":3,"mean_commits":"19.666666666666668","dds":0.0847457627118644,"last_synced_commit":"67ace5b63644af50f69cf9b2fbf7d37f500565a5"},"previous_names":[],"tags_count":46,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matfish2%2Fcraft-activity-log","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matfish2%2Fcraft-activity-log/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matfish2%2Fcraft-activity-log/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matfish2%2Fcraft-activity-log/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matfish2","download_url":"https://codeload.github.com/matfish2/craft-activity-log/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248322600,"owners_count":21084336,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audit","craftcms-plugin"],"created_at":"2024-11-24T18:11:20.046Z","updated_at":"2025-04-11T01:01:45.916Z","avatar_url":"https://github.com/matfish2.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Craft Activity Log\n![activity_logs](https://github.com/matfish2/craft-activity-log/assets/1510460/2c52ed8f-9805-4203-85fe-69b453ced922)\n\nThis plugin provides a detailed activity log for incoming web requests.\n\n### Requirements\n\nThis plugin requires Craft CMS 4.x or later.\n\n### Installation\n\n1. Include the package:\n\n```\ncomposer require matfish/craft-activity-log\n```\n\n2. Install the plugin:\n\n```\nphp craft plugin/install activity-logs\n```\n\n### Usage\n\nOnce the plugin is installed Craft will start recording all requests, excluding Control Panel AJAX requests (except for Login request).\nData points include:\n* URL\n* Action (if it is an action request)\n* User\n* Site\n* Query\n* Payload \n* IP\n* User agent\n* Method (GET,POST,PUT or DELETE)\n* Is CP (Control Panel) Request?\n* Is AJAX request?\n* Response Code\n* Execution Time\n* Timestamp (Created at)\n\nThe user can control which request types to record under the Settings page.\n\n![Screenshot 2023-07-05 122540](https://github.com/matfish2/craft-activity-log/assets/1510460/a0eca755-4351-4e52-8c9d-847a8d38f9ca)\n\n### Advanced Request Filtering\n\nFor a more fine-grained control, **on top of** request type settings, you can use the `requestFilter` setting:\n1. In your project create a `config/activity-logs.php` file\n2. Define a `requestFilter` callback that returns a `boolean`. E.g:\n```php\n\u003c?php\nreturn [\n 'requestFilter' =\u003e function () {\n        if ($this-\u003eisAjax) {\n            return $this-\u003eisActionRequest \u0026\u0026 count($this-\u003eactionSegments) === 2 \u0026\u0026 $this-\u003eactionSegments[1] === 'save-draft';\n        }\n\n        return true;\n    }\n]\n```\nThe `$this` object in this context will be an instance of the request class ([`craft\\web\\Request`](https://docs.craftcms.com/api/v4/craft-web-request.html)).\nOnly requests satisfying the condition (returning `true`) will be recorded.\n\n### View Filtering \nWhile `reqestsFilter` allows you to control which requests are being **recorded** to the database, at times, you may wish to filter some recorded requests from the [**viewable** audit trail](#audit-trail-ui) for specific users, either due to permissions or in order to reduce the cognitive load of parsing unnecessary data.\nThis can be accomplished using the `viewFilters` setting, following the same structure as the example below:\n```php \n'viewFilters'=\u003e [\n        [\n            'users'=\u003e['admin'], // Username(s) of relevant users\n            'filters'=\u003e[ // Filters to be applied for said users:\n                'isCp'=\u003etrue, // Only Control Panel requests\n                'isAction'=\u003etrue, // Only Action requests \n                'isAjax'=\u003efalse, // Only page Requests\n                'siteId'=\u003e1, // or (e.g) [1,2] for multiple sites\n                'actions'=\u003e[ // Only display those actions \n                    ['user-settings','save-group'] // full action array, can be found under `actionSegments` in `activitylog` table\n                ]\n            ]\n        ]\n```\nUsers not included in any of the array items will be shown the full audit trail as per usual.\n\n### Action Requests\n[Controller Actions](https://craftcms.com/docs/4.x/dev/controller-actions.html) are automatically labelled using a naming convention. E.g [\"fields\",\"save-group\"] will become \"Fields Save Group\".\nThis is relevant for the \"Action\" search dropdown on the Logs page and for the Actions widget on the Statistics page.\nIn addition the user can optionally override this convention by giving explicit labels to recorded actions under the Actions page.\n\n![Screenshot 2023-07-05 123908](https://github.com/matfish2/craft-activity-log/assets/1510460/b977f911-9783-4b77-894a-a0b693d63baa)\n\n### Audit Trail UI\nRequests can be viewed and filtered under the Activity Log page.\nClick the \"Columns\" button to add or remove columns from the table on the fly:\n\n![craft4 test_adminos_activity-logs_site=default](https://user-images.githubusercontent.com/1510460/175236200-2c2ebc1b-b1c6-4dfa-a07a-8d20a3780cb5.png)\n\nNote that most columns have a dedicated filter attached to them (except for date range at the top of the table).\n\nClick the \"+\" sign on the left-hand side of each row to expand a child row containing the full request data:\n\n![craft4 test_adminos_activity-log_site=default (4)](https://user-images.githubusercontent.com/1510460/175233957-eeb453c1-8b18-448e-af7a-c476f3ac9cb5.png)\n \n### Payload Filtering\n\nThe plugin automatically replaces the CSRF Token and any payload key which contains the word \"password\" with a \"[filtered]\" mask.\nYou can add additional keys to be filtered in two ways:\n\na. General: Add it to the `filterPayloadKeys` on the setting file:\n```php   \n 'filterPayloadKeys'=\u003e[\n        'cvv','long_number'\n    ]\n```\nb. Specific: If you only want to filter a certain key from specific requests you can use the `filterPayloadCallbacks` array instead, e.g:\n```php\n 'filterPayloadCallbacks'=\u003e [\n     function(\\craft\\web\\Request $request) {\n        if (str_contains($request-\u003egetUrl(),'add-credit-card')) {\n                return 'cvv';\n         }\n\n        // Don't add any key to the list\n        return false;\n      }\n]\n```\n\n### Payload Search\nBy default, searching in request payload is disabled in order to remove unnecessary clutter from the table controls.\nYou can enable it in the Settings Page.\n![Screenshot 2023-07-05 122958](https://github.com/matfish2/craft-activity-log/assets/1510460/5050e149-0872-464c-bc64-e00ff6586666)\n\nNote that you need to press enter or leave the field for the search to be triggered.\n\n### Statistics\n![activity_logs_stats](https://github.com/matfish2/craft-activity-log/assets/1510460/824cf593-157e-4eb4-ba73-4365b75b2be0)\nThe statistics page provides some insights gleaned from the raw data.\nSimilar to Craft's dashboard widgets, you can add and remove widgets, as well as change the order and the column span.\nThe data can be filtered by:\n1. Date Range\n2. Site Id\n3. User Id\n4. Is Ajax?\n5. Is Cp? (Control Panel Request)\n\nIf you have an idea for additional widget(s) please open a new [feature request](https://github.com/matfish2/craft-activity-log/issues/new?assignees=\u0026labels=\u0026template=feature_request.md\u0026title=).\n\n### Pruning Data\n\nYou can prune (delete) data before that last X days using the following console command:\n```bash\nphp craft activity-logs/logs/prune --days=30\n```\nIf omitted the `days` option defaults to 30 days.\n\n\u003e Note: If you are running the command as a cron job add the `--interactive=0` option to disable manual confirmation\n\n### License\n\nYou can try Activity Log in a development environment for as long as you like. Once your site goes live, you are\nrequired to purchase a license for the plugin. License is purchasable through\nthe [Craft Plugin Store](https://plugins.craftcms.com/activity-logs).\n\nFor more information, see\nCraft's [Commercial Plugin Licensing](https://craftcms.com/docs/4.x/plugins.html#commercial-plugin-licensing).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatfish2%2Fcraft-activity-log","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatfish2%2Fcraft-activity-log","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatfish2%2Fcraft-activity-log/lists"}