Skip to content

Commit eeb80d0

Browse files
authored
Merge branch 'master' into hazat/getTransaction
2 parents a116d0f + 1204302 commit eeb80d0

File tree

18 files changed

+578
-130
lines changed

18 files changed

+578
-130
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- [core] fix: Call `bindClient` when creating new `Hub` to make integrations work automatically (#2665)
1111
- [gatsby] feat: Add @sentry/gatsby package (#2652)
1212
- [apm] feat: Add `Sentry.getSpan` to return the Span on the Scope (#2668)
13+
- [core] ref: Rename `whitelistUrls/blacklistUrls` to `allowUrls/denyUrls` (#2671)
1314

1415
## 5.17.0
1516

MIGRATION.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ Sentry.addBreadcrumb({
253253

254254
### Ignoring Urls
255255

256-
> '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)
256+
> 'ignoreUrls' was renamed to 'denyUrls'. 'ignoreErrors', which has a similar name was not renamed. [Docs](https://docs.sentry.io/error-reporting/configuration/?platform=browser#deny-urls) and [Decluttering Sentry](https://docs.sentry.io/platforms/javascript/#decluttering-sentry)
257257
258258
_Old_:
259259

@@ -270,7 +270,7 @@ _New_:
270270

271271
```js
272272
Sentry.init({
273-
blacklistUrls: [
273+
denyUrls: [
274274
'https://www.baddomain.com',
275275
/graph\.facebook\.com/i,
276276
],

packages/browser/examples/app.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ Sentry.init({
3737
// An array of strings or regexps that'll be used to ignore specific errors based on their type/message
3838
ignoreErrors: [/PickleRick_\d\d/, 'RangeError'],
3939
// An array of strings or regexps that'll be used to ignore specific errors based on their origin url
40-
blacklistUrls: ['external-lib.js'],
40+
denyUrls: ['external-lib.js'],
4141
// An array of strings or regexps that'll be used to allow specific errors based on their origin url
42-
whitelistUrls: ['http://localhost:5000', 'https://browser.sentry-cdn'],
42+
allowUrls: ['http://localhost:5000', 'https://browser.sentry-cdn'],
4343
// Debug mode with valuable initialization/lifecycle informations.
4444
debug: true,
4545
// Whether SDK should be enabled or not.
@@ -93,15 +93,15 @@ Sentry.init({
9393
// Testing code, irrelevant vvvvv
9494

9595
document.addEventListener('DOMContentLoaded', () => {
96-
document.querySelector('#blacklist-url').addEventListener('click', () => {
96+
document.querySelector('#deny-url').addEventListener('click', () => {
9797
const script = document.createElement('script');
9898
script.crossOrigin = 'anonymous';
9999
script.src =
100100
'https://rawgit.com/kamilogorek/cfbe9f92196c6c61053b28b2d42e2f5d/raw/3aef6ff5e2fd2ad4a84205cd71e2496a445ebe1d/external-lib.js';
101101
document.body.appendChild(script);
102102
});
103103

104-
document.querySelector('#whitelist-url').addEventListener('click', () => {
104+
document.querySelector('#allow-url').addEventListener('click', () => {
105105
const script = document.createElement('script');
106106
script.crossOrigin = 'anonymous';
107107
script.src =

packages/browser/examples/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
</style>
2121
</head>
2222
<body>
23-
<button id="blacklist-url">blacklistUrl example</button>
24-
<button id="whitelist-url">whitelistUrl example</button>
23+
<button id="deny-url">denyUrls example</button>
24+
<button id="allow-url">allowUrls example</button>
2525
<button id="ignore-message">ignoreError message example</button>
2626
<button id="ignore-type">ignoreError type example</button>
2727
<button id="regular-exception">regularException example</button>

packages/browser/src/backend.ts

+11-5
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,24 @@ import { FetchTransport, XHRTransport } from './transports';
1111
*/
1212
export interface BrowserOptions extends Options {
1313
/**
14-
* A pattern for error URLs which should not be sent to Sentry.
15-
* To whitelist certain errors instead, use {@link Options.whitelistUrls}.
14+
* A pattern for error URLs which should exclusively be sent to Sentry.
15+
* This is the opposite of {@link Options.denyUrls}.
1616
* By default, all errors will be sent.
1717
*/
18-
blacklistUrls?: Array<string | RegExp>;
18+
allowUrls?: Array<string | RegExp>;
1919

2020
/**
21-
* A pattern for error URLs which should exclusively be sent to Sentry.
22-
* This is the opposite of {@link Options.blacklistUrls}.
21+
* A pattern for error URLs which should not be sent to Sentry.
22+
* To allow certain errors instead, use {@link Options.allowUrls}.
2323
* By default, all errors will be sent.
2424
*/
25+
denyUrls?: Array<string | RegExp>;
26+
27+
/** @deprecated use {@link Options.allowUrls} instead. */
2528
whitelistUrls?: Array<string | RegExp>;
29+
30+
/** @deprecated use {@link Options.denyUrls} instead. */
31+
blacklistUrls?: Array<string | RegExp>;
2632
}
2733

2834
/**

packages/browser/test/integration/common/init.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function initSDK() {
3434
integrations: [new Sentry.Integrations.Dedupe()],
3535
attachStacktrace: true,
3636
ignoreErrors: ["ignoreErrorTest"],
37-
blacklistUrls: ["foo.js"],
37+
denyUrls: ["foo.js"],
3838
beforeSend: function(event, eventHint) {
3939
events.push(event);
4040
eventHints.push(eventHint);

packages/browser/test/integration/suites/config.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ describe("config", function() {
2121
* > bar.js file called a function in baz.js
2222
* > baz.js threw an error
2323
*
24-
* foo.js is blacklisted in the `init` call (init.js), thus we filter it
24+
* foo.js is denied in the `init` call (init.js), thus we filter it
2525
* */
26-
var urlWithBlacklistedUrl = new Error("filter");
27-
urlWithBlacklistedUrl.stack =
26+
var urlWithDeniedUrl = new Error("filter");
27+
urlWithDeniedUrl.stack =
2828
"Error: bar\n" +
2929
" at http://localhost:5000/foo.js:7:19\n" +
3030
" at bar(http://localhost:5000/bar.js:2:3)\n" +
@@ -35,17 +35,17 @@ describe("config", function() {
3535
* > bar-pass.js file called a function in baz-pass.js
3636
* > baz-pass.js threw an error
3737
*
38-
* foo-pass.js is *not* blacklisted in the `init` call (init.js), thus we don't filter it
38+
* foo-pass.js is *not* denied in the `init` call (init.js), thus we don't filter it
3939
* */
40-
var urlWithoutBlacklistedUrl = new Error("pass");
41-
urlWithoutBlacklistedUrl.stack =
40+
var urlWithoutDeniedUrl = new Error("pass");
41+
urlWithoutDeniedUrl.stack =
4242
"Error: bar\n" +
4343
" at http://localhost:5000/foo-pass.js:7:19\n" +
4444
" at bar(http://localhost:5000/bar-pass.js:2:3)\n" +
4545
" at baz(http://localhost:5000/baz-pass.js:2:9)\n";
4646

47-
Sentry.captureException(urlWithBlacklistedUrl);
48-
Sentry.captureException(urlWithoutBlacklistedUrl);
47+
Sentry.captureException(urlWithDeniedUrl);
48+
Sentry.captureException(urlWithoutDeniedUrl);
4949
}).then(function(summary) {
5050
assert.lengthOf(summary.events, 1);
5151
assert.equal(summary.events[0].exception.values[0].type, "Error");

packages/core/src/integrations/inboundfilters.ts

+37-21
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,15 @@ const DEFAULT_IGNORE_ERRORS = [/^Script error\.?$/, /^Javascript error: Script e
88

99
/** JSDoc */
1010
interface InboundFiltersOptions {
11-
blacklistUrls?: Array<string | RegExp>;
12-
ignoreErrors?: Array<string | RegExp>;
13-
ignoreInternal?: boolean;
14-
whitelistUrls?: Array<string | RegExp>;
11+
allowUrls: Array<string | RegExp>;
12+
denyUrls: Array<string | RegExp>;
13+
ignoreErrors: Array<string | RegExp>;
14+
ignoreInternal: boolean;
15+
16+
/** @deprecated use {@link InboundFiltersOptions.allowUrls} instead. */
17+
whitelistUrls: Array<string | RegExp>;
18+
/** @deprecated use {@link InboundFiltersOptions.denyUrls} instead. */
19+
blacklistUrls: Array<string | RegExp>;
1520
}
1621

1722
/** Inbound filters configurable by the user */
@@ -25,7 +30,7 @@ export class InboundFilters implements Integration {
2530
*/
2631
public static id: string = 'InboundFilters';
2732

28-
public constructor(private readonly _options: InboundFiltersOptions = {}) {}
33+
public constructor(private readonly _options: Partial<InboundFiltersOptions> = {}) {}
2934

3035
/**
3136
* @inheritDoc
@@ -50,7 +55,7 @@ export class InboundFilters implements Integration {
5055
}
5156

5257
/** JSDoc */
53-
private _shouldDropEvent(event: Event, options: InboundFiltersOptions): boolean {
58+
private _shouldDropEvent(event: Event, options: Partial<InboundFiltersOptions>): boolean {
5459
if (this._isSentryError(event, options)) {
5560
logger.warn(`Event dropped due to being internal Sentry Error.\nEvent: ${getEventDescription(event)}`);
5661
return true;
@@ -61,17 +66,17 @@ export class InboundFilters implements Integration {
6166
);
6267
return true;
6368
}
64-
if (this._isBlacklistedUrl(event, options)) {
69+
if (this._isDeniedUrl(event, options)) {
6570
logger.warn(
66-
`Event dropped due to being matched by \`blacklistUrls\` option.\nEvent: ${getEventDescription(
71+
`Event dropped due to being matched by \`denyUrls\` option.\nEvent: ${getEventDescription(
6772
event,
6873
)}.\nUrl: ${this._getEventFilterUrl(event)}`,
6974
);
7075
return true;
7176
}
72-
if (!this._isWhitelistedUrl(event, options)) {
77+
if (!this._isAllowedUrl(event, options)) {
7378
logger.warn(
74-
`Event dropped due to not being matched by \`whitelistUrls\` option.\nEvent: ${getEventDescription(
79+
`Event dropped due to not being matched by \`allowUrls\` option.\nEvent: ${getEventDescription(
7580
event,
7681
)}.\nUrl: ${this._getEventFilterUrl(event)}`,
7782
);
@@ -81,7 +86,7 @@ export class InboundFilters implements Integration {
8186
}
8287

8388
/** JSDoc */
84-
private _isSentryError(event: Event, options: InboundFiltersOptions = {}): boolean {
89+
private _isSentryError(event: Event, options: Partial<InboundFiltersOptions>): boolean {
8590
if (!options.ignoreInternal) {
8691
return false;
8792
}
@@ -101,7 +106,7 @@ export class InboundFilters implements Integration {
101106
}
102107

103108
/** JSDoc */
104-
private _isIgnoredError(event: Event, options: InboundFiltersOptions = {}): boolean {
109+
private _isIgnoredError(event: Event, options: Partial<InboundFiltersOptions>): boolean {
105110
if (!options.ignoreErrors || !options.ignoreErrors.length) {
106111
return false;
107112
}
@@ -113,36 +118,47 @@ export class InboundFilters implements Integration {
113118
}
114119

115120
/** JSDoc */
116-
private _isBlacklistedUrl(event: Event, options: InboundFiltersOptions = {}): boolean {
121+
private _isDeniedUrl(event: Event, options: Partial<InboundFiltersOptions>): boolean {
117122
// TODO: Use Glob instead?
118-
if (!options.blacklistUrls || !options.blacklistUrls.length) {
123+
if (!options.denyUrls || !options.denyUrls.length) {
119124
return false;
120125
}
121126
const url = this._getEventFilterUrl(event);
122-
return !url ? false : options.blacklistUrls.some(pattern => isMatchingPattern(url, pattern));
127+
return !url ? false : options.denyUrls.some(pattern => isMatchingPattern(url, pattern));
123128
}
124129

125130
/** JSDoc */
126-
private _isWhitelistedUrl(event: Event, options: InboundFiltersOptions = {}): boolean {
131+
private _isAllowedUrl(event: Event, options: Partial<InboundFiltersOptions>): boolean {
127132
// TODO: Use Glob instead?
128-
if (!options.whitelistUrls || !options.whitelistUrls.length) {
133+
if (!options.allowUrls || !options.allowUrls.length) {
129134
return true;
130135
}
131136
const url = this._getEventFilterUrl(event);
132-
return !url ? true : options.whitelistUrls.some(pattern => isMatchingPattern(url, pattern));
137+
return !url ? true : options.allowUrls.some(pattern => isMatchingPattern(url, pattern));
133138
}
134139

135140
/** JSDoc */
136-
private _mergeOptions(clientOptions: InboundFiltersOptions = {}): InboundFiltersOptions {
141+
private _mergeOptions(clientOptions: Partial<InboundFiltersOptions> = {}): Partial<InboundFiltersOptions> {
142+
// tslint:disable:deprecation
137143
return {
138-
blacklistUrls: [...(this._options.blacklistUrls || []), ...(clientOptions.blacklistUrls || [])],
144+
allowUrls: [
145+
...(this._options.whitelistUrls || []),
146+
...(this._options.allowUrls || []),
147+
...(clientOptions.whitelistUrls || []),
148+
...(clientOptions.allowUrls || []),
149+
],
150+
denyUrls: [
151+
...(this._options.blacklistUrls || []),
152+
...(this._options.denyUrls || []),
153+
...(clientOptions.blacklistUrls || []),
154+
...(clientOptions.denyUrls || []),
155+
],
139156
ignoreErrors: [
140157
...(this._options.ignoreErrors || []),
141158
...(clientOptions.ignoreErrors || []),
142159
...DEFAULT_IGNORE_ERRORS,
143160
],
144161
ignoreInternal: typeof this._options.ignoreInternal !== 'undefined' ? this._options.ignoreInternal : true,
145-
whitelistUrls: [...(this._options.whitelistUrls || []), ...(clientOptions.whitelistUrls || [])],
146162
};
147163
}
148164

0 commit comments

Comments
 (0)