From 72e54b7e9c9b741eca5a14e4e81f4ed2b279588e Mon Sep 17 00:00:00 2001 From: Thomas O'Dwyer Date: Wed, 22 Jan 2025 14:31:08 +0000 Subject: [PATCH 1/2] Update Plausible tracking tag --- templates/base.html | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/templates/base.html b/templates/base.html index 141394d63..2bbe6ca28 100644 --- a/templates/base.html +++ b/templates/base.html @@ -22,11 +22,26 @@ }); - {# The following tags are for Plausible stats collection. Internal Bennett Institute reference: https://plausible.io/jobs.opensafely.org #} - - {# Note that the name is_staff has no direct relationship to the User.is_staff flag in a django.contrib.admin context, which we no longer use. For more detail, see: https://github.com/opensafely-core/job-server/issues/4590 #} - - {% if template_name %}{% endif %} + {% comment %} + The following tags are for Plausible stats collection. + Internal Bennett Institute reference: https://plausible.io/jobs.opensafely.org + Note that the name is_staff has no direct relationship to the User.is_staff flag in a django.contrib.admin context, which we no longer use. + For more detail, see: https://github.com/opensafely-core/job-server/issues/4590 + {% endcomment %} + + {# End of stats-collecting tags. #} {% vite_hmr_client %} From ea562b2710ab00b2b41764c7c9db8f4b4f156ee9 Mon Sep 17 00:00:00 2001 From: Thomas O'Dwyer Date: Wed, 22 Jan 2025 14:31:18 +0000 Subject: [PATCH 2/2] Remove custom plausible script --- assets/src/scripts/_plausible.js | 25 ------------------------- assets/src/scripts/base.js | 1 - 2 files changed, 26 deletions(-) delete mode 100644 assets/src/scripts/_plausible.js diff --git a/assets/src/scripts/_plausible.js b/assets/src/scripts/_plausible.js deleted file mode 100644 index 3f3c7a7ee..000000000 --- a/assets/src/scripts/_plausible.js +++ /dev/null @@ -1,25 +0,0 @@ -const isLoggedIn = document.head.querySelector(`meta[name="is_logged_in"]`); -const isStaff = document.head.querySelector(`meta[name="is_staff"]`); -const templateName = document.head.querySelector(`meta[name="template"]`); - -if (document.location.hostname === "jobs.opensafely.org") { - const script = document.createElement("script"); - script.defer = true; - script.setAttribute("data-domain", "jobs.opensafely.org"); - script.id = "plausible"; - script.src = "https://plausible.io/js/script.pageview-props.tagged-events.js"; - - if (isLoggedIn) { - script.setAttribute("event-is_logged_in", isLoggedIn.content); - } - - if (isStaff) { - script.setAttribute("event-is_staff", isStaff.content); - } - - if (templateName) { - script.setAttribute("event-template", templateName.content); - } - - document.head.appendChild(script); -} diff --git a/assets/src/scripts/base.js b/assets/src/scripts/base.js index 0c4310c07..a5a3d1d0e 100644 --- a/assets/src/scripts/base.js +++ b/assets/src/scripts/base.js @@ -13,4 +13,3 @@ import "../styles/base.css"; // Custom JS import "./_alert"; import "./_expand-list"; -import "./_plausible";