@openreplay/tracker 7.0.1 → 7.0.2-beta.1

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 CHANGED
@@ -34,7 +34,7 @@ class App {
34
34
  this.stopCallbacks = [];
35
35
  this.commitCallbacks = [];
36
36
  this.activityState = ActivityState.NotActive;
37
- this.version = '7.0.1'; // TODO: version compatability check inside each plugin.
37
+ this.version = '7.0.2-beta.1'; // TODO: version compatability check inside each plugin.
38
38
  this.compressionThreshold = 24 * 1000;
39
39
  this.restartAttempts = 0;
40
40
  this._usingOldFetchPlugin = false;
package/cjs/index.js CHANGED
@@ -142,7 +142,7 @@ class API {
142
142
  // no-cors issue only with text/plain or not-set Content-Type
143
143
  // req.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
144
144
  req.send(JSON.stringify({
145
- trackerVersion: '7.0.1',
145
+ trackerVersion: '7.0.2-beta.1',
146
146
  projectKey: options.projectKey,
147
147
  doNotTrack,
148
148
  // TODO: add precise reason (an exact API missing)
@@ -7,16 +7,55 @@ function default_1(app, instance, opts, sanitize, stringify) {
7
7
  const { headers: reqHs, data: reqData, method, url } = axiosResponseObj.config;
8
8
  const { data: rData, headers: rHs, status: globStatus, response } = axiosResponseObj;
9
9
  const { data: resData, headers: resHs, status: resStatus } = response || {};
10
+ const ihOpt = opts.ignoreHeaders;
11
+ const isHIgnoring = Array.isArray(ihOpt)
12
+ ? (name) => ihOpt.includes(name)
13
+ : () => 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
+ }
10
49
  const reqResInfo = sanitize({
11
50
  url,
12
51
  method: method || '',
13
52
  status: globStatus || resStatus || 0,
14
53
  request: {
15
- headers: reqHs.toJSON(),
54
+ headers: requestHs,
16
55
  body: reqData,
17
56
  },
18
57
  response: {
19
- headers: (resHs === null || resHs === void 0 ? void 0 : resHs.toJSON()) || rHs.toJSON(),
58
+ headers: responseHs,
20
59
  body: resData || rData,
21
60
  },
22
61
  });
package/lib/app/index.js CHANGED
@@ -31,7 +31,7 @@ export default class App {
31
31
  this.stopCallbacks = [];
32
32
  this.commitCallbacks = [];
33
33
  this.activityState = ActivityState.NotActive;
34
- this.version = '7.0.1'; // TODO: version compatability check inside each plugin.
34
+ this.version = '7.0.2-beta.1'; // TODO: version compatability check inside each plugin.
35
35
  this.compressionThreshold = 24 * 1000;
36
36
  this.restartAttempts = 0;
37
37
  this._usingOldFetchPlugin = false;
package/lib/index.js CHANGED
@@ -137,7 +137,7 @@ export default class API {
137
137
  // no-cors issue only with text/plain or not-set Content-Type
138
138
  // req.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
139
139
  req.send(JSON.stringify({
140
- trackerVersion: '7.0.1',
140
+ trackerVersion: '7.0.2-beta.1',
141
141
  projectKey: options.projectKey,
142
142
  doNotTrack,
143
143
  // TODO: add precise reason (an exact API missing)
@@ -5,16 +5,55 @@ export default function (app, instance, opts, sanitize, stringify) {
5
5
  const { headers: reqHs, data: reqData, method, url } = axiosResponseObj.config;
6
6
  const { data: rData, headers: rHs, status: globStatus, response } = axiosResponseObj;
7
7
  const { data: resData, headers: resHs, status: resStatus } = response || {};
8
+ const ihOpt = opts.ignoreHeaders;
9
+ const isHIgnoring = Array.isArray(ihOpt)
10
+ ? (name) => ihOpt.includes(name)
11
+ : () => 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
+ }
8
47
  const reqResInfo = sanitize({
9
48
  url,
10
49
  method: method || '',
11
50
  status: globStatus || resStatus || 0,
12
51
  request: {
13
- headers: reqHs.toJSON(),
52
+ headers: requestHs,
14
53
  body: reqData,
15
54
  },
16
55
  response: {
17
- headers: (resHs === null || resHs === void 0 ? void 0 : resHs.toJSON()) || rHs.toJSON(),
56
+ headers: responseHs,
18
57
  body: resData || rData,
19
58
  },
20
59
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@openreplay/tracker",
3
3
  "description": "The OpenReplay tracker main package",
4
- "version": "7.0.1",
4
+ "version": "7.0.2-beta.1",
5
5
  "keywords": [
6
6
  "logging",
7
7
  "replay"