Skip to content

Commit

Permalink
fix: Avoid JavaScript error if a content blocker prevents Fathom from…
Browse files Browse the repository at this point in the history
… loading
  • Loading branch information
jpmckinney committed Nov 7, 2024
1 parent 7ab76f3 commit a473854
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions data_registry/templates/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@
})

document.querySelectorAll('a[download]').forEach(trackable => {
trackable.addEventListener('click', event => {
fathom.trackEvent(`download ${trackable.dataset.event}`) // eslint-disable-line no-undef
})
if (typeof fathom !== 'undefined') {
trackable.addEventListener('click', event => {
fathom.trackEvent(`download ${trackable.dataset.event}`) // eslint-disable-line no-undef
})
}
})
</script>
{% endblock %}
Expand Down Expand Up @@ -363,7 +365,7 @@ <h3>CSV</h3>
</div>
</div>
<div class="col-md-auto">
<a href="mailto:[email protected]?{% feedback_query_string_parameters %}" onclick="fathom.trackEvent('contact')" target="_blank" class="hstack link-white">
<a href="mailto:[email protected]?{% feedback_query_string_parameters %}" onclick="typeof fathom !== 'undefined' && fathom.trackEvent('contact')" target="_blank" class="hstack link-white">
{% include "includes/chevron_icon.html" with direction="right" classes="me-2" size="24" only %}{% translate "Contact Data Support Team" %}
</a>
</div>
Expand Down

0 comments on commit a473854

Please sign in to comment.