matfish2 / craft-activity-log

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

If any action perform outside the page then that action can't store in activity log #11

Closed ks-arshitk closed 1 year ago

ks-arshitk commented 1 year ago

Versions Craft: 3.6.12.1 Activity Logs: 0.1.8

Question

If any action perform outside the details page then that action can't store in activity log

Activity setting image

Thank you

matfish2 commented 1 year ago

@ks-arshitk I don't understand which action you are referring to. What is the request associated with the action? Actions are short for "Controller Actions" (https://docs.craftcms.com/api/v3/craft-web-request.html#isactionrequest). The plugin doesn't record UI actions that have no request counterpart (e.g selecting a user or opening a dropdown). Also note that your settings only record non-ajax actions. To record all CP actions you need to check the "Record Control Panel AJAX Requests" as well.

ks-arshitk commented 1 year ago

@matfish2 I already enable "Record Control Panel AJAX Requests" and it store that request. But there is problem, it store all ajax request and database size increase or in table it show all ajax entry or find any specific entry is difficult.

Is there any way to store specific entry ?

matfish2 commented 1 year ago

Is there any way to store specific entry ?

Yes. Use the requestFilter setting. It allows you to fine-tune the exact requests you wish to record. https://github.com/matfish2/craft-activity-log#advanced-request-filtering

matfish2 commented 1 year ago

Forgot you were using Craft 3. Added requestFilter on version 0.1.9.

ks-arshitk commented 1 year ago

I am showing list of request stored on Database to Front end, but initially all the stored request are shown, which is causing extra load for me, what I want, is to filter request list on initial page load

matfish2 commented 1 year ago

@ks-arshitk if I understand correctly you still want those requests stored to the DB, but you want to filter on initial page load? Because if you are not interested in storing the requests in the first place you can use the requestFilter function as indicated above.

ks-arshitk commented 1 year ago

@matfish2 I want to store two types of request but display one type of request to user. One type of request is only for developer, so i don't want show to user.

matfish2 commented 1 year ago

I suppose you mean a per-user request filter that filters which requests are loaded to page in the first place (before any client-side filtering occurs). That's an interesting idea. I'll see how it can be implemented. Although my initial idea was that this is a plugin for admin eyes only, and shouldn't be reviewed by "ordinary" users.

ks-arshitk commented 1 year ago

@matfish2

so i don't want show to user.

Users means Admin I don't want show to admin

matfish2 commented 1 year ago

But you still want those requests recorded for another user (the Developer), right? This would require something like a filterRequestViewing function/setting, that accepts the current user and returns a modified initial query. Need to think about it.

ks-arshitk commented 1 year ago

@matfish2 So what did you think about this?

matfish2 commented 1 year ago

@ks-arshitk Please download v0.2.0 and try the following setting (just an example. Remove/change filters/username[s] as necessary):

'viewFilters'=> [
        [
            'users'=>['admin'], // Username(s) of relevant users
            'filters'=>[ // Filters to be applied for said users
                'isCp'=>true, // Only Control Panel requests
                'isAction'=>true, // Only Action requests 
                'isAjax'=>false, // Only page Requests
                'siteId'=>1, // or (e.g) [1,2] for multiple sites
                'actions'=>[ // Only display those actions 
                    ['user-settings','save-group'] // full action array, can be found under `actionSegments` in `activitylogs` table
                ]
            ]
        ]
ks-arshitk commented 1 year ago

@matfish2 it show all the request

please check it

'viewFilters'=> [[
        'users'=>[],
        'filters'=>[
            'isCp'=>true,
            'isAction'=>true,
            'isAjax'=>true,
            'siteId'=>1,
            'actions'=>[
                ["Login"]
            ]
        ]
]],
matfish2 commented 1 year ago

@ks-arshitk: a. You didn't specify any users in the array. You need to give it at least one username (e.g admin). You can find the username under Users in Craft. b. There is no ["Login"] action. Action is called ["users","login"]. It must match the activitylog.actionSegements column in the DB.

ks-arshitk commented 1 year ago

@matfish2 Thank you. It's work :+1: