Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking the time a user spends on the site more accurately #77

Open
pckapps opened this issue May 9, 2019 · 4 comments
Open

Tracking the time a user spends on the site more accurately #77

pckapps opened this issue May 9, 2019 · 4 comments

Comments

@pckapps
Copy link

pckapps commented May 9, 2019

Why should VisitorTrackingMiddleware be before django.contrib.sessions.middleware.SessionMiddleware?

I have custom middleware that logs a user out after 1 hour. I want to run this before VisitorTrackingMiddleware otherwise it greatly overstates the time a user spends on the site.

Or is there another way to be more accurate in the time a user spends on the site?

@mjschultz
Copy link
Collaborator

VisitorTrackingMiddleware is before SessionMiddleware because the tracker only operates on the response from the app. Middlewares go top to bottom for request and bottom to top for response.

Is it possible you could adapt your custom middleware to work on the response?

@pckapps
Copy link
Author

pckapps commented May 10, 2019

Won't be ideal to change my custom middleware. I've placed VisitorTrackingMiddleware at the bottom now and it seems to work?

Alternatively, is there something else I can do so that the time on the site is more accurate? Currently sessions are set to expire after 2 weeks, so if a user doesn't log out it looks like they are always on the site

@SilverStrings024
Copy link

Won't be ideal to change my custom middleware. I've placed VisitorTrackingMiddleware at the bottom now and it seems to work?

Alternatively, is there something else I can do so that the time on the site is more accurate? Currently sessions are set to expire after 2 weeks, so if a user doesn't log out it looks like they are always on the site

Do a check to make sure the user is actually active, if they haven't left a certain page or anything, you can log them out.

@SilverStrings024
Copy link

Won't be ideal to change my custom middleware. I've placed VisitorTrackingMiddleware at the bottom now and it seems to work?
Alternatively, is there something else I can do so that the time on the site is more accurate? Currently sessions are set to expire after 2 weeks, so if a user doesn't log out it looks like they are always on the site

Do a check to make sure the user is actually active, if they haven't left a certain page or anything, you can log them out.

Oh...nevermind, it was last year that this was posted lol my bad, didntmean to necrobump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants