I wanted to use TRACK_USAGE_INCLUDE_OR_EXCLUDE_VIEWS = 'exclude' to track every view except the admin view, however it tracked too the requests for static files (which I don't want to track), creating a lot of entries in the database.
I tried to exclude it with
tracker.exclude("/static")
But when requesting static files, TrackUsage.before_request -> self.app.view_functions.get(ctx.request.endpoint)
|
view_func = self.app.view_functions.get(ctx.request.endpoint) |
returns a lambda, which makes impossible (or at least I could find how to replicate) exclude those routes.
This could be very handy for semi-large/large applications where is faster just exclude 1 view than include all the other views.
I have seen that ctx.request.path returns the path (/, /static, /admin, etc), maybe checking both possibilities, views and routes could be a solution for this?
I wanted to use
TRACK_USAGE_INCLUDE_OR_EXCLUDE_VIEWS = 'exclude'to track every view except the admin view, however it tracked too the requests for static files (which I don't want to track), creating a lot of entries in the database.I tried to exclude it with
But when requesting static files,
TrackUsage.before_request->self.app.view_functions.get(ctx.request.endpoint)flask-track-usage/src/flask_track_usage/__init__.py
Line 109 in 629ad1c
This could be very handy for semi-large/large applications where is faster just exclude 1 view than include all the other views.
I have seen that
ctx.request.pathreturns the path (/, /static, /admin, etc), maybe checking both possibilities, views and routes could be a solution for this?