8000 Merge branch 'master' into onur/playwright-browser-tests · deammer/sentry-javascript@b6c434f · GitHub
[go: up one dir, main page]

Skip to content

Commit b6c434f

Browse files
authored
Merge branch 'master' into onur/playwright-browser-tests
2 parents eb8eb96 + 27f8609 commit b6c434f

38 files changed

+483
-125
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44

55
- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott
66

7+
## 6.13.2
8+
9+
- fix(browser): Use getGlobalObject for document check (#3996)
10+
- misc(all): Disallow direct usage of globals (#3999)
11+
12+
## 6.13.1
13+
14+
- fix(browser): Check for document when sending outcomes (#3993)
15+
716
## 6.13.0
817

918
- feat(browser): Client Report Support (#3955)

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"lerna": "3.4.0",
3-
"version": "6.12.0",
3+
"version": "6.13.2",
44
"packages": "packages/*",
55
"npmClient": "yarn",
66
"useWorkspaces": true

packages/angular/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sentry/angular",
3-
"version": "6.12.0",
3+
"version": "6.13.2",
44
"description": "Official Sentry SDK for Angular",
55
"repository": "git://github.com/getsentry/sentry-javascript.git",
66
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/angular",
@@ -21,17 +21,17 @@
2121
"@angular/router": "10.x || 11.x || 12.x"
2222
},
2323
"dependencies": {
24-
"@sentry/browser": "6.12.0",
25-
"@sentry/types": "6.12.0",
26-
"@sentry/utils": "6.12.0",
24+
"@sentry/browser": "6.13.2",
25+
"@sentry/types": "6.13.2",
26+
"@sentry/utils": "6.13.2",
2727
"rxjs": "^6.6.0",
2828
"tslib": "^1.9.3"
2929
},
3030
"devDependencies": {
3131
"@angular/common": "^10.0.3",
3232
"@angular/core": "^10.0.3",
3333
"@angular/router": "^10.0.3",
34-
"@sentry-internal/eslint-config-sdk": "6.12.0",
34+
"@sentry-internal/eslint-config-sdk": "6.13.2",
3535
"npm-run-all": "^4.1.2",
3636
"prettier": "1.19.0",
3737
"rimraf": "^2.6.3",

packages/angular/src/tracing.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { AfterViewInit, Directive, Injectable, Input, NgModule, OnDestroy, OnIni
22
import { Event, NavigationEnd, NavigationStart, Router } from '@angular/router';
33
import { getCurrentHub } from '@sentry/browser';
44
import { Span, Transaction, TransactionContext } from '@sentry/types';
5-
import { logger, stripUrlQueryAndFragment, timestampWithMs } from '@sentry/utils';
5+
import { getGlobalObject, logger, stripUrlQueryAndFragment, timestampWithMs } from '@sentry/utils';
66
import { Observable, Subscription } from 'rxjs';
77
import { filter, tap } from 'rxjs/operators';
88

@@ -12,6 +12,8 @@ let instrumentationInitialized: boolean;
1212
let stashedStartTransaction: (context: TransactionContext) => Transaction | undefined;
1313
let stashedStartTransactionOnLocationChange: boolean;
1414

15+
const global = getGlobalObject<Window>();
16+
1517
/**
1618
* Creates routing instrumentation for Angular Router.
1719
*/
@@ -26,7 +28,7 @@ export function routingInstrumentation(
2628

2729
if (startTransactionOnPageLoad) {
2830
customStartTransaction({
29-
name: window.location.pathname,
31+
name: global.location.pathname,
3032
op: 'pageload',
3133
});
3234
}

packages/browser/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sentry/browser",
3-
"version": "6.12.0",
3+
"version": "6.13.2",
44
"description": "Official Sentry SDK for browsers",
55
"repository": "git://github.com/getsentry/sentry-javascript.git",
66
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/browser",
@@ -16,13 +16,13 @@
1616
"access": "public"
1717
},
1818
"dependencies": {
19-
"@sentry/core": "6.12.0",
20-
"@sentry/types": "6.12.0",
21-
"@sentry/utils": "6.12.0",
19+
"@sentry/core": "6.13.2",
20+
"@sentry/types": "6.13.2",
21+
"@sentry/utils": "6.13.2",
2222
"tslib": "^1.9.3"
2323
},
2424
"devDependencies": {
25-
"@sentry-internal/eslint-config-sdk": "6.12.0",
25+
"@sentry-internal/eslint-config-sdk": "6.13.2",
2626
"@types/eslint": "^7.2.0",
2727
"@types/md5": "2.1.33",
2828
"btoa": "^1.2.1",

packages/browser/src/helpers.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { API, captureException, withScope } from '@sentry/core';
22
import { DsnLike, Event as SentryEvent, Mechanism, Scope, WrappedFunction } from '@sentry/types';
3-
import { addExceptionMechanism, addExceptionTypeValue, logger } from '@sentry/utils';
3+
import { addExceptionMechanism, addExceptionTypeValue, getGlobalObject, logger } from '@sentry/utils';
44

5+
const global = getGlobalObject<Window>();
56
let ignoreOnError: number = 0;
67

78
/**
@@ -193,16 +194,21 @@ export interface ReportDialogOptions {
193194
* @hidden
194195
*/
195196
export function injectReportDialog(options: ReportDialogOptions = {}): void {
197+
if (!global.document) {
198+
return;
199+
}
200+
196201
if (!options.eventId) {
197202
logger.error(`Missing eventId option in showReportDialog call`);
198203
return;
199204
}
205+
200206
if (!options.dsn) {
201207
logger.error(`Missing dsn option in showReportDialog call`);
202208
return;
203209
}
204210

205-
const script = document.createElement('script');
211+
const script = global.document.createElement('script');
206212
script.async = true;
207213
script.src = new API(options.dsn).getReportDialogEndpoint(options);
208214

@@ -211,7 +217,7 @@ export function injectReportDialog(options: ReportDialogOptions = {}): void {
211217
script.onload = options.onLoad;
212218
}
213219

214-
const injectionPoint = document.head || document.body;
220+
const injectionPoint = global.document.head || global.document.body;
215221

216222
if (injectionPoint) {
217223
injectionPoint.appendChild(script);

packages/browser/src/transports/base.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@ import {
88
Transport,
99
TransportOptions,
1010
} from '@sentry/types';
11-
import { dateTimestampInSeconds, logger, parseRetryAfterHeader, PromiseBuffer, SentryError } from '@sentry/utils';
11+
import {
12+
dateTimestampInSeconds,
13+
getGlobalObject,
14+
logger,
15+
parseRetryAfterHeader,
16+
PromiseBuffer,
17+
SentryError,
18+
} from '@sentry/utils';
1219

1320
const CATEGORY_MAPPING: {
1421
[key in SentryRequestType]: string;
@@ -19,6 +26,8 @@ const CATEGORY_MAPPING: {
1926
attachment: 'attachment',
2027
};
2128

29+
const global = getGlobalObject<Window>();
30+
2231
/** Base Transport class implementation */
2332
export abstract class BaseTransport implements Transport {
2433
/**
@@ -42,9 +51,9 @@ export abstract class BaseTransport implements Transport {
4251
// eslint-disable-next-line deprecation/deprecation
4352
this.url = this._api.getStoreEndpointWithUrlEncodedAuth();
4453

45-
if (this.options.sendClientReports) {
46-
document.addEventListener('visibilitychange', () => {
47-
if (document.visibilityState === 'hidden') {
54+
if (this.options.sendClientReports && global.document) {
55+
global.document.addEventListener('visibilitychange', () => {
56+
if (global.document.visibilityState === 'hidden') {
4857
this._flushOutcomes();
4958
}
5059
});
@@ -90,7 +99,7 @@ export abstract class BaseTransport implements Transport {
9099
return;
91100
}
92101

93-
if (!navigator || typeof navigator.sendBeacon !== 'function') {
102+
if (!global.navigator || typeof global.navigator.sendBeacon !== 'function') {
94103
logger.warn('Beacon API not available, skipping sending outcomes.');
95104
return;
96105
}
@@ -125,7 +134,7 @@ export abstract class BaseTransport implements Transport {
125134
});
126135
const envelope = `${envelopeHeader}\n${itemHeaders}\n${item}`;
127136

128-
navigator.sendBeacon(url, envelope);
137+
global.navigator.sendBeacon(url, envelope);
129138
}
130139

131140
/**

packages/core/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sentry/core",
3-
"version": "6.12.0",
3+
"version": "6.13.2",
44
"description": "Base implementation for all Sentry JavaScript SDKs",
55
"repository": "git://github.com/getsentry/sentry-javascript.git",
66
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/core",
@@ -16,14 +16,14 @@
1616
"access": "public"
1717
},
1818
"dependencies": {
19-
"@sentry/hub": "6.12.0",
20-
"@sentry/minimal": "6.12.0",
21-
"@sentry/types": "6.12.0",
22-
"@sentry/utils": "6.12.0",
19+
"@sentry/hub": "6.13.2",
20+
"@sentry/minimal": "6.13.2",
21+
"@sentry/types": "6.13.2",
22+
"@sentry/utils": "6.13.2",
2323
"tslib": "^1.9.3"
2424
},
2525
"devDependencies": {
26-
"@sentry-internal/eslint-config-sdk": "6.12.0",
26+
"@sentry-internal/eslint-config-sdk": "6.13.2",
2727
"jest": "^24.7.1",
2828
"npm-run-all": "^4.1.2",
2929
"prettier": "1.19.0",

packages/core/src/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const SDK_VERSION = '6.12.0';
1+
export const SDK_VERSION = '6.13.2';

packages/ember/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sentry/ember",
3-
"version": "6.12.0",
3+
"version": "6.13.2",
44
"description": "Official Sentry SDK for Ember.js",
55
"repository": "git://github.com/getsentry/sentry-javascript.git",
66
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/ember",
@@ -32,10 +32,10 @@
3232
},
3333
"dependencies": {
3434
"@embroider/macros": "~0.37.0",
35-
"@sentry/browser": "6.12.0",
36-
"@sentry/tracing": "6.12.0",
37-
"@sentry/types": "6.12.0",
38-
"@sentry/utils": "6.12.0",
35+
"@sentry/browser": "6.13.2",
36+
"@sentry/tracing": "6.13.2",
37+
"@sentry/types": "6.13.2",
38+
"@sentry/utils": "6.13.2",
3939
"ember-auto-import": "~1.6.0",
4040
"ember-cli-babel": "~7.26.6",
4141
"ember-cli-htmlbars": "~5.1.2",
@@ -46,7 +46,7 @@
4646
"@embroider/test-setup": "~0.37.0",
4747
"@glimmer/component": "~1.0.0",
4848
"@glimmer/tracking": "~1.0.0",
49-
"@sentry-internal/eslint-config-sdk": "6.12.0",
49+
"@sentry-internal/eslint-config-sdk": "6.13.2",
5050
"@types/ember": "~3.16.5",
5151
"@types/ember-qunit": "~3.4.9",
5252
"@types/ember__test-helpers": "~1.7.0",
@@ -93,4 +93,4 @@
9393
"node": "14.15.4",
9494
"yarn": "1.22.5"
9595
}
96-
}
96+
}

0 commit comments

Comments
 (0)
0