@@ -8,11 +8,11 @@ import {
8
8
} from '@sentry/core' ;
9
9
import {
10
10
addInstrumentationHandler ,
11
- getGlobalObject ,
12
11
logger ,
13
12
resolvedSyncPromise ,
14
13
stackParserFromStackParserOptions ,
15
14
supportsFetch ,
15
+ WINDOW ,
16
16
} from '@sentry/utils' ;
17
17
18
18
import { BrowserClient , BrowserClientOptions , BrowserOptions } from './client' ;
@@ -94,10 +94,9 @@ export function init(options: BrowserOptions = {}): void {
94
94
options . defaultIntegrations = defaultIntegrations ;
95
95
}
96
96
if ( options . release === undefined ) {
97
- const window = getGlobalObject < Window > ( ) ;
98
97
// This supports the variable that sentry-webpack-plugin injects
99
- if ( window . SENTRY_RELEASE && window . SENTRY_RELEASE . id ) {
100
- options . release = window . SENTRY_RELEASE . id ;
98
+ if ( WINDOW . SENTRY_RELEASE && WINDOW . SENTRY_RELEASE . id ) {
99
+ options . release = WINDOW . SENTRY_RELEASE . id ;
101
100
}
102
101
}
103
102
if ( options . autoSessionTracking === undefined ) {
@@ -128,8 +127,7 @@ export function init(options: BrowserOptions = {}): void {
128
127
*/
129
128
export function showReportDialog ( options : ReportDialogOptions = { } , hub : Hub = getCurrentHub ( ) ) : void {
130
129
// doesn't work without a document (React Native)
131
- const global = getGlobalObject < Window > ( ) ;
132
- if ( ! global . document ) {
130
+ if ( ! WINDOW . document ) {
133
131
__DEBUG_BUILD__ && logger . error ( 'Global document not defined in showReportDialog call' ) ;
134
132
return ;
135
133
}
@@ -152,7 +150,7 @@ export function showReportDialog(options: ReportDialogOptions = {}, hub: Hub = g
152
150
options . eventId = hub . lastEventId ( ) ;
153
151
}
154
152
155
- const script = global . document . createElement ( 'script' ) ;
153
+ const script = WINDOW . document . createElement ( 'script' ) ;
156
154
script . async = true ;
157
155
script . src = getReportDialogEndpoint ( dsn , options ) ;
158
156
@@ -161,7 +159,7 @@ export function showReportDialog(options: ReportDialogOptions = {}, hub: Hub = g
161
159
script . onload = options . onLoad ;
162
160
}
163
161
164
- const injectionPoint = global . document . head || global . document . body ;
162
+ const injectionPoint = WINDOW . document . head || WINDOW . document . body ;
165
163
if ( injectionPoint ) {
166
164
injectionPoint . appendChild ( script ) ;
167
165
} else {
@@ -249,10 +247,7 @@ function startSessionOnHub(hub: Hub): void {
249
247
* Enable automatic Session Tracking for the initial page load.
250
248
*/
251
249
function startSessionTracking ( ) : void {
252
- const window = getGlobalObject < Window > ( ) ;
253
- const document = window . document ;
254
-
255
- if ( typeof document === 'undefined' ) {
250
+ if ( typeof WINDOW . document === 'undefined' ) {
256
251
__DEBUG_BUILD__ &&
257
252
logger . warn ( 'Session tracking in non-browser environment with @sentry/browser is not supported.' ) ;
258
253
return ;
0 commit comments