Skip to content

Commit 9abca91

Browse files
lforstAbhiPrasad
authored andcommitted
fix(tracing): Don't use querySelector when not available (#5160)
1 parent 9b74870 commit 9abca91

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/tracing/src/browser/browsertracing.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,13 @@ export function extractTraceDataFromMetaTags(): Partial<TransactionContext> | un
268268

269269
/** Returns the value of a meta tag */
270270
export function getMetaContent(metaName: string): string | null {
271-
const el = getGlobalObject<Window>().document.querySelector(`meta[name=${metaName}]`);
272-
return el ? el.getAttribute('content') : null;
271+
const globalObject = getGlobalObject<Window>();
272+
273+
// DOM/querySelector is not available in all environments
274+
if (globalObject.document && globalObject.document.querySelector) {
275+
const el = globalObject.document.querySelector(`meta[name=${metaName}]`);
276+
return el ? el.getAttribute('content') : null;
277+
} else {
278+
return null;
279+
}
273280
}

0 commit comments

Comments
 (0)