Skip to content

Remove use of the words blacklist and whitelist #2641

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ Sentry.addBreadcrumb({

> 'ignoreUrls' was renamed to 'blacklistUrls'. 'ignoreErrors', which has a similar name was not renamed. [Docs](https://docs.sentry.io/error-reporting/configuration/?platform=browser#blacklist-urls) and [Decluttering Sentry](https://docs.sentry.io/platforms/javascript/#decluttering-sentry)

> 'blacklistUrls' has since been renamed to 'excludedUrls'

_Old_:

```js
Expand Down
8 changes: 4 additions & 4 deletions packages/browser/examples/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ Sentry.init({
// An array of strings or regexps that'll be used to ignore specific errors based on their type/message
ignoreErrors: [/PickleRick_\d\d/, 'RangeError'],
// An array of strings or regexps that'll be used to ignore specific errors based on their origin url
blacklistUrls: ['external-lib.js'],
excludedUrls: ['external-lib.js'],
// An array of strings or regexps that'll be used to allow specific errors based on their origin url
whitelistUrls: ['http://localhost:5000', 'https://browser.sentry-cdn'],
includedUrls: ['http://localhost:5000', 'https://browser.sentry-cdn'],
// Debug mode with valuable initialization/lifecycle informations.
debug: true,
// Whether SDK should be enabled or not.
Expand Down Expand Up @@ -93,15 +93,15 @@ Sentry.init({
// Testing code, irrelevant vvvvv

document.addEventListener('DOMContentLoaded', () => {
document.querySelector('#blacklist-url').addEventListener('click', () => {
document.querySelector('#excluded-url').addEventListener('click', () => {
const script = document.createElement('script');
script.crossOrigin = 'anonymous';
script.src =
'https://rawgit.com/kamilogorek/cfbe9f92196c6c61053b28b2d42e2f5d/raw/3aef6ff5e2fd2ad4a84205cd71e2496a445ebe1d/external-lib.js';
document.body.appendChild(script);
});

document.querySelector('#whitelist-url').addEventListener('click', () => {
document.querySelector('#included-url').addEventListener('click', () => {
const script = document.createElement('script');
script.crossOrigin = 'anonymous';
script.src =
Expand Down
4 changes: 2 additions & 2 deletions packages/browser/examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
</style>
</head>
<body>
<button id="blacklist-url">blacklistUrl example</button>
<button id="whitelist-url">whitelistUrl example</button>
<button id="excluded-url">excludedUrl example</button>
<button id="included-url">includedUrl example</button>
<button id="ignore-message">ignoreError message example</button>
<button id="ignore-type">ignoreError type example</button>
<button id="regular-exception">regularException example</button>
Expand Down
6 changes: 4 additions & 2 deletions packages/browser/src/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ import { FetchTransport, XHRTransport } from './transports';
export interface BrowserOptions extends Options {
/**
* A pattern for error URLs which should not be sent to Sentry.
* To whitelist certain errors instead, use {@link Options.whitelistUrls}.
* To include certain errors instead, use {@link Options.includedUrls}.
* By default, all errors will be sent.
*/
excludedUrls?: Array<string | RegExp>;
blacklistUrls?: Array<string | RegExp>;
Comment on lines 13 to 19
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a docblock here to both old values:

/**
  * @deprecated Consider removing in major bump
  * {@see excludedUrls}
**/


/**
* A pattern for error URLs which should exclusively be sent to Sentry.
* This is the opposite of {@link Options.blacklistUrls}.
* This is the opposite of {@link Options.excludedUrls}.
* By default, all errors will be sent.
*/
includedUrls?: Array<string | RegExp>;
whitelistUrls?: Array<string | RegExp>;
}

Expand Down
3 changes: 3 additions & 0 deletions packages/browser/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ export function init(options: BrowserOptions = {}): void {
if (options.defaultIntegrations === undefined) {
options.defaultIntegrations = defaultIntegrations;
}
// Deprecate, but still support old exclusion/inclusion types
options.excludedUrls = options.excludedUrls || options.blacklistUrls;
options.includedUrls = options.includedUrls || options.whitelistUrls;
if (options.release === undefined) {
const window = getGlobalObject<Window>();
// This supports the variable that sentry-webpack-plugin injects
Expand Down
16 changes: 8 additions & 8 deletions packages/browser/test/integration/suites/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ describe("config", function() {
* > bar.js file called a function in baz.js
* > baz.js threw an error
*
* foo.js is blacklisted in the `init` call (init.js), thus we filter it
* foo.js is excluded in the `init` call (init.js), thus we filter it
* */
var urlWithBlacklistedUrl = new Error("filter");
urlWithBlacklistedUrl.stack =
var urlWithExcludedUrl = new Error("filter");
urlWithExcludedUrl.stack =
"Error: bar\n" +
" at http://localhost:5000/foo.js:7:19\n" +
" at bar(http://localhost:5000/bar.js:2:3)\n" +
Expand All @@ -35,17 +35,17 @@ describe("config", function() {
* > bar-pass.js file called a function in baz-pass.js
* > baz-pass.js threw an error
*
* foo-pass.js is *not* blacklisted in the `init` call (init.js), thus we don't filter it
* foo-pass.js is *not* excluded in the `init` call (init.js), thus we don't filter it
* */
var urlWithoutBlacklistedUrl = new Error("pass");
urlWithoutBlacklistedUrl.stack =
var urlWithoutExcludedUrl = new Error("pass");
urlWithoutExcludedUrl.stack =
"Error: bar\n" +
" at http://localhost:5000/foo-pass.js:7:19\n" +
" at bar(http://localhost:5000/bar-pass.js:2:3)\n" +
" at baz(http://localhost:5000/baz-pass.js:2:9)\n";

Sentry.captureException(urlWithBlacklistedUrl);
Sentry.captureException(urlWithoutBlacklistedUrl);
Sentry.captureException(urlWithExcludedUrl);
Sentry.captureException(urlWithoutExcludedUrl);
}).then(function(summary) {
assert.lengthOf(summary.events, 1);
assert.equal(summary.events[0].exception.values[0].type, "Error");
Expand Down
28 changes: 14 additions & 14 deletions packages/core/src/integrations/inboundfilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ const DEFAULT_IGNORE_ERRORS = [/^Script error\.?$/, /^Javascript error: Script e

/** JSDoc */
interface InboundFiltersOptions {
blacklistUrls?: Array<string | RegExp>;
excludedUrls?: Array<string | RegExp>;
ignoreErrors?: Array<string | RegExp>;
ignoreInternal?: boolean;
whitelistUrls?: Array<string | RegExp>;
includedUrls?: Array<string | RegExp>;
}

/** Inbound filters configurable by the user */
Expand Down Expand Up @@ -61,17 +61,17 @@ export class InboundFilters implements Integration {
);
return true;
}
if (this._isBlacklistedUrl(event, options)) {
if (this._isExcludedUrl(event, options)) {
logger.warn(
`Event dropped due to being matched by \`blacklistUrls\` option.\nEvent: ${getEventDescription(
`Event dropped due to being matched by \`excludedUrls\` option.\nEvent: ${getEventDescription(
event,
)}.\nUrl: ${this._getEventFilterUrl(event)}`,
);
return true;
}
if (!this._isWhitelistedUrl(event, options)) {
if (!this._isIncludedUrl(event, options)) {
logger.warn(
`Event dropped due to not being matched by \`whitelistUrls\` option.\nEvent: ${getEventDescription(
`Event dropped due to not being matched by \`includedUrls\` option.\nEvent: ${getEventDescription(
event,
)}.\nUrl: ${this._getEventFilterUrl(event)}`,
);
Expand Down Expand Up @@ -113,36 +113,36 @@ export class InboundFilters implements Integration {
}

/** JSDoc */
private _isBlacklistedUrl(event: Event, options: InboundFiltersOptions = {}): boolean {
private _isExcludedUrl(event: Event, options: InboundFiltersOptions = {}): boolean {
// TODO: Use Glob instead?
if (!options.blacklistUrls || !options.blacklistUrls.length) {
if (!options.excludedUrls || !options.excludedUrls.length) {
return false;
}
const url = this._getEventFilterUrl(event);
return !url ? false : options.blacklistUrls.some(pattern => isMatchingPattern(url, pattern));
return !url ? false : options.excludedUrls.some(pattern => isMatchingPattern(url, pattern));
}

/** JSDoc */
private _isWhitelistedUrl(event: Event, options: InboundFiltersOptions = {}): boolean {
private _isIncludedUrl(event: Event, options: InboundFiltersOptions = {}): boolean {
// TODO: Use Glob instead?
if (!options.whitelistUrls || !options.whitelistUrls.length) {
if (!options.includedUrls || !options.includedUrls.length) {
return true;
}
const url = this._getEventFilterUrl(event);
return !url ? true : options.whitelistUrls.some(pattern => isMatchingPattern(url, pattern));
return !url ? true : options.includedUrls.some(pattern => isMatchingPattern(url, pattern));
}

/** JSDoc */
private _mergeOptions(clientOptions: InboundFiltersOptions = {}): InboundFiltersOptions {
return {
blacklistUrls: [...(this._options.blacklistUrls || []), ...(clientOptions.blacklistUrls || [])],
excludedUrls: [...(this._options.excludedUrls || []), ...(clientOptions.excludedUrls || [])],
ignoreErrors: [
...(this._options.ignoreErrors || []),
...(clientOptions.ignoreErrors || []),
...DEFAULT_IGNORE_ERRORS,
],
ignoreInternal: typeof this._options.ignoreInternal !== 'undefined' ? this._options.ignoreInternal : true,
whitelistUrls: [...(this._options.whitelistUrls || []), ...(clientOptions.whitelistUrls || [])],
includedUrls: [...(this._options.includedUrls || []), ...(clientOptions.includedUrls || [])],
};
}

Expand Down
Loading