From 4d7c036acc7d1730d73323fc05306bf45d4321a2 Mon Sep 17 00:00:00 2001 From: Matt Ronchetto Date: Sat, 27 Aug 2022 18:35:56 -0700 Subject: [PATCH] Add support for GPC header (#219) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: reflect both headers in debugging * chore: add Sec-GPC handling with DNT handling The `if` statement is there purely so that nothing more has to change handling wise. If either value is true, DNT policy should kick in and no data should be stored/tracked. *Should* just work™. * fix: meet Black style guide * fix: comply with other header formatting * fix: header typo --- shynet/analytics/tasks.py | 2 +- shynet/analytics/views/ingress.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/shynet/analytics/tasks.py b/shynet/analytics/tasks.py index 5ea5bf4..6e6510c 100644 --- a/shynet/analytics/tasks.py +++ b/shynet/analytics/tasks.py @@ -61,7 +61,7 @@ def ingress_request( log.debug(f"Linked to service {service}") if dnt and service.respect_dnt: - log.debug("Ignoring because of DNT") + log.debug("Ignoring because of DNT or GPC") return try: diff --git a/shynet/analytics/views/ingress.py b/shynet/analytics/views/ingress.py index 538f1e6..b6b7609 100644 --- a/shynet/analytics/views/ingress.py +++ b/shynet/analytics/views/ingress.py @@ -29,6 +29,9 @@ def ingress(request, service_uuid, identifier, tracker, payload): 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" + gpc = request.META.get("HTTP_SEC_GPC", "0").strip() == "1" + if gpc or dnt: + dnt = True ingress_request.delay( service_uuid,