1 # -*- coding: utf-8 -*-
2 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
5 from celery.task import task
6 from django.conf import settings
7 from http.client import HTTPConnection
9 from urllib.parse import urlsplit
11 logger = logging.getLogger(__name__)
16 # Retrieve piwik information
18 _host = urlsplit(settings.PIWIK_URL).netloc
19 except AttributeError:
20 logger.debug("PIWIK_URL not configured.")
24 @task(ignore_result=True)
25 def track_request(piwik_args):
26 piwik_url = "%s%s%s" % (settings.PIWIK_URL, u"/piwik.php?", piwik_args)
27 conn = HTTPConnection(_host)
28 conn.request('GET', piwik_url)