Skip to content

Commit

Permalink
Merge pull request #4819 from opensafely-core/plausible
Browse files Browse the repository at this point in the history
Replace custom Plausible JS code with scripts
  • Loading branch information
tomodwyer authored Jan 23, 2025
2 parents 7027da0 + ea562b2 commit 2a6de14
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 31 deletions.
25 changes: 0 additions & 25 deletions assets/src/scripts/_plausible.js

This file was deleted.

1 change: 0 additions & 1 deletion assets/src/scripts/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ import "../styles/base.css";
// Custom JS
import "./_alert";
import "./_expand-list";
import "./_plausible";
25 changes: 20 additions & 5 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,26 @@
});
</script>

{# The following <meta> tags are for Plausible stats collection. Internal Bennett Institute reference: https://plausible.io/jobs.opensafely.org #}
<meta name="is_logged_in" content="{% if user.is_authenticated %}true{% else %}false{% endif %}">
{# 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 #}
<meta name="is_staff" content="{% if user_can_view_staff_area %}true{% else %}false{% endif %}">
{% if template_name %}<meta name="template" content="{{ template_name }}">{% endif %}
{% comment %}
The following <meta> 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 %}
<script
defer
data-domain="jobs.opensafely.org"
event-is_logged_in="{% if user.is_authenticated %}true{% else %}false{% endif %}"
event-is_staff="{% if user_can_view_staff_area %}true{% else %}false{% endif %}"
{% if template_name %}
event-template="{{ template_name }}"
{% endif %}
src="https://plausible.io/js/script.pageview-props.tagged-events.js"
>
</script>
<script nonce="{{ request.csp_nonce }}">
window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) }
</script>
{# End of stats-collecting <meta> tags. #}

{% vite_hmr_client %}
Expand Down

0 comments on commit 2a6de14

Please sign in to comment.