Small fixes to admin & script

This commit is contained in:
R. Miles McCain
2020-04-16 10:00:18 -04:00
parent 595d6cfd20
commit ac0f4cee73
4 changed files with 12 additions and 5 deletions

View File

@@ -44,6 +44,7 @@ class HitAdmin(admin.ModelAdmin):
"heartbeats",
"tracker",
"load_time",
"location",
)
list_display_links = ("session",)
search_fields = ("initial", "tracker", "location", "referrer")

View File

@@ -7,8 +7,7 @@ window.onload = function () {
var xhr = new XMLHttpRequest();
xhr.open(
"POST",
self.location.protocol +
"//{{request.site.domain|default:request.META.HTTP_HOST}}{{endpoint}}",
"{{protocol}}://{{request.site.domain|default:request.META.HTTP_HOST}}{{endpoint}}",
true
);
xhr.setRequestHeader("Content-Type", "application/json");

View File

@@ -6,6 +6,7 @@ from django.shortcuts import render, reverse
from django.utils import timezone
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt
from django.conf import settings
from django.views.generic import TemplateView, View
from ipware import get_client_ip
@@ -64,6 +65,7 @@ class ScriptView(View):
return resp
def get(self, *args, **kwargs):
protocol = "https" if settings.SCRIPT_USE_HTTPS else "http"
endpoint = (
reverse(
"ingress:endpoint_script",
@@ -81,7 +83,7 @@ class ScriptView(View):
return render(
self.request,
"analytics/scripts/page.js",
context={"endpoint": endpoint},
context={"endpoint": endpoint, "protocol": protocol},
content_type="application/javascript",
)