Skip to content

Commit

Permalink
fix(tracing): Don't use querySelector when not available (#5160)
Browse files Browse the repository at this point in the history
  • Loading branch information
lforst authored May 24, 2022
1 parent bbc9d3d commit fa5712e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/tracing/src/browser/browsertracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,13 @@ export function extractTraceDataFromMetaTags(): Partial<TransactionContext> | un

/** Returns the value of a meta tag */
export function getMetaContent(metaName: string): string | null {
const el = getGlobalObject<Window>().document.querySelector(`meta[name=${metaName}]`);
return el ? el.getAttribute('content') : null;
const globalObject = getGlobalObject<Window>();

// DOM/querySelector is not available in all environments
if (globalObject.document && globalObject.document.querySelector) {
const el = globalObject.document.querySelector(`meta[name=${metaName}]`);
return el ? el.getAttribute('content') : null;
} else {
return null;
}
}

0 comments on commit fa5712e

Please sign in to comment.