@openreplay/tracker 5.0.5-beta.6 → 5.0.5-beta.8
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/network.js +28 -11
- package/lib/app/index.js +1 -1
- package/lib/index.js +1 -1
- package/lib/modules/network.js +28 -11
- 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.8'; // 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.8',
|
|
144
144
|
projectKey: options.projectKey,
|
|
145
145
|
doNotTrack,
|
|
146
146
|
// TODO: add precise reason (an exact API missing)
|
package/cjs/modules/network.js
CHANGED
|
@@ -165,16 +165,29 @@ function default_1(app, opts = {}) {
|
|
|
165
165
|
});
|
|
166
166
|
xhr.addEventListener('load', app.safe((e) => {
|
|
167
167
|
const { headers: reqHs, body: reqBody } = getXHRRequestDataObject(xhr);
|
|
168
|
-
|
|
168
|
+
if (!xhr.getAllResponseHeaders())
|
|
169
|
+
app.debug.warn('Openreplay: XHR no response headers returned');
|
|
169
170
|
const duration = startTime > 0 ? e.timeStamp - startTime : 0;
|
|
170
171
|
const hString = ignoreHeaders ? '' : xhr.getAllResponseHeaders(); // might be null (though only if no response received though)
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
172
|
+
const headersArr = hString.trim().split(/[\r\n]+/);
|
|
173
|
+
const headerMap = {};
|
|
174
|
+
headersArr.forEach(function (line) {
|
|
175
|
+
const parts = line.split(': ');
|
|
176
|
+
const header = parts.shift();
|
|
177
|
+
if (!isHIgnored(header)) {
|
|
178
|
+
headerMap[header] = parts.join(': ');
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
// const resHs = hString
|
|
182
|
+
// ? hString
|
|
183
|
+
// .split('\r\n')
|
|
184
|
+
// .map((h) => h.split(':'))
|
|
185
|
+
// .filter((entry) => !isHIgnored(entry[0]))
|
|
186
|
+
// .reduce(
|
|
187
|
+
// (hds, [name, value]) => ({ ...hds, [name]: value }),
|
|
188
|
+
// {} as Record<string, string>,
|
|
189
|
+
// )
|
|
190
|
+
// : {}
|
|
178
191
|
const method = strMethod(initMethod);
|
|
179
192
|
const reqResInfo = sanitize({
|
|
180
193
|
url: String(url),
|
|
@@ -185,13 +198,19 @@ function default_1(app, opts = {}) {
|
|
|
185
198
|
body: reqBody,
|
|
186
199
|
},
|
|
187
200
|
response: {
|
|
188
|
-
headers:
|
|
201
|
+
headers: headerMap,
|
|
189
202
|
body: xhr.response,
|
|
190
203
|
},
|
|
191
204
|
});
|
|
192
205
|
if (!reqResInfo) {
|
|
193
206
|
return;
|
|
194
207
|
}
|
|
208
|
+
app.debug.log('Openreplay: XHR load', reqResInfo.url, {
|
|
209
|
+
instance: xhr,
|
|
210
|
+
headers: xhr.getAllResponseHeaders(),
|
|
211
|
+
requestData: getXHRRequestDataObject(xhr),
|
|
212
|
+
result: (0, messages_gen_js_1.NetworkRequest)('xhr', method, String(reqResInfo.url), stringify(reqResInfo.request), stringify(reqResInfo.response), xhr.status, startTime + (0, utils_js_1.getTimeOrigin)(), duration),
|
|
213
|
+
}, headerMap);
|
|
195
214
|
app.send((0, messages_gen_js_1.NetworkRequest)('xhr', method, String(reqResInfo.url), stringify(reqResInfo.request), stringify(reqResInfo.response), xhr.status, startTime + (0, utils_js_1.getTimeOrigin)(), duration));
|
|
196
215
|
}));
|
|
197
216
|
//TODO: handle error (though it has no Error API nor any useful information)
|
|
@@ -202,12 +221,10 @@ function default_1(app, opts = {}) {
|
|
|
202
221
|
XMLHttpRequest.prototype.send = function (body) {
|
|
203
222
|
const rdo = getXHRRequestDataObject(this);
|
|
204
223
|
rdo.body = body;
|
|
205
|
-
app.debug.log('Openreplay: ', 'XHR send', rdo, 'XHR Object', this);
|
|
206
224
|
return nativeSend.apply(this, arguments);
|
|
207
225
|
};
|
|
208
226
|
const nativeSetRequestHeader = XMLHttpRequest.prototype.setRequestHeader;
|
|
209
227
|
XMLHttpRequest.prototype.setRequestHeader = function (name, value) {
|
|
210
|
-
app.debug.log('Openreplay: ', name, value, isHIgnored(name), getXHRRequestDataObject(this));
|
|
211
228
|
if (!isHIgnored(name)) {
|
|
212
229
|
const rdo = getXHRRequestDataObject(this);
|
|
213
230
|
rdo.headers[name] = value;
|
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.8'; // 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.8',
|
|
139
139
|
projectKey: options.projectKey,
|
|
140
140
|
doNotTrack,
|
|
141
141
|
// TODO: add precise reason (an exact API missing)
|
package/lib/modules/network.js
CHANGED
|
@@ -163,16 +163,29 @@ export default function (app, opts = {}) {
|
|
|
163
163
|
});
|
|
164
164
|
xhr.addEventListener('load', app.safe((e) => {
|
|
165
165
|
const { headers: reqHs, body: reqBody } = getXHRRequestDataObject(xhr);
|
|
166
|
-
|
|
166
|
+
if (!xhr.getAllResponseHeaders())
|
|
167
|
+
app.debug.warn('Openreplay: XHR no response headers returned');
|
|
167
168
|
const duration = startTime > 0 ? e.timeStamp - startTime : 0;
|
|
168
169
|
const hString = ignoreHeaders ? '' : xhr.getAllResponseHeaders(); // might be null (though only if no response received though)
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
170
|
+
const headersArr = hString.trim().split(/[\r\n]+/);
|
|
171
|
+
const headerMap = {};
|
|
172
|
+
headersArr.forEach(function (line) {
|
|
173
|
+
const parts = line.split(': ');
|
|
174
|
+
const header = parts.shift();
|
|
175
|
+
if (!isHIgnored(header)) {
|
|
176
|
+
headerMap[header] = parts.join(': ');
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
// const resHs = hString
|
|
180
|
+
// ? hString
|
|
181
|
+
// .split('\r\n')
|
|
182
|
+
// .map((h) => h.split(':'))
|
|
183
|
+
// .filter((entry) => !isHIgnored(entry[0]))
|
|
184
|
+
// .reduce(
|
|
185
|
+
// (hds, [name, value]) => ({ ...hds, [name]: value }),
|
|
186
|
+
// {} as Record<string, string>,
|
|
187
|
+
// )
|
|
188
|
+
// : {}
|
|
176
189
|
const method = strMethod(initMethod);
|
|
177
190
|
const reqResInfo = sanitize({
|
|
178
191
|
url: String(url),
|
|
@@ -183,13 +196,19 @@ export default function (app, opts = {}) {
|
|
|
183
196
|
body: reqBody,
|
|
184
197
|
},
|
|
185
198
|
response: {
|
|
186
|
-
headers:
|
|
199
|
+
headers: headerMap,
|
|
187
200
|
body: xhr.response,
|
|
188
201
|
},
|
|
189
202
|
});
|
|
190
203
|
if (!reqResInfo) {
|
|
191
204
|
return;
|
|
192
205
|
}
|
|
206
|
+
app.debug.log('Openreplay: XHR load', reqResInfo.url, {
|
|
207
|
+
instance: xhr,
|
|
208
|
+
headers: xhr.getAllResponseHeaders(),
|
|
209
|
+
requestData: getXHRRequestDataObject(xhr),
|
|
210
|
+
result: NetworkRequest('xhr', method, String(reqResInfo.url), stringify(reqResInfo.request), stringify(reqResInfo.response), xhr.status, startTime + getTimeOrigin(), duration),
|
|
211
|
+
}, headerMap);
|
|
193
212
|
app.send(NetworkRequest('xhr', method, String(reqResInfo.url), stringify(reqResInfo.request), stringify(reqResInfo.response), xhr.status, startTime + getTimeOrigin(), duration));
|
|
194
213
|
}));
|
|
195
214
|
//TODO: handle error (though it has no Error API nor any useful information)
|
|
@@ -200,12 +219,10 @@ export default function (app, opts = {}) {
|
|
|
200
219
|
XMLHttpRequest.prototype.send = function (body) {
|
|
201
220
|
const rdo = getXHRRequestDataObject(this);
|
|
202
221
|
rdo.body = body;
|
|
203
|
-
app.debug.log('Openreplay: ', 'XHR send', rdo, 'XHR Object', this);
|
|
204
222
|
return nativeSend.apply(this, arguments);
|
|
205
223
|
};
|
|
206
224
|
const nativeSetRequestHeader = XMLHttpRequest.prototype.setRequestHeader;
|
|
207
225
|
XMLHttpRequest.prototype.setRequestHeader = function (name, value) {
|
|
208
|
-
app.debug.log('Openreplay: ', name, value, isHIgnored(name), getXHRRequestDataObject(this));
|
|
209
226
|
if (!isHIgnored(name)) {
|
|
210
227
|
const rdo = getXHRRequestDataObject(this);
|
|
211
228
|
rdo.headers[name] = value;
|