django-tracking2 tracks the length of time visitors and registered users spend on your site. Although this will work for websites, this is more applicable to web _applications_ with registered users. This does not replace (nor intend) to replace client-side analytics which is great for understanding aggregate flow of page views.
We have a system that automatically logs users out after a period of inactivity. Every so often we get an IntegrityError thrown claiming that the session_key already exists in the database. This should fix it.
I say should because race conditions are hard to test for. I thought I had a good test but it passed. I believe what is happening is the .save() is going through the UPDATE version, two threads get the response that nothing was updated, then both attempt to INSERT. One succeeds, the other fails with an IntegrityError. These changes catch the IntegrityError and simply return the winning Visitor object (which should make the resulting Pageview have a good reference).
Since the sessions time out at the same instance the objects should be identical (okay perhaps a few microseconds apart on some of the times, whatever).
We have a system that automatically logs users out after a period of inactivity. Every so often we get an IntegrityError thrown claiming that the session_key already exists in the database. This should fix it.
I say should because race conditions are hard to test for. I thought I had a good test but it passed. I believe what is happening is the
.save()
is going through the UPDATE version, two threads get the response that nothing was updated, then both attempt to INSERT. One succeeds, the other fails with an IntegrityError. These changes catch the IntegrityError and simply return the winning Visitor object (which should make the resulting Pageview have a good reference).Since the sessions time out at the same instance the objects should be identical (okay perhaps a few microseconds apart on some of the times, whatever).