Browse Source

Allow passing tracking params to PiwikTrackingMiddleware via PIWIK_TRACKING_MIDDLEWARE_PARAMS in settings

master
Johann Schmitz 5 years ago
parent
commit
cd9c08d1a1
Signed by: ercpe GPG Key ID: A084064277C501ED
  1. 5
      .gitignore
  2. 6
      Makefile
  3. 4
      src/django_pypiwik/middleware.py

5
.gitignore

@ -1,4 +1,7 @@
.idea
*.pyc
src/test.py
.coverage
.coverage
build/
dist/
src/*.egg-info/

6
Makefile

@ -1,5 +1,8 @@
TARGET?=tests
clean:
rm -r dist build src/*.egg-info
test:
PYTHONPATH=".:./src" python tests/
@ -7,3 +10,6 @@ coverage:
coverage erase
PYTHONPATH=".:./src" coverage run --source='src' --omit='src/test.py' --branch tests/__main__.py
coverage report -m
release:
python setup.py sdist upload -r pypi

4
src/django_pypiwik/middleware.py

@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
from django.conf import settings
from django_pypiwik.tracker import DjangoPiwikTracker
@ -6,5 +8,5 @@ class PiwikTrackingMiddleware(object):
def process_response(self, request, response):
tracker = DjangoPiwikTracker.for_current_site(request=request)
tracker.track_page_view()
tracker.track_page_view(**getattr(settings, 'PIWIK_TRACKING_MIDDLEWARE_PARAMS', {}))
return response