@@ -257,7 +257,7 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio
257
257
isPageloadTransaction , // should wait for finish signal if it's a pageload transaction
258
258
) ;
259
259
260
- if ( isPageloadTransaction ) {
260
+ if ( isPageloadTransaction && WINDOW . document ) {
261
261
WINDOW . document . addEventListener ( 'readystatechange' , ( ) => {
262
262
if ( [ 'interactive' , 'complete' ] . includes ( WINDOW . document . readyState ) ) {
263
263
idleTransaction . sendAutoFinishSignal ( ) ;
@@ -307,7 +307,7 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio
307
307
}
308
308
309
309
let activeSpan : Span | undefined ;
310
- let startingUrl : string | undefined = WINDOW . location . href ;
310
+ let startingUrl : string | undefined = WINDOW . location && WINDOW . location . href ;
311
311
312
312
if ( client . on ) {
313
313
client . on ( 'startNavigationSpan' , ( context : StartSpanOptions ) => {
@@ -335,7 +335,7 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio
335
335
} ) ;
336
336
}
337
337
338
- if ( options . instrumentPageLoad && client . emit ) {
338
+ if ( options . instrumentPageLoad && client . emit && WINDOW . location ) {
339
339
const context : StartSpanOptions = {
340
340
name : WINDOW . location . pathname ,
341
341
// pageload should always start at timeOrigin (and needs to be in s, not ms)
@@ -348,7 +348,7 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio
348
348
startBrowserTracingPageLoadSpan ( client , context ) ;
349
349
}
350
350
351
- if ( options . instrumentNavigation && client . emit ) {
351
+ if ( options . instrumentNavigation && client . emit && WINDOW . location ) {
352
352
addHistoryInstrumentationHandler ( ( { to, from } ) => {
353
353
/**
354
354
* This early return is there to account for some cases where a navigation transaction starts right after
0 commit comments