Skip to content

Commit ac6da8f

Browse files
committed
fix: missing global in browser environments
1 parent 52f583d commit ac6da8f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/opentelemetry-api/src/api/global-utils.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ type MyGlobals = Partial<{
3838
[GLOBAL_TRACE_API_KEY]: Get<TracerProvider>;
3939
}>;
4040

41-
export const _global = global as typeof global & MyGlobals;
41+
export const _global = (typeof globalThis === 'object'
42+
? globalThis
43+
: typeof global === 'object'
44+
? global
45+
: window) as MyGlobals;
4246

4347
/**
4448
* Make a function which accepts a version integer and returns the instance of an API if the version

0 commit comments

Comments
 (0)