Skip to content

Commit

Permalink
Revert "Respect dnt in JS tracker (#257)"
Browse files Browse the repository at this point in the history
This reverts commit 4ffc3bd.
  • Loading branch information
StarkZarn authored Apr 18, 2024
1 parent c4410c4 commit d333a96
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
8 changes: 0 additions & 8 deletions shynet/analytics/templates/analytics/scripts/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@
//
// This script only sends the current URL, the referrer URL, and the page load time. That's it!

{% if dnt %}
var Shynet = {
dnt: true
};
{% else %}
var Shynet = {
dnt: false,
idempotency: null,
heartbeatTaskId: null,
skipHeartbeat: false,
Expand Down Expand Up @@ -59,8 +53,6 @@ var Shynet = {
};

window.addEventListener("load", Shynet.newPageLoad);
{% endif %}


{% if script_inject %}
// The following is script is not part of Shynet, and was instead
Expand Down
10 changes: 3 additions & 7 deletions shynet/analytics/views/ingress.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from django.utils import timezone
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt
from django.views.generic import View
from django.views.generic import TemplateView, View
from ipware import get_client_ip

from core.models import Service
Expand Down Expand Up @@ -119,7 +119,7 @@ def get(self, *args, **kwargs):
"service_uuid": self.kwargs.get("service_uuid"),
},
)
if self.kwargs.get("identifier") is None
if self.kwargs.get("identifier") == None
else reverse(
"ingress:endpoint_script_id",
kwargs={
Expand All @@ -129,9 +129,6 @@ def get(self, *args, **kwargs):
)
)
heartbeat_frequency = settings.SCRIPT_HEARTBEAT_FREQUENCY
dnt = self.request.META.get("HTTP_DNT", "0").strip() == "1"
service_uuid = self.kwargs.get("service_uuid")
service = Service.objects.get(pk=service_uuid, status=Service.ACTIVE)
return render(
self.request,
"analytics/scripts/page.js",
Expand All @@ -141,7 +138,6 @@ def get(self, *args, **kwargs):
"protocol": protocol,
"heartbeat_frequency": heartbeat_frequency,
"script_inject": self.get_script_inject(),
"dnt": dnt and service.respect_dnt,
}
),
content_type="application/javascript",
Expand All @@ -163,7 +159,7 @@ def post(self, *args, **kwargs):
def get_script_inject(self):
service_uuid = self.kwargs.get("service_uuid")
script_inject = cache.get(f"script_inject_{service_uuid}")
if script_inject is None:
if script_inject == None:
service = Service.objects.get(uuid=service_uuid)
script_inject = service.script_inject
cache.set(f"script_inject_{service_uuid}", script_inject, timeout=3600)
Expand Down

0 comments on commit d333a96

Please sign in to comment.