77
88import { Integration } from '@sentry/types' ;
99
10- /** Internal */
11- interface SentryGlobal {
10+ /** An object representing properties that can be found on all globals */
11+ interface GlobalObject {
12+ navigator ?: Navigator ;
13+ }
14+
15+ /** Internal Sentry extensions on global */
16+ interface SentryGlobal extends GlobalObject {
1217 Sentry ?: {
1318 Integrations ?: Integration [ ] ;
1419 } ;
@@ -24,7 +29,7 @@ interface SentryGlobal {
2429 } ;
2530}
2631
27- // The code below for 'isGlobalObj' and 'GLOBAL ' was copied from core-js before modification
32+ // The code below for 'isGlobalObj' and 'GLOBAL_OBJ ' was copied from core-js before modification
2833// https://github.com/zloirock/core-js/blob/1b944df55282cdc99c90db5f49eb0b6eda2cc0a3/packages/core-js/internals/global.js
2934// core-js has the following licence:
3035//
@@ -53,7 +58,7 @@ function isGlobalObj(obj: { Math?: Math }): any | undefined {
5358 return obj && obj . Math == Math ? obj : undefined ;
5459}
5560
56- const GLOBAL =
61+ export const GLOBAL_OBJ : SentryGlobal =
5762 ( typeof globalThis == 'object' && isGlobalObj ( globalThis ) ) ||
5863 // eslint-disable-next-line no-restricted-globals
5964 ( typeof window == 'object' && isGlobalObj ( window ) ) ||
@@ -70,7 +75,7 @@ const GLOBAL =
7075 * @returns Global scope object
7176 */
7277export function getGlobalObject < T > ( ) : T & SentryGlobal {
73- return GLOBAL as T & SentryGlobal ;
78+ return GLOBAL_OBJ as T & SentryGlobal ;
7479}
7580
7681/**
@@ -85,7 +90,7 @@ export function getGlobalObject<T>(): T & SentryGlobal {
8590 * @returns the singleton
8691 */
8792export function getGlobalSingleton < T > ( name : keyof SentryGlobal [ '__SENTRY__' ] , creator : ( ) => T , obj ?: unknown ) : T {
88- const global = ( obj || GLOBAL ) as SentryGlobal ;
93+ const global = ( obj || GLOBAL_OBJ ) as SentryGlobal ;
8994 const __SENTRY__ = ( global . __SENTRY__ = global . __SENTRY__ || { } ) ;
9095 const singleton = __SENTRY__ [ name ] || ( __SENTRY__ [ name ] = creator ( ) ) ;
9196 return singleton ;
0 commit comments