Commit eba43382 authored by Robert Knight's avatar Robert Knight

Replace `whitelistUrls` config with `allowUrls`

Replace the deprecated `whitelistUrls` config option in Sentry with
`allowUrls`. `whitelistUrls` was deprecated in Sentry v5.18.0.

Also revise the comments to be more succinct and note what happens if an
exception does not have a useful stack trace.
parent 0e909e57
......@@ -36,22 +36,21 @@ function currentScriptOrigin() {
* @param {SentryConfig} config
*/
export function init(config) {
// Only send events for errors which can be attributed to our code. This
// reduces noise in Sentry caused by errors triggered by eg. script tags added
// by browser extensions. The downside is that this may cause us to miss errors
// which are caused by our code but, for any reason, cannot be attributed to
// it. This logic assumes that all of our script bundles are served from
// the same origin as the bundle which includes this module.
//
// If we can't determine the current script's origin, just disable the
// whitelist and report all errors.
const scriptOrigin = currentScriptOrigin();
const whitelistUrls = scriptOrigin ? [scriptOrigin] : undefined;
const allowUrls = scriptOrigin ? [scriptOrigin] : undefined;
Sentry.init({
dsn: config.dsn,
environment: config.environment,
// Only report exceptions where the stack trace references a URL that is
// part of our code. This reduces noise caused by third-party scripts which
// may be injected by browser extensions.
//
// Sentry currently always allows exceptions to bypass this list if no
// URL can be extracted.
allowUrls,
// Ignore various errors due to circumstances outside of our control.
ignoreErrors: [
// Ignore network request failures. Some of these ought to be
......@@ -65,7 +64,6 @@ export function init(config) {
],
release: '__VERSION__', // replaced by versionify
whitelistUrls,
// See https://docs.sentry.io/error-reporting/configuration/filtering/?platform=javascript#before-send
beforeSend: (event, hint) => {
......
......@@ -69,7 +69,7 @@ describe('sidebar/util/sentry', () => {
assert.calledWith(
fakeSentry.init,
sinon.match({
whitelistUrls: ['https://cdn.hypothes.is'],
allowUrls: ['https://cdn.hypothes.is'],
})
);
});
......@@ -88,7 +88,7 @@ describe('sidebar/util/sentry', () => {
);
});
it('disables the URL whitelist if `document.currentScript` is inaccessible', () => {
it('disables the URL allowlist if `document.currentScript` is inaccessible', () => {
fakeDocumentCurrentScript.get(() => null);
sentry.init({
......@@ -99,7 +99,7 @@ describe('sidebar/util/sentry', () => {
assert.calledWith(
fakeSentry.init,
sinon.match({
whitelistUrls: undefined,
allowUrls: undefined,
})
);
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment