Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion packages/browser/src/integrations/trycatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export class TryCatch implements Integration {
*/
const wrappedEventHandler = (fn as unknown) as WrappedFunction;
try {
const originalEventHandler = wrappedEventHandler?.__sentry_wrapped__;
const originalEventHandler = wrappedEventHandler && wrappedEventHandler.__sentry_wrapped__;
if (originalEventHandler) {
originalRemoveEventListener.call(this, eventName, originalEventHandler, options);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/browser/src/integrations/useragent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ export class UserAgent implements Integration {
}

// grab as much info as exists and add it to the event
const url = event.request?.url || global.location?.href;
const url = (event.request && event.request.url) || (global.location && global.location.href);
const { referrer } = global.document || {};
const { userAgent } = global.navigator || {};

const headers = {
...event.request?.headers,
...(event.request && event.request.headers),
...(referrer && { Referer: referrer }),
...(userAgent && { 'User-Agent': userAgent }),
};
Expand Down
7 changes: 4 additions & 3 deletions packages/browser/src/transports/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@ export function getNativeFetchImplementation(): FetchImpl {
const document = global.document;
let fetchImpl = global.fetch;
// eslint-disable-next-line deprecation/deprecation
if (typeof document?.createElement === `function`) {
if (document && typeof document.createElement === `function`) {
try {
const sandbox = document.createElement('iframe');
sandbox.hidden = true;
document.head.appendChild(sandbox);
if (sandbox.contentWindow?.fetch) {
fetchImpl = sandbox.contentWindow.fetch;
const contentWindow = sandbox.contentWindow;
if (contentWindow && contentWindow.fetch) {
fetchImpl = contentWindow.fetch;
}
document.head.removeChild(sandbox);
} catch (e) {
Expand Down