matfish2 / craft-activity-log

Record HTTP requests to Craft
https://plugins.craftcms.com/activity-logs?craft4
Other
0 stars 1 forks source link

FR: Add a custom request filter #2

Closed gregoryturner closed 2 years ago

gregoryturner commented 2 years ago

Is your feature request related to a problem? Please describe. No issues related to feature request

Describe the solution you'd like The plugin records all events to the DB. For our purposes, we only need a concise recording of select events. We would like you to add an event we could tap into via a module. This would enable us to control what gets written to the DB and what gets displayed without having to do a lot of filtering on the display itself.

An example event syntax: Event::trigger(self::class, self::EVENT_BEFORE_INDEX_ELEMENT, $event);

Describe alternatives you've considered We have considered writing our own plugin.

matfish2 commented 2 years ago

The plugin records all events to the DB

Just to clarify, the plugin records requests, not events.

Excellent idea. Will look into adding a custom filter, as requested.

matfish2 commented 2 years ago

I have added an optional requestFilter setting to version 1.1.2, that can be defined under config/activity-logs.php. E.g:

<?php
return [
    'requestFilter' => function () {
        return $this->getPathInfo() !== 'activity-logs';
    }
];

Note that $this is an instance of craft\web\Request

gregoryturner commented 2 years ago

Thank you for the rapid response. I'll share this update with our dev. group and see if it'll meet their needs.