Skip to content

fix: Revert that bundle will be appended to body #1943

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/browser/src/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
// come out in the wrong order. Because of that we don't need async=1 as GA does.
// it was probably(?) a legacy behavior that they left to not modify few years old snippet
// https://www.html5rocks.com/en/tutorials/speed/script-loading/
var _currentScriptTag = _document.getElementsByTagName(_script)[0];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if it's null?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It cannot be null, as it's our own loader's script tag.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless it's some odd edge-case scenario in non-browser environment, but you shouldn't use a loader then anyway.

var _newScriptTag = _document.createElement(_script);
_newScriptTag.src = _sdkBundleUrl;
_newScriptTag.crossorigin = 'anonymous';
Expand Down Expand Up @@ -90,9 +91,7 @@
}
});

// We append the script to the body because if you use an `onload` callback it could happen that
// the `onLoad` of the already injected SDK will be called, which breaks the setup flow.
document.body.appendChild(_newScriptTag);
_currentScriptTag.parentNode.insertBefore(_newScriptTag, _currentScriptTag);
}

function sdkLoaded(callbacks, SDK) {
Expand All @@ -107,8 +106,9 @@
}

var initAlreadyCalled = false;
var __sentry = _window['__SENTRY__'];
// If there is a global __SENTRY__ that means that in any of the callbacks init() was already invoked
if (!(typeof _window['__SENTRY__'] === 'undefined')) {
if (!(typeof __sentry === 'undefined') && __sentry.hub && __sentry.hub.getClient()) {
initAlreadyCalled = true;
}

Expand Down