Raekkeri/django-requestlogs

Ignore requests by users

Closed this issue · 5 comments

There are users for that I don't need to capture the requests.
Can we create a filter to ignore requests from certain users?

My idea is to create two new configurations:

DEFAULT_SETTINGS = {
     ...
     'IGNORE_USER_FIELD': '',
     'IGNORE_USERS': [],
}

My own configuration would look like this:

REQUESTLOGS = {
     ...
     'IGNORE_USER_FIELD': 'username',
     'IGNORE_USERS': ['username1', 'username2'],
}

or

REQUESTLOGS = {
     ...
     'IGNORE_USER_FIELD': 'email',
     'IGNORE_USERS': ['email@email1.com', 'email@email2.com'],
}

and finalize() method in RequestLogEntry class do:

self.response = self.response_handler(response)

if SETTINGS['IGNORE_USER_FIELD']:
     if (self.user.get(SETTINGS['IGNORE_USER_FIELD'], None) in SETTINGS['IGNORE_USERS']):
         return None

self.store()

@Raekkeri, what do you think about this?

I think it is ok to include this kind of feature. Also a unittest for this would be nice. Or I can implement this in some time.

Hi @leogregianin

here's the PR for this #39

Thanks @Raekkeri 👏

@leogregianin Thanks for your contribution!

@Raekkeri would you entertain a feature request (I'd be happy to PR) for an INCLUDE_USERS.

Just found this library today and personally would like to just enable it for a particular user that's encountering issues.

Thanks for sharing your work with the community!