Skip to content

Commit 31aa06c

Browse files
committed
fix: Use utils in integrations, Remove incremental mode
1 parent cca0d27 commit 31aa06c

File tree

3 files changed

+26
-27
lines changed

3 files changed

+26
-27
lines changed

packages/integrations/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
},
1515
"main": "dist/index.js",
1616
"module": "esm/index.js",
17-
"browser": "dist/index.js",
1817
"types": "dist/index.d.ts",
1918
"dependencies": {
2019
"@sentry/types": "5.2.0-beta.0",
21-
"@sentry/utils": "5.2.0-beta.0"
20+
"@sentry/utils": "5.2.0-beta.0",
21+
"tslib": "^1.9.3"
2222
},
2323
"devDependencies": {
2424
"chai": "^4.1.2",

packages/integrations/src/tracing.ts

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,26 @@ export class Tracing implements Integration {
3535
*
3636
* @param _options TracingOptions
3737
*/
38-
public constructor(private readonly _options: TracingOptions) {}
38+
public constructor(private readonly _options: TracingOptions) {
39+
if (!_options.tracingOrigins || !Array.isArray(_options.tracingOrigins) || _options.tracingOrigins.length === 0) {
40+
throw new SentryError('You need to define `tracingOrigins` in the options. Set an array of urls to trace.');
41+
}
42+
}
3943

4044
/**
4145
* @inheritDoc
4246
*/
4347
public setupOnce(_: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void {
44-
if (this._options.tracingOrigins.length) {
45-
if (this._options.traceXHR !== false) {
46-
this._traceXHR(getCurrentHub);
47-
}
48-
if (this._options.traceFetch !== false) {
49-
this._traceFetch(getCurrentHub);
50-
}
51-
if (this._options.autoStartOnDomReady !== false) {
52-
getGlobalObject<Window>().addEventListener('DOMContentLoaded', () => {
53-
Tracing.startTrace(getCurrentHub(), getGlobalObject<Window>().location.href);
54-
});
55-
}
56-
} else {
57-
throw new SentryError('You need to define tracingOrigins in the options');
48+
if (this._options.traceXHR !== false) {
49+
this._traceXHR(getCurrentHub);
50+
}
51+
if (this._options.traceFetch !== false) {
52+
this._traceFetch(getCurrentHub);
53+
}
54+
if (this._options.autoStartOnDomReady !== false) {
55+
getGlobalObject<Window>().addEventListener('DOMContentLoaded', () => {
56+
Tracing.startTrace(getCurrentHub(), getGlobalObject<Window>().location.href);
57+
});
5858
}
5959
}
6060

@@ -102,19 +102,19 @@ export class Tracing implements Integration {
102102
function(this: XMLHttpRequest, ...args: any[]): void {
103103
// @ts-ignore
104104
const self = getCurrentHub().getIntegration(Tracing);
105-
if (self) {
105+
if (self && self._xhrUrl) {
106106
const headers = getCurrentHub().traceHeaders();
107107
let whiteListed = false;
108-
109-
if (self._xhrUrl) {
110-
self._options.tracingOrigins.forEach((whiteListUrl: string) => {
111-
if (!whiteListed) {
112-
whiteListed = isMatchingPattern(self._xhrUrl, whiteListUrl);
113-
}
114-
});
108+
// tslint:disable-next-line: prefer-for-of
109+
for (let index = 0; index < self._options.tracingOrigins.length; index++) {
110+
const whiteListUrl = self._options.tracingOrigins[index];
111+
whiteListed = isMatchingPattern(self._xhrUrl, whiteListUrl);
112+
if (whiteListed) {
113+
break;
114+
}
115115
}
116116

117-
if (whiteListed) {
117+
if (whiteListed && this.setRequestHeader) {
118118
Object.keys(headers).forEach(key => {
119119
this.setRequestHeader(key, headers[key]);
120120
});

packages/typescript/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"strict": true,
2121
"target": "es5",
2222
"strictBindCallApply": false,
23-
"incremental": true,
2423
"plugins": [
2524
{
2625
"name": "typescript-tslint-plugin",

0 commit comments

Comments
 (0)