@openreplay/tracker 5.0.5-beta.2 → 5.0.5-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/app/index.js +1 -1
- package/cjs/index.js +1 -1
- package/cjs/modules/axiosSpy.js +40 -2
- package/lib/app/index.js +1 -1
- package/lib/index.js +1 -1
- package/lib/modules/axiosSpy.js +40 -2
- package/package.json +1 -1
package/cjs/app/index.js
CHANGED
|
@@ -33,7 +33,7 @@ class App {
|
|
|
33
33
|
this.stopCallbacks = [];
|
|
34
34
|
this.commitCallbacks = [];
|
|
35
35
|
this.activityState = ActivityState.NotActive;
|
|
36
|
-
this.version = '5.0.5-beta.
|
|
36
|
+
this.version = '5.0.5-beta.3'; // TODO: version compatability check inside each plugin.
|
|
37
37
|
this._usingOldFetchPlugin = false;
|
|
38
38
|
this.delay = 0;
|
|
39
39
|
this.projectKey = projectKey;
|
package/cjs/index.js
CHANGED
|
@@ -140,7 +140,7 @@ class API {
|
|
|
140
140
|
// no-cors issue only with text/plain or not-set Content-Type
|
|
141
141
|
// req.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
|
142
142
|
req.send(JSON.stringify({
|
|
143
|
-
trackerVersion: '5.0.5-beta.
|
|
143
|
+
trackerVersion: '5.0.5-beta.3',
|
|
144
144
|
projectKey: options.projectKey,
|
|
145
145
|
doNotTrack,
|
|
146
146
|
// TODO: add precise reason (an exact API missing)
|
package/cjs/modules/axiosSpy.js
CHANGED
|
@@ -5,19 +5,57 @@ const utils_js_1 = require("../utils.js");
|
|
|
5
5
|
function default_1(app, instance, opts, sanitize, stringify) {
|
|
6
6
|
app.debug.log('Openreplay: attaching axios spy to instance', instance);
|
|
7
7
|
function captureResponseData(axiosResponseObj) {
|
|
8
|
+
app.debug.log('Openreplay: capturing axios response data', axiosResponseObj);
|
|
8
9
|
const { headers: reqHs, data: reqData, method, url } = axiosResponseObj.config;
|
|
9
10
|
const { data: rData, headers: rHs, status: globStatus, response } = axiosResponseObj;
|
|
10
11
|
const { data: resData, headers: resHs, status: resStatus } = response || {};
|
|
12
|
+
const ihOpt = opts.ignoreHeaders;
|
|
13
|
+
const isHIgnoring = Array.isArray(ihOpt) ? (name) => ihOpt.includes(name) : () => ihOpt;
|
|
14
|
+
function writeHeader(hsObj, header) {
|
|
15
|
+
if (!isHIgnoring(header[0])) {
|
|
16
|
+
hsObj[header[0]] = header[1];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
let requestHs = {};
|
|
20
|
+
let responseHs = {};
|
|
21
|
+
if (reqHs.toJSON) {
|
|
22
|
+
requestHs = reqHs.toJSON();
|
|
23
|
+
}
|
|
24
|
+
else if (reqHs instanceof Headers) {
|
|
25
|
+
reqHs.forEach((v, n) => writeHeader(requestHs, [n, v]));
|
|
26
|
+
}
|
|
27
|
+
else if (Array.isArray(reqHs)) {
|
|
28
|
+
reqHs.forEach((h) => writeHeader(requestHs, h));
|
|
29
|
+
}
|
|
30
|
+
else if (typeof reqHs === 'object') {
|
|
31
|
+
Object.entries(reqHs).forEach((h) => writeHeader(requestHs, h));
|
|
32
|
+
}
|
|
33
|
+
const usedResHeader = resHs ? resHs : rHs;
|
|
34
|
+
if (usedResHeader.toJSON) {
|
|
35
|
+
responseHs = usedResHeader.toJSON();
|
|
36
|
+
}
|
|
37
|
+
else if (usedResHeader instanceof Headers) {
|
|
38
|
+
usedResHeader.forEach((v, n) => writeHeader(responseHs, [n, v]));
|
|
39
|
+
}
|
|
40
|
+
else if (Array.isArray(usedResHeader)) {
|
|
41
|
+
usedResHeader.forEach((h) => writeHeader(responseHs, h));
|
|
42
|
+
}
|
|
43
|
+
else if (typeof usedResHeader === 'object') {
|
|
44
|
+
Object.entries(usedResHeader).forEach(([n, v]) => {
|
|
45
|
+
if (!isHIgnoring(n))
|
|
46
|
+
responseHs[n] = v;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
11
49
|
const reqResInfo = sanitize({
|
|
12
50
|
url,
|
|
13
51
|
method: method || '',
|
|
14
52
|
status: globStatus || resStatus || 0,
|
|
15
53
|
request: {
|
|
16
|
-
headers:
|
|
54
|
+
headers: requestHs,
|
|
17
55
|
body: reqData,
|
|
18
56
|
},
|
|
19
57
|
response: {
|
|
20
|
-
headers:
|
|
58
|
+
headers: responseHs,
|
|
21
59
|
body: resData || rData,
|
|
22
60
|
},
|
|
23
61
|
});
|
package/lib/app/index.js
CHANGED
|
@@ -30,7 +30,7 @@ export default class App {
|
|
|
30
30
|
this.stopCallbacks = [];
|
|
31
31
|
this.commitCallbacks = [];
|
|
32
32
|
this.activityState = ActivityState.NotActive;
|
|
33
|
-
this.version = '5.0.5-beta.
|
|
33
|
+
this.version = '5.0.5-beta.3'; // TODO: version compatability check inside each plugin.
|
|
34
34
|
this._usingOldFetchPlugin = false;
|
|
35
35
|
this.delay = 0;
|
|
36
36
|
this.projectKey = projectKey;
|
package/lib/index.js
CHANGED
|
@@ -135,7 +135,7 @@ export default class API {
|
|
|
135
135
|
// no-cors issue only with text/plain or not-set Content-Type
|
|
136
136
|
// req.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
|
137
137
|
req.send(JSON.stringify({
|
|
138
|
-
trackerVersion: '5.0.5-beta.
|
|
138
|
+
trackerVersion: '5.0.5-beta.3',
|
|
139
139
|
projectKey: options.projectKey,
|
|
140
140
|
doNotTrack,
|
|
141
141
|
// TODO: add precise reason (an exact API missing)
|
package/lib/modules/axiosSpy.js
CHANGED
|
@@ -3,19 +3,57 @@ import { getTimeOrigin } from '../utils.js';
|
|
|
3
3
|
export default function (app, instance, opts, sanitize, stringify) {
|
|
4
4
|
app.debug.log('Openreplay: attaching axios spy to instance', instance);
|
|
5
5
|
function captureResponseData(axiosResponseObj) {
|
|
6
|
+
app.debug.log('Openreplay: capturing axios response data', axiosResponseObj);
|
|
6
7
|
const { headers: reqHs, data: reqData, method, url } = axiosResponseObj.config;
|
|
7
8
|
const { data: rData, headers: rHs, status: globStatus, response } = axiosResponseObj;
|
|
8
9
|
const { data: resData, headers: resHs, status: resStatus } = response || {};
|
|
10
|
+
const ihOpt = opts.ignoreHeaders;
|
|
11
|
+
const isHIgnoring = Array.isArray(ihOpt) ? (name) => ihOpt.includes(name) : () => ihOpt;
|
|
12
|
+
function writeHeader(hsObj, header) {
|
|
13
|
+
if (!isHIgnoring(header[0])) {
|
|
14
|
+
hsObj[header[0]] = header[1];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
let requestHs = {};
|
|
18
|
+
let responseHs = {};
|
|
19
|
+
if (reqHs.toJSON) {
|
|
20
|
+
requestHs = reqHs.toJSON();
|
|
21
|
+
}
|
|
22
|
+
else if (reqHs instanceof Headers) {
|
|
23
|
+
reqHs.forEach((v, n) => writeHeader(requestHs, [n, v]));
|
|
24
|
+
}
|
|
25
|
+
else if (Array.isArray(reqHs)) {
|
|
26
|
+
reqHs.forEach((h) => writeHeader(requestHs, h));
|
|
27
|
+
}
|
|
28
|
+
else if (typeof reqHs === 'object') {
|
|
29
|
+
Object.entries(reqHs).forEach((h) => writeHeader(requestHs, h));
|
|
30
|
+
}
|
|
31
|
+
const usedResHeader = resHs ? resHs : rHs;
|
|
32
|
+
if (usedResHeader.toJSON) {
|
|
33
|
+
responseHs = usedResHeader.toJSON();
|
|
34
|
+
}
|
|
35
|
+
else if (usedResHeader instanceof Headers) {
|
|
36
|
+
usedResHeader.forEach((v, n) => writeHeader(responseHs, [n, v]));
|
|
37
|
+
}
|
|
38
|
+
else if (Array.isArray(usedResHeader)) {
|
|
39
|
+
usedResHeader.forEach((h) => writeHeader(responseHs, h));
|
|
40
|
+
}
|
|
41
|
+
else if (typeof usedResHeader === 'object') {
|
|
42
|
+
Object.entries(usedResHeader).forEach(([n, v]) => {
|
|
43
|
+
if (!isHIgnoring(n))
|
|
44
|
+
responseHs[n] = v;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
9
47
|
const reqResInfo = sanitize({
|
|
10
48
|
url,
|
|
11
49
|
method: method || '',
|
|
12
50
|
status: globStatus || resStatus || 0,
|
|
13
51
|
request: {
|
|
14
|
-
headers:
|
|
52
|
+
headers: requestHs,
|
|
15
53
|
body: reqData,
|
|
16
54
|
},
|
|
17
55
|
response: {
|
|
18
|
-
headers:
|
|
56
|
+
headers: responseHs,
|
|
19
57
|
body: resData || rData,
|
|
20
58
|
},
|
|
21
59
|
});
|