Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
remove user urls from sentry data
Browse files Browse the repository at this point in the history
  • Loading branch information
dannycoates committed Mar 29, 2017
1 parent 54cc494 commit 1eb9177
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion addon/webextension/background/senderror.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ window.errorpopup = (function () {
});
};

function regexpEscape(str) {
// http://stackoverflow.com/questions/3115150/how-to-escape-regular-expression-special-characters-using-javascript
return str.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
}

exports.reportError = function (e) {
if (!analytics.getTelemetryPrefSync()) {
console.error("Telemetry disabled. Not sending critical error:", e);
Expand All @@ -76,7 +81,17 @@ window.errorpopup = (function () {
return;
}
if (! Raven.isSetup()) {
Raven.config(dsn).install();
Raven.config(dsn, {
dataCallback: function sanitizeSentry(data) {
const href = new RegExp(regexpEscape(window.location.href), 'g');
const origin = new RegExp(`${regexpEscape(window.location.origin)}[^\s",>]*`, 'g');
const json = JSON.stringify(data)
.replace(href, 'REDACTED_HREF')
.replace(origin, 'REDACTED_URL');
const result = JSON.parse(json);
return result;
}
}).install();
}
let exception = new Error(e.message);
exception.stack = e.multilineStack || e.stack || undefined;
Expand Down

0 comments on commit 1eb9177

Please sign in to comment.