Skip to content

Commit

Permalink
Add support for GPC header (#219)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
doamatto authored Aug 28, 2022
1 parent d75008a commit 4d7c036
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion shynet/analytics/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions shynet/analytics/views/ingress.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 4d7c036

Please sign in to comment.