11/* eslint-disable max-lines */ // TODO: We might want to split this file up
2+ import { WINDOW } from '@sentry/browser' ;
23import { addGlobalEventProcessor , getCurrentHub , Scope , setContext } from '@sentry/core' ;
34import { Breadcrumb , Client , Event , Integration } from '@sentry/types' ;
45import { addInstrumentationHandler , createEnvelope , logger } from '@sentry/utils' ;
@@ -232,7 +233,7 @@ export class Replay implements Integration {
232233 return ;
233234 }
234235 // XXX: See method comments above
235- window . setTimeout ( ( ) => this . start ( ) ) ;
236+ setTimeout ( ( ) => this . start ( ) ) ;
236237 }
237238
238239 /**
@@ -396,8 +397,8 @@ export class Replay implements Integration {
396397 * first flush.
397398 */
398399 setInitialState ( ) : void {
399- const urlPath = `${ window . location . pathname } ${ window . location . hash } ${ window . location . search } ` ;
400- const url = `${ window . location . origin } ${ urlPath } ` ;
400+ const urlPath = `${ WINDOW . location . pathname } ${ WINDOW . location . hash } ${ WINDOW . location . search } ` ;
401+ const url = `${ WINDOW . location . origin } ${ urlPath } ` ;
401402
402403 this . performanceEvents = [ ] ;
403404
@@ -414,9 +415,9 @@ export class Replay implements Integration {
414415 */
415416 addListeners ( ) : void {
416417 try {
417- document . addEventListener ( 'visibilitychange' , this . handleVisibilityChange ) ;
418- window . addEventListener ( 'blur' , this . handleWindowBlur ) ;
419- window . addEventListener ( 'focus' , this . handleWindowFocus ) ;
418+ WINDOW . document . addEventListener ( 'visibilitychange' , this . handleVisibilityChange ) ;
419+ WINDOW . addEventListener ( 'blur' , this . handleWindowBlur ) ;
420+ WINDOW . addEventListener ( 'focus' , this . handleWindowFocus ) ;
420421
421422 // There is no way to remove these listeners, so ensure they are only added once
422423 if ( ! this . hasInitializedCoreListeners ) {
@@ -440,7 +441,7 @@ export class Replay implements Integration {
440441 }
441442
442443 // PerformanceObserver //
443- if ( ! ( 'PerformanceObserver' in window ) ) {
444+ if ( ! ( 'PerformanceObserver' in WINDOW ) ) {
444445 return ;
445446 }
446447
@@ -475,10 +476,10 @@ export class Replay implements Integration {
475476 */
476477 removeListeners ( ) : void {
477478 try {
478- document . removeEventListener ( 'visibilitychange' , this . handleVisibilityChange ) ;
479+ WINDOW . document . removeEventListener ( 'visibilitychange' , this . handleVisibilityChange ) ;
479480
480- window . removeEventListener ( 'blur' , this . handleWindowBlur ) ;
481- window . removeEventListener ( 'focus' , this . handleWindowFocus ) ;
481+ WINDOW . removeEventListener ( 'blur' , this . handleWindowBlur ) ;
482+ WINDOW . removeEventListener ( 'focus' , this . handleWindowFocus ) ;
482483
483484 if ( this . performanceObserver ) {
484485 this . performanceObserver . disconnect ( ) ;
@@ -665,7 +666,7 @@ export class Replay implements Integration {
665666 * page will also trigger a change to a hidden state.
666667 */
667668 handleVisibilityChange : ( ) => void = ( ) => {
668- if ( document . visibilityState === 'visible' ) {
669+ if ( WINDOW . document . visibilityState === 'visible' ) {
669670 this . doChangeToForegroundTasks ( ) ;
670671 } else {
671672 this . doChangeToBackgroundTasks ( ) ;
@@ -980,13 +981,13 @@ export class Replay implements Integration {
980981 addMemoryEntry ( ) : Promise < void [ ] > | undefined {
981982 // window.performance.memory is a non-standard API and doesn't work on all browsers
982983 // so we check before creating the event.
983- if ( ! ( 'memory' in window . performance ) ) {
984+ if ( ! ( 'memory' in WINDOW . performance ) ) {
984985 return ;
985986 }
986987
987988 return this . createPerformanceSpans ( [
988989 // @ts -ignore memory doesn't exist on type Performance as the API is non-standard (we check that it exists above)
989- createMemoryEntry ( window . performance . memory ) ,
990+ createMemoryEntry ( WINDOW . performance . memory ) ,
990991 ] ) ;
991992 }
992993
0 commit comments