network proxy: prevent referring to window object on import, fixes #2742
This commit is contained in:
parent
f321ffbdda
commit
769d8851bb
2 changed files with 3 additions and 2 deletions
|
|
@ -74,7 +74,7 @@ export class BeaconProxyHandler<T extends typeof navigator.sendBeacon> implement
|
|||
}
|
||||
|
||||
export default class BeaconProxy {
|
||||
public static origSendBeacon = window?.navigator?.sendBeacon
|
||||
public static origSendBeacon = typeof window !== 'undefined' ? window.navigator?.sendBeacon : undefined
|
||||
|
||||
public static hasSendBeacon() {
|
||||
return !!BeaconProxy.origSendBeacon
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ export default function createNetworkProxy(
|
|||
},
|
||||
tokenUrlMatcher?: (url: string) => boolean,
|
||||
): void {
|
||||
if (!context) return;
|
||||
if (modules.xhr) {
|
||||
if (context.XMLHttpRequest) {
|
||||
context.XMLHttpRequest = XHRProxy.create(
|
||||
|
|
@ -83,7 +84,7 @@ export default function createNetworkProxy(
|
|||
}
|
||||
}
|
||||
if (modules.beacon) {
|
||||
if (context?.navigator?.sendBeacon) {
|
||||
if (context.navigator?.sendBeacon) {
|
||||
context.navigator.sendBeacon = BeaconProxy.create(
|
||||
ignoredHeaders,
|
||||
setSessionTokenHeader,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue