fix(tracker-fetch;tracker-axios):prevent multiple plugin use on the same app/axios instance

This commit is contained in:
Alex Kaminskii 2022-12-16 12:10:14 +01:00
parent 72bf5916bb
commit 47158814f2
4 changed files with 15 additions and 5 deletions

View file

@ -1,7 +1,7 @@
{
"name": "@openreplay/tracker-axios",
"description": "Tracker plugin for axios requests recording",
"version": "3.6.1",
"version": "3.6.2",
"keywords": [
"axios",
"logging",

View file

@ -52,9 +52,14 @@ export default function(opts: Partial<Options> = {}) {
opts,
);
return (app: App | null) => {
if (app === null) {
if (app === null ||
// @ts-ignore - a catch for the developers who apply a plugin several times
options.instance.__openreplayAxiosInstalled__
) {
return;
}
// @ts-ignore
options.instance.__openreplayAxiosInstalled__ = true
const ihOpt = options.ignoreHeaders
const isHIgnoring = Array.isArray(ihOpt)

View file

@ -1,7 +1,7 @@
{
"name": "@openreplay/tracker-fetch",
"description": "Tracker plugin for fetch requests recording ",
"version": "3.6.1",
"version": "3.6.2",
"keywords": [
"fetch",
"logging",

View file

@ -37,7 +37,7 @@ export default function(opts: Partial<Options> = {}): (app: App | null) => Windo
if (typeof window === 'undefined') {
// not in browser (SSR)
return () => opts.fetch || null
}
}
const options: Options = Object.assign(
{
@ -53,9 +53,14 @@ export default function(opts: Partial<Options> = {}): (app: App | null) => Windo
}
return (app: App | null) => {
if (app === null) {
if (app === null ||
// @ts-ignore - a catch for the developers who apply a plugin several times
app.__fetchInstalled__
) {
return options.fetch
}
// @ts-ignore
app.__fetchInstalled__ = true
const ihOpt = options.ignoreHeaders
const isHIgnoring = Array.isArray(ihOpt)