Skip to content

Commit

Permalink
Merge pull request #4466 from galaxyproject/bowfin-gorgon
Browse files Browse the repository at this point in the history
Fix analytics
  • Loading branch information
shiltemann authored Nov 1, 2023
2 parents e6fda7b + 00c8c8e commit 38bdea6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 48 deletions.
71 changes: 25 additions & 46 deletions _includes/analytics.html
Original file line number Diff line number Diff line change
@@ -1,59 +1,38 @@
<!--
<script async defer data-domain="training.galaxyproject.org" src="https://plausible.galaxyproject.eu/js/plausible.js"></script>
-->
<!-- We let users opt-out, so if they've opted in, we need to append the plausible script to the body -->

<script>
var scriptElement = document.createElement("script");
scriptElement.async = true;
scriptElement.defer = true;
scriptElement.setAttribute("data-domain", "training.galaxyproject.org");
scriptElement.src = "https://plausible.galaxyproject.eu/js/plausible.js";

// Appending the script element to the body
if(localStorage.getItem('plausible-opt-out') !== 'opt-out' && navigator.doNotTrack !== "1") {
console.log("Plausible: opt-in");
// Wait for the document to be available
document.addEventListener("DOMContentLoaded", function(event) {
document.body.appendChild(scriptElement);
});
}
</script>

<!-- JavaScript Error Monitoring, and performance tracking. -->
<!--
<script
src="https://browser.sentry-cdn.com/7.52.1/bundle.tracing.min.js"
integrity="sha384-muuFXKS3752PNA4rPm9Uq6BLvOfV4CXyr9MHDBPvozOJJUWLKkogEFWOIRoVps43"
crossorigin="anonymous"
></script>
-->
<script type="text/javascript">
var scriptElement = document.createElement("script");
scriptElement.src = "https://browser.sentry-cdn.com/7.52.1/bundle.tracing.min.js";
scriptElement.integrity = "sha384-muuFXKS3752PNA4rPm9Uq6BLvOfV4CXyr9MHDBPvozOJJUWLKkogEFWOIRoVps43";
scriptElement.crossOrigin = "anonymous";

if(localStorage.getItem('sentry-opt-out') !== 'opt-out' && navigator.doNotTrack !== "1") {
console.log("Sentry: opt-in");
// Appending the script element to the body
document.addEventListener("DOMContentLoaded", function(event) {
document.body.appendChild(scriptElement);
});

Sentry.init({
dsn: "https://[email protected]/10",
release: "galaxy-training-network@{{ site.git_revision }}",
integrations: [new Sentry.BrowserTracing(), new Sentry.Replay()],
sampleRate: 0.1,
tracesSampleRate: 0.1,
// Capture Replay for no sessions by default
replaysSessionSampleRate: 0.01,
// plus for 1% of sessions with an error
replaysOnErrorSampleRate: 0.01,
// PII OFF
sendDefaultPii: false, // Off by default but just in case.
environment: "{{ jekyll.environment }}",
dsn: "https://[email protected]/10",
release: "galaxy-training-network@{{ site.git_revision }}",
integrations: [new Sentry.BrowserTracing(), new Sentry.Replay()],
sampleRate: 0.1,
tracesSampleRate: 0.1,
// Capture Replay for no sessions by default
replaysSessionSampleRate: 0.01,
// plus for 1% of sessions with an error
replaysOnErrorSampleRate: 0.01,
// PII OFF
sendDefaultPii: false, // Off by default but just in case.
environment: "{{ jekyll.environment }}",
});
}
</script>

<!-- Page view tracking -->
<script async defer data-domain="training.galaxyproject.org" src="https://plausible.galaxyproject.eu/js/plausible.js"></script>
<script>
if(localStorage.getItem('plausible-opt-out') !== 'opt-out' && navigator.doNotTrack !== "1") {
localStorage.removeItem("plausible_ignore")
console.log("Plausible: opt-in");
} else {
// if they're opting-out, or DNT
// we might get one page by accident but we won't get future ones.
localStorage.setItem("plausible_ignore", "true")
}
</script>
2 changes: 1 addition & 1 deletion _includes/extras.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
{% endif %}

<a href="{% link preferences.md %}" class="dropdown-item">
{% icon gtn-theme %} Themes have moved <span class="badge badge-secondary">New</span>
{% icon gtn-theme %} User Preferences <span class="badge badge-secondary">New</span>
</a>

<div class="dropdown-item">
Expand Down
8 changes: 7 additions & 1 deletion preferences.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ When something breaks on the GTN in the UI, we collect information about how tha
> > - Stack trace
> > - GTN Javascript variables
> {: .code-in}
>
>
> > <code-out-title>How we use it</code-out-title>
> > - Fixing JavaScript Bugs
> > - Especially from unusual platforms which we cannot test on.
Expand All @@ -177,6 +177,12 @@ Opt out from sentry:
function savePrivacy() {
gtnLocalSet('sentry-opt-out', document.getElementById("sentry-opt-out").value)
gtnLocalSet('plausible-opt-out', document.getElementById("plausible-opt-out").value)

if(document.getElementById("plausible-opt-out").value === "opt-in") {
localStorage.removeItem("plausible_ignore")
} else {
localStorage.setItem("plausible_ignore", "true")
}
}
// restore from prefs
document.getElementById("sentry-opt-out").value = gtnLocalGet("sentry-opt-out") || "opt-in";
Expand Down

0 comments on commit 38bdea6

Please sign in to comment.