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