Skip to content
This repository has been archived by the owner on Jul 28, 2020. It is now read-only.

Commit

Permalink
Merge a0fba34 into ab74e01
Browse files Browse the repository at this point in the history
  • Loading branch information
smn committed Oct 20, 2015
2 parents ab74e01 + a0fba34 commit d191448
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions garelay/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@
environ.get('GARELAY_REGISTER_BATCH_SIZE') or 1000)
GARELAY_RELAY_TIMEOUT = int(
environ.get('GARELAY_RELAY_TIMEOUT') or 10)
GARELAY_SESSION_AGE = int(
environ.get('GARELAY_SESSION_AGE') or
timedelta(days=365 * 2).total_seconds())

# Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/
Expand Down
5 changes: 5 additions & 0 deletions garelay/tracker/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
from datetime import timedelta

from django.test import TestCase
from django.test.client import Client
Expand Down Expand Up @@ -41,6 +42,10 @@ def test_tracking_event(self):
self.assertFalse(event.registered_at)
self.assertEqual(event.tracking_id, 'UA-F00-1')
self.assertEqual(event.client_id, self.client.session['tracker_uuid'])
self.assertEqual(
timedelta(seconds=self.client.session.get_expiry_age()).days,
365 * 2, # default session age is set to two years
)
self.assertEqual(event.user_agent, 'The Agent')
self.assertEqual(event.status, 'captured')
self.assertEqual(json.loads(event.data), {
Expand Down
2 changes: 2 additions & 0 deletions garelay/tracker/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.http import HttpResponse
from django.views.decorators.cache import never_cache
from django.utils import timezone
from django.conf import settings

from .models import TrackingEvent

Expand All @@ -18,6 +19,7 @@ def get_tracker_uuid(request):

@never_cache
def tracker(request, tracking_id, path):
request.session.set_expiry(settings.GARELAY_SESSION_AGE)
client_id = get_tracker_uuid(request)
data = {
'dp': path,
Expand Down

0 comments on commit d191448

Please sign in to comment.