@openreplay/tracker 9.0.2 → 9.0.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/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- # 9.0.2
1
+ # 9.0.2 & 9.0.3
2
2
 
3
3
  - fix "setSessionTokenHeader" method
4
4
 
package/cjs/app/index.js CHANGED
@@ -35,7 +35,7 @@ class App {
35
35
  this.stopCallbacks = [];
36
36
  this.commitCallbacks = [];
37
37
  this.activityState = ActivityState.NotActive;
38
- this.version = '9.0.2'; // TODO: version compatability check inside each plugin.
38
+ this.version = '9.0.3'; // TODO: version compatability check inside each plugin.
39
39
  this.compressionThreshold = 24 * 1000;
40
40
  this.restartAttempts = 0;
41
41
  this.bc = null;
package/cjs/index.js CHANGED
@@ -153,7 +153,7 @@ class API {
153
153
  // no-cors issue only with text/plain or not-set Content-Type
154
154
  // req.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
155
155
  req.send(JSON.stringify({
156
- trackerVersion: '9.0.2',
156
+ trackerVersion: '9.0.3',
157
157
  projectKey: options.projectKey,
158
158
  doNotTrack,
159
159
  // TODO: add precise reason (an exact API missing)
@@ -125,8 +125,23 @@ class FetchProxyHandler {
125
125
  const item = new networkMessage_js_1.default(this.ignoredHeaders, this.setSessionTokenHeader, this.sanitize);
126
126
  this.beforeFetch(item, input, init);
127
127
  this.setSessionTokenHeader((name, value) => {
128
- var _a;
129
- argsList[1] = Object.assign(Object.assign({}, argsList[1]), { headers: Object.assign(Object.assign({}, (_a = argsList[1]) === null || _a === void 0 ? void 0 : _a.headers), { [name]: value }) });
128
+ if (argsList[1] === undefined && argsList[0] instanceof Request) {
129
+ return argsList[0].headers.append(name, value);
130
+ }
131
+ else {
132
+ if (argsList[1].headers === undefined) {
133
+ argsList[1].headers = {};
134
+ }
135
+ if (argsList[1].headers instanceof Headers) {
136
+ argsList[1].headers.append(name, value);
137
+ }
138
+ else if (Array.isArray(argsList[1].headers)) {
139
+ argsList[1].headers.push([name, value]);
140
+ }
141
+ else {
142
+ argsList[1].headers[name] = value;
143
+ }
144
+ }
130
145
  });
131
146
  return target.apply(window, argsList)
132
147
  .then(this.afterFetch(item))
@@ -35,7 +35,9 @@ class XHRProxyHandler {
35
35
  case 'open':
36
36
  return this.getOpen(target);
37
37
  case 'send':
38
+ console.log('sending');
38
39
  this.setSessionTokenHeader((name, value) => {
40
+ console.log('setting header', name, value);
39
41
  target.setRequestHeader(name, value);
40
42
  });
41
43
  return this.getSend(target);
@@ -113,6 +115,7 @@ class XHRProxyHandler {
113
115
  getSetRequestHeader(target) {
114
116
  const targetFunction = Reflect.get(target, 'setRequestHeader');
115
117
  return (...args) => {
118
+ console.log('called here', this.item.requestHeader);
116
119
  if (!this.item.requestHeader) {
117
120
  this.item.requestHeader = {};
118
121
  }
package/lib/app/index.js CHANGED
@@ -32,7 +32,7 @@ export default class App {
32
32
  this.stopCallbacks = [];
33
33
  this.commitCallbacks = [];
34
34
  this.activityState = ActivityState.NotActive;
35
- this.version = '9.0.2'; // TODO: version compatability check inside each plugin.
35
+ this.version = '9.0.3'; // TODO: version compatability check inside each plugin.
36
36
  this.compressionThreshold = 24 * 1000;
37
37
  this.restartAttempts = 0;
38
38
  this.bc = null;
package/lib/index.js CHANGED
@@ -148,7 +148,7 @@ export default class API {
148
148
  // no-cors issue only with text/plain or not-set Content-Type
149
149
  // req.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
150
150
  req.send(JSON.stringify({
151
- trackerVersion: '9.0.2',
151
+ trackerVersion: '9.0.3',
152
152
  projectKey: options.projectKey,
153
153
  doNotTrack,
154
154
  // TODO: add precise reason (an exact API missing)
@@ -121,8 +121,23 @@ export class FetchProxyHandler {
121
121
  const item = new NetworkMessage(this.ignoredHeaders, this.setSessionTokenHeader, this.sanitize);
122
122
  this.beforeFetch(item, input, init);
123
123
  this.setSessionTokenHeader((name, value) => {
124
- var _a;
125
- argsList[1] = Object.assign(Object.assign({}, argsList[1]), { headers: Object.assign(Object.assign({}, (_a = argsList[1]) === null || _a === void 0 ? void 0 : _a.headers), { [name]: value }) });
124
+ if (argsList[1] === undefined && argsList[0] instanceof Request) {
125
+ return argsList[0].headers.append(name, value);
126
+ }
127
+ else {
128
+ if (argsList[1].headers === undefined) {
129
+ argsList[1].headers = {};
130
+ }
131
+ if (argsList[1].headers instanceof Headers) {
132
+ argsList[1].headers.append(name, value);
133
+ }
134
+ else if (Array.isArray(argsList[1].headers)) {
135
+ argsList[1].headers.push([name, value]);
136
+ }
137
+ else {
138
+ argsList[1].headers[name] = value;
139
+ }
140
+ }
126
141
  });
127
142
  return target.apply(window, argsList)
128
143
  .then(this.afterFetch(item))
@@ -32,7 +32,9 @@ export class XHRProxyHandler {
32
32
  case 'open':
33
33
  return this.getOpen(target);
34
34
  case 'send':
35
+ console.log('sending');
35
36
  this.setSessionTokenHeader((name, value) => {
37
+ console.log('setting header', name, value);
36
38
  target.setRequestHeader(name, value);
37
39
  });
38
40
  return this.getSend(target);
@@ -110,6 +112,7 @@ export class XHRProxyHandler {
110
112
  getSetRequestHeader(target) {
111
113
  const targetFunction = Reflect.get(target, 'setRequestHeader');
112
114
  return (...args) => {
115
+ console.log('called here', this.item.requestHeader);
113
116
  if (!this.item.requestHeader) {
114
117
  this.item.requestHeader = {};
115
118
  }
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": "9.0.2",
4
+ "version": "9.0.3",
5
5
  "keywords": [
6
6
  "logging",
7
7
  "replay"