Add better tracking script protocol support

This commit is contained in:
R. Miles McCain 2020-05-07 17:49:02 -04:00
parent c84dac6b01
commit d88f61b281
No known key found for this signature in database
GPG Key ID: 24F9B6A2588C5408
2 changed files with 8 additions and 2 deletions

View File

@ -14,8 +14,8 @@
<p>Place the following snippet at the end of the <code>&lt;body&gt;</code> tag on any page you'd like to track.</p> <p>Place the following snippet at the end of the <code>&lt;body&gt;</code> tag on any page you'd like to track.</p>
<div class="card ~neutral !high font-mono text-sm"> <div class="card ~neutral !high font-mono text-sm">
{% filter force_escape %}<noscript><img {% filter force_escape %}<noscript><img
src="//{{request.site.domain}}{% url 'ingress:endpoint_pixel' object.uuid %}"></noscript> src="{{script_protocol}}{{request.site.domain}}{% url 'ingress:endpoint_pixel' object.uuid %}"></noscript>
<script src="//{{request.site.domain}}{% url 'ingress:endpoint_script' object.uuid %}"></script> <script src="{{script_protocol}}{{request.site.domain}}{% url 'ingress:endpoint_script' object.uuid %}"></script>
{% endfilter %} {% endfilter %}
</div> </div>
<hr class="sep h-4"> <hr class="sep h-4">

View File

@ -4,6 +4,7 @@ from django.core.cache import cache
from django.db.models import Q from django.db.models import Q
from django.shortcuts import get_object_or_404, reverse from django.shortcuts import get_object_or_404, reverse
from django.utils import timezone from django.utils import timezone
from django.conf import settings
from django.views.generic import ( from django.views.generic import (
CreateView, CreateView,
DeleteView, DeleteView,
@ -85,6 +86,11 @@ class ServiceUpdateView(
) )
return resp return resp
def get_context_data(self, *args, **kwargs):
data = super().get_context_data(*args, **kwargs)
data["script_protocol"] = "https://" if settings.SCRIPT_USE_HTTPS else "http://"
return data
class ServiceDeleteView( class ServiceDeleteView(
LoginRequiredMixin, PermissionRequiredMixin, SuccessMessageMixin, DeleteView LoginRequiredMixin, PermissionRequiredMixin, SuccessMessageMixin, DeleteView