Skip to content

Commit

Permalink
Mask admin folder in URL tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Morgan Pichat committed Jul 2, 2024
1 parent 6983b0b commit 9330dea
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions js/sentry.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@

Sentry.init({
dsn: "https://[email protected]/4507254110552064",
beforeSend(event) {
event.request.url = maskSensitiveInfoInUrl(event.request.url, input.adminUrl);
return event;
},
});

document.getElementById("submitErrorReport").addEventListener("click", function () {
Expand All @@ -38,6 +42,10 @@ document.getElementById("submitErrorReport").addEventListener("click", function
}
});

const url = maskSensitiveInfoInUrl(window.location.href, input.adminUrl);

Sentry.setTag("url", url);

const eventId = Sentry.captureMessage(messages, "error");
const userEmail = document.getElementById("userEmail");
const errorDescription = document.getElementById("errorDescription");
Expand All @@ -54,3 +62,11 @@ document.getElementById("submitErrorReport").addEventListener("click", function
$('#errorModal').modal('hide')
}
});

function maskSensitiveInfoInUrl(url, adminFolder) {
let regex = new RegExp(adminFolder, "g");
url = url.replace(regex, '/********');

regex = new RegExp( "token=[^&]*", "i");
return url.replace(regex, 'token=********');
}

0 comments on commit 9330dea

Please sign in to comment.