@@ -38,12 +38,6 @@ import { defaultRequestInstrumentationOptions, instrumentOutgoingRequests } from
3838
3939export const BROWSER_TRACING_INTEGRATION_ID = 'BrowserTracing' ;
4040
41- /**
42- * This is just a small wrapper that makes `document` optional.
43- * We want to be extra-safe and always check that this exists, to ensure weird environments do not blow up.
44- */
45- const optionalWindowDocument = WINDOW . document as ( typeof WINDOW ) [ 'document' ] | undefined ;
46-
4741interface RouteInfo {
4842 name : string | undefined ;
4943 source : TransactionSource | undefined ;
@@ -195,6 +189,12 @@ const DEFAULT_BROWSER_TRACING_OPTIONS: BrowserTracingOptions = {
195189 * We explicitly export the proper type here, as this has to be extended in some cases.
196190 */
197191export const browserTracingIntegration = ( ( _options : Partial < BrowserTracingOptions > = { } ) => {
192+ /**
193+ * This is just a small wrapper that makes `document` optional.
194+ * We want to be extra-safe and always check that this exists, to ensure weird environments do not blow up.
195+ */
196+ const optionalWindowDocument = WINDOW . document as ( typeof WINDOW ) [ 'document' ] | undefined ;
197+
198198 registerSpanErrorInstrumentation ( ) ;
199199
200200 const {
@@ -467,6 +467,12 @@ export function startBrowserTracingNavigationSpan(client: Client, spanOptions: S
467467
468468/** Returns the value of a meta tag */
469469export function getMetaContent ( metaName : string ) : string | undefined {
470+ /**
471+ * This is just a small wrapper that makes `document` optional.
472+ * We want to be extra-safe and always check that this exists, to ensure weird environments do not blow up.
473+ */
474+ const optionalWindowDocument = WINDOW . document as ( typeof WINDOW ) [ 'document' ] | undefined ;
475+
470476 const metaTag = optionalWindowDocument && optionalWindowDocument . querySelector ( `meta[name=${ metaName } ]` ) ;
471477 return ( metaTag && metaTag . getAttribute ( 'content' ) ) || undefined ;
472478}
@@ -478,6 +484,12 @@ function registerInteractionListener(
478484 childSpanTimeout : BrowserTracingOptions [ 'childSpanTimeout' ] ,
479485 latestRoute : RouteInfo ,
480486) : void {
487+ /**
488+ * This is just a small wrapper that makes `document` optional.
489+ * We want to be extra-safe and always check that this exists, to ensure weird environments do not blow up.
490+ */
491+ const optionalWindowDocument = WINDOW . document as ( typeof WINDOW ) [ 'document' ] | undefined ;
492+
481493 let inflightInteractionSpan : Span | undefined ;
482494 const registerInteractionTransaction = ( ) : void => {
483495 const op = 'ui.action.click' ;
0 commit comments