Skip to content

Commit

Permalink
code review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Lms24 committed Sep 18, 2024
1 parent 03d5c8f commit 0d1adc9
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/browser/src/utils/lazyLoadIntegration.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { SDK_VERSION, getClient } from '@sentry/core';
import type { IntegrationFn } from '@sentry/types';
import { logger } from '@sentry/utils';
import type { BrowserClient } from '../client';
import { WINDOW } from '../helpers';

Expand Down Expand Up @@ -70,12 +69,12 @@ export async function lazyLoadIntegration(
});

const currentScript = WINDOW.document.currentScript;
const parent = (currentScript && currentScript.parentElement) || WINDOW.document.body || WINDOW.document.head;
const parent = WINDOW.document.body || WINDOW.document.head || (currentScript && currentScript.parentElement);

if (parent) {
parent.appendChild(script);
} else {
logger.error(`Could not find parent element to insert lazy-loaded ${name} script`);
throw new Error(`Could not find parent element to insert lazy-loaded ${name} script`);
}

try {
Expand Down

0 comments on commit 0d1adc9

Please sign in to comment.