11/* eslint-disable max-lines */
22import { Measurements } from '@sentry/types' ;
3- import { browserPerformanceTimeOrigin , getGlobalObject , htmlTreeAsString , logger } from '@sentry/utils' ;
3+ import { browserPerformanceTimeOrigin , htmlTreeAsString , logger , WINDOW } from '@sentry/utils' ;
44
55import { IdleTransaction } from '../../idletransaction' ;
66import { Transaction } from '../../transaction' ;
@@ -13,10 +13,8 @@ import { observe, PerformanceEntryHandler } from '../web-vitals/lib/observe';
1313import { NavigatorDeviceMemory , NavigatorNetworkInformation } from '../web-vitals/types' ;
1414import { _startChild , isMeasurementValue } from './utils' ;
1515
16- const global = getGlobalObject < Window > ( ) ;
17-
1816function getBrowserPerformanceAPI ( ) : Performance | undefined {
19- return global && global . addEventListener && global . performance ;
17+ return WINDOW && WINDOW . addEventListener && WINDOW . performance ;
2018}
2119
2220let _performanceCursor : number = 0 ;
@@ -32,7 +30,7 @@ export function startTrackingWebVitals(reportAllChanges: boolean = false): void
3230 const performance = getBrowserPerformanceAPI ( ) ;
3331 if ( performance && browserPerformanceTimeOrigin ) {
3432 if ( performance . mark ) {
35- global . performance . mark ( 'sentry-tracing-init' ) ;
33+ WINDOW . performance . mark ( 'sentry-tracing-init' ) ;
3634 }
3735 _trackCLS ( ) ;
3836 _trackLCP ( reportAllChanges ) ;
@@ -112,7 +110,7 @@ function _trackFID(): void {
112110/** Add performance related spans to a transaction */
113111export function addPerformanceEntries ( transaction : Transaction ) : void {
114112 const performance = getBrowserPerformanceAPI ( ) ;
115- if ( ! performance || ! global . performance . getEntries || ! browserPerformanceTimeOrigin ) {
113+ if ( ! performance || ! WINDOW . performance . getEntries || ! browserPerformanceTimeOrigin ) {
116114 // Gatekeeper if performance API not available
117115 return ;
118116 }
@@ -162,7 +160,7 @@ export function addPerformanceEntries(transaction: Transaction): void {
162160 break ;
163161 }
164162 case 'resource' : {
165- const resourceName = ( entry . name as string ) . replace ( global . location . origin , '' ) ;
163+ const resourceName = ( entry . name as string ) . replace ( WINDOW . location . origin , '' ) ;
166164 _addResourceSpans ( transaction , entry , resourceName , startTime , duration , timeOrigin ) ;
167165 break ;
168166 }
@@ -376,7 +374,7 @@ export function _addResourceSpans(
376374 * Capture the information of the user agent.
377375 */
378376function _trackNavigator ( transaction : Transaction ) : void {
379- const navigator = global . navigator as null | ( Navigator & NavigatorNetworkInformation & NavigatorDeviceMemory ) ;
377+ const navigator = WINDOW . navigator as null | ( Navigator & NavigatorNetworkInformation & NavigatorDeviceMemory ) ;
380378 if ( ! navigator ) {
381379 return ;
382380 }
0 commit comments