fix(tracker): add check for network api in client; 9.0.1
This commit is contained in:
parent
493886f758
commit
0d9c225c1d
2 changed files with 27 additions and 15 deletions
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@openreplay/tracker",
|
||||
"description": "The OpenReplay tracker main package",
|
||||
"version": "9.0.0",
|
||||
"version": "9.0.1",
|
||||
"keywords": [
|
||||
"logging",
|
||||
"replay"
|
||||
|
|
|
|||
|
|
@ -3,6 +3,10 @@ import XHRProxy from './xhrProxy.js'
|
|||
import { RequestResponseData } from './types.js'
|
||||
import { NetworkRequest } from '../../../common/messages.gen.js'
|
||||
|
||||
const getWarning = (api: string) =>
|
||||
console.warn(`Openreplay: Can't find ${api} in global context.
|
||||
If you're using serverside rendering in your app, make sure that tracker is loaded dynamically, otherwise ${api} won't be tracked.`)
|
||||
|
||||
export default function setProxy(
|
||||
context: typeof globalThis,
|
||||
ignoredHeaders: boolean | string[],
|
||||
|
|
@ -11,18 +15,26 @@ export default function setProxy(
|
|||
sendMessage: (message: NetworkRequest) => void,
|
||||
isServiceUrl: (url: string) => boolean,
|
||||
) {
|
||||
context.XMLHttpRequest = XHRProxy.create(
|
||||
ignoredHeaders,
|
||||
setSessionTokenHeader,
|
||||
sanitize,
|
||||
sendMessage,
|
||||
isServiceUrl,
|
||||
)
|
||||
context.fetch = FetchProxy.create(
|
||||
ignoredHeaders,
|
||||
setSessionTokenHeader,
|
||||
sanitize,
|
||||
sendMessage,
|
||||
isServiceUrl,
|
||||
)
|
||||
if (context.XMLHttpRequest) {
|
||||
context.XMLHttpRequest = XHRProxy.create(
|
||||
ignoredHeaders,
|
||||
setSessionTokenHeader,
|
||||
sanitize,
|
||||
sendMessage,
|
||||
isServiceUrl,
|
||||
)
|
||||
} else {
|
||||
getWarning('XMLHttpRequest')
|
||||
}
|
||||
if (context.fetch) {
|
||||
context.fetch = FetchProxy.create(
|
||||
ignoredHeaders,
|
||||
setSessionTokenHeader,
|
||||
sanitize,
|
||||
sendMessage,
|
||||
isServiceUrl,
|
||||
)
|
||||
} else {
|
||||
getWarning('fetch')
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue