Skip to content

Commit

Permalink
Merge pull request #178 from papyri/feature/matomo-tracking-jquery-mi…
Browse files Browse the repository at this point in the history
…grate

Adding basic tracking for jquery migrate errors through matomo
  • Loading branch information
iccole authored Jan 15, 2025
2 parents 249562f + 0fc685c commit 85db542
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pn-site/js/init.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
function init() {
initjQueryMigrate();
jQuery("div#hd h1").on('click', () => { window.location = "/" });
jQuery("li.dialog").each(function(i) {
jQuery(this).after("<li><a href=\"#\" onclick=\"javascript:jQuery('#" + this.id + "c').dialog({height:100,modal:true})\">" + this.title + "</a></li>");
Expand Down Expand Up @@ -74,6 +75,16 @@ function init() {
getCampaign();
}

function initjQueryMigrate() {
jQuery.migrateMute = true;
jQuery.migrateTrace = false;
jQuery.migrateWarnings.push = (message) => {
const stacktrace = new Error().stack;
const cleanedStacktrace = stacktrace.replace(/^.*at jQuery\.migrateWarnings\.push.*$/gm, '');
_paq.push(['trackEvent', 'warning.jqmigrate', message + '\n' + cleanedStacktrace]);
};
}

function getPath() {
var result = window.location.href.substring(window.location.href.indexOf(window.location.pathname));
if (window.location.search.length > 0) {
Expand Down

0 comments on commit 85db542

Please sign in to comment.