Skip to content

Commit

Permalink
fix for tests...
Browse files Browse the repository at this point in the history
  • Loading branch information
mydea committed Dec 19, 2024
1 parent 932c20f commit 5a0cb39
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions packages/browser/src/tracing/browserTracingIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ import { defaultRequestInstrumentationOptions, instrumentOutgoingRequests } from

export const BROWSER_TRACING_INTEGRATION_ID = 'BrowserTracing';

/**
* This is just a small wrapper that makes `document` optional.
* We want to be extra-safe and always check that this exists, to ensure weird environments do not blow up.
*/
const optionalWindowDocument = WINDOW.document as (typeof WINDOW)['document'] | undefined;

interface RouteInfo {
name: string | undefined;
source: TransactionSource | undefined;
Expand Down Expand Up @@ -195,6 +189,12 @@ const DEFAULT_BROWSER_TRACING_OPTIONS: BrowserTracingOptions = {
* We explicitly export the proper type here, as this has to be extended in some cases.
*/
export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptions> = {}) => {
/**
* This is just a small wrapper that makes `document` optional.
* We want to be extra-safe and always check that this exists, to ensure weird environments do not blow up.
*/
const optionalWindowDocument = WINDOW.document as (typeof WINDOW)['document'] | undefined;

registerSpanErrorInstrumentation();

const {
Expand Down Expand Up @@ -467,6 +467,12 @@ export function startBrowserTracingNavigationSpan(client: Client, spanOptions: S

/** Returns the value of a meta tag */
export function getMetaContent(metaName: string): string | undefined {
/**
* This is just a small wrapper that makes `document` optional.
* We want to be extra-safe and always check that this exists, to ensure weird environments do not blow up.
*/
const optionalWindowDocument = WINDOW.document as (typeof WINDOW)['document'] | undefined;

const metaTag = optionalWindowDocument && optionalWindowDocument.querySelector(`meta[name=${metaName}]`);
return (metaTag && metaTag.getAttribute('content')) || undefined;
}
Expand All @@ -478,6 +484,12 @@ function registerInteractionListener(
childSpanTimeout: BrowserTracingOptions['childSpanTimeout'],
latestRoute: RouteInfo,
): void {
/**
* This is just a small wrapper that makes `document` optional.
* We want to be extra-safe and always check that this exists, to ensure weird environments do not blow up.
*/
const optionalWindowDocument = WINDOW.document as (typeof WINDOW)['document'] | undefined;

let inflightInteractionSpan: Span | undefined;
const registerInteractionTransaction = (): void => {
const op = 'ui.action.click';
Expand Down

0 comments on commit 5a0cb39

Please sign in to comment.