Add Do Not Track support

This commit is contained in:
R. Miles McCain
2020-04-22 13:18:25 -04:00
parent 3d10ddf711
commit c2f4724b11
7 changed files with 36 additions and 8 deletions

View File

@@ -42,12 +42,15 @@ def _geoip2_lookup(ip):
@shared_task
def ingress_request(
service_uuid, tracker, time, payload, ip, location, user_agent, identifier=""
service_uuid, tracker, time, payload, ip, location, user_agent, dnt=False, identifier=""
):
try:
service = Service.objects.get(pk=service_uuid, status=Service.ACTIVE)
log.debug(f"Linked to service {service}")
if dnt and service.respect_dnt:
return
ip_data = _geoip2_lookup(ip)
log.debug(f"Found geoip2 data")

View File

@@ -18,6 +18,7 @@ def ingress(request, service_uuid, identifier, tracker, payload):
client_ip, is_routable = get_client_ip(request)
location = request.META.get("HTTP_REFERER", "").strip()
user_agent = request.META.get("HTTP_USER_AGENT", "").strip()
dnt = request.META.get("HTTP_DNT", "0").strip() == "1"
ingress_request.delay(
service_uuid,
@@ -27,7 +28,8 @@ def ingress(request, service_uuid, identifier, tracker, payload):
client_ip,
location,
user_agent,
identifier,
dnt=dnt,
identifier=identifier,
)