@@ -8,11 +8,11 @@ import {
88} from '@sentry/core' ;
99import {
1010 addInstrumentationHandler ,
11- getGlobalObject ,
1211 logger ,
1312 resolvedSyncPromise ,
1413 stackParserFromStackParserOptions ,
1514 supportsFetch ,
15+ WINDOW ,
1616} from '@sentry/utils' ;
1717
1818import { BrowserClient , BrowserClientOptions , BrowserOptions } from './client' ;
@@ -94,10 +94,9 @@ export function init(options: BrowserOptions = {}): void {
9494 options . defaultIntegrations = defaultIntegrations ;
9595 }
9696 if ( options . release === undefined ) {
97- const window = getGlobalObject < Window > ( ) ;
9897 // 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 ;
101100 }
102101 }
103102 if ( options . autoSessionTracking === undefined ) {
@@ -128,8 +127,7 @@ export function init(options: BrowserOptions = {}): void {
128127 */
129128export function showReportDialog ( options : ReportDialogOptions = { } , hub : Hub = getCurrentHub ( ) ) : void {
130129 // doesn't work without a document (React Native)
131- const global = getGlobalObject < Window > ( ) ;
132- if ( ! global . document ) {
130+ if ( ! WINDOW . document ) {
133131 __DEBUG_BUILD__ && logger . error ( 'Global document not defined in showReportDialog call' ) ;
134132 return ;
135133 }
@@ -152,7 +150,7 @@ export function showReportDialog(options: ReportDialogOptions = {}, hub: Hub = g
152150 options . eventId = hub . lastEventId ( ) ;
153151 }
154152
155- const script = global . document . createElement ( 'script' ) ;
153+ const script = WINDOW . document . createElement ( 'script' ) ;
156154 script . async = true ;
157155 script . src = getReportDialogEndpoint ( dsn , options ) ;
158156
@@ -161,7 +159,7 @@ export function showReportDialog(options: ReportDialogOptions = {}, hub: Hub = g
161159 script . onload = options . onLoad ;
162160 }
163161
164- const injectionPoint = global . document . head || global . document . body ;
162+ const injectionPoint = WINDOW . document . head || WINDOW . document . body ;
165163 if ( injectionPoint ) {
166164 injectionPoint . appendChild ( script ) ;
167165 } else {
@@ -249,10 +247,7 @@ function startSessionOnHub(hub: Hub): void {
249247 * Enable automatic Session Tracking for the initial page load.
250248 */
251249function startSessionTracking ( ) : void {
252- const window = getGlobalObject < Window > ( ) ;
253- const document = window . document ;
254-
255- if ( typeof document === 'undefined' ) {
250+ if ( typeof WINDOW . document === 'undefined' ) {
256251 __DEBUG_BUILD__ &&
257252 logger . warn ( 'Session tracking in non-browser environment with @sentry/browser is not supported.' ) ;
258253 return ;
0 commit comments