@openreplay/tracker 5.0.4-beta.1 → 5.0.5-beta.2
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 +9 -1
- package/lib/app/index.js +1 -1
- package/lib/index.js +1 -1
- package/lib/modules/axiosSpy.js +9 -1
- 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.
|
|
36
|
+
this.version = '5.0.5-beta.2'; // 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.
|
|
143
|
+
trackerVersion: '5.0.5-beta.2',
|
|
144
144
|
projectKey: options.projectKey,
|
|
145
145
|
doNotTrack,
|
|
146
146
|
// TODO: add precise reason (an exact API missing)
|
package/cjs/modules/axiosSpy.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const messages_gen_js_1 = require("../app/messages.gen.js");
|
|
4
4
|
const utils_js_1 = require("../utils.js");
|
|
5
5
|
function default_1(app, instance, opts, sanitize, stringify) {
|
|
6
|
+
app.debug.log('Openreplay: attaching axios spy to instance', instance);
|
|
6
7
|
function captureResponseData(axiosResponseObj) {
|
|
7
8
|
const { headers: reqHs, data: reqData, method, url } = axiosResponseObj.config;
|
|
8
9
|
const { data: rData, headers: rHs, status: globStatus, response } = axiosResponseObj;
|
|
@@ -21,6 +22,7 @@ function default_1(app, instance, opts, sanitize, stringify) {
|
|
|
21
22
|
},
|
|
22
23
|
});
|
|
23
24
|
if (!reqResInfo) {
|
|
25
|
+
app.debug.log('Openreplay: empty request/response info, skipping');
|
|
24
26
|
return;
|
|
25
27
|
}
|
|
26
28
|
const requestStart = axiosResponseObj.config.__openreplay_timing;
|
|
@@ -28,6 +30,7 @@ function default_1(app, instance, opts, sanitize, stringify) {
|
|
|
28
30
|
app.send((0, messages_gen_js_1.NetworkRequest)('xhr', String(method), String(reqResInfo.url), stringify(reqResInfo.request), stringify(reqResInfo.response), reqResInfo.status, requestStart + (0, utils_js_1.getTimeOrigin)(), duration));
|
|
29
31
|
}
|
|
30
32
|
function getStartTime(config) {
|
|
33
|
+
app.debug.log('Openreplay: capturing API request', config);
|
|
31
34
|
config.__openreplay_timing = performance.now();
|
|
32
35
|
if (opts.sessionTokenHeader) {
|
|
33
36
|
const header = typeof opts.sessionTokenHeader === 'string'
|
|
@@ -50,7 +53,12 @@ function default_1(app, instance, opts, sanitize, stringify) {
|
|
|
50
53
|
captureResponseData(error);
|
|
51
54
|
return Promise.reject(error);
|
|
52
55
|
}
|
|
53
|
-
|
|
56
|
+
function logRequestError(ev) {
|
|
57
|
+
app.debug.log('Openreplay: failed API request, skipping', ev);
|
|
58
|
+
}
|
|
59
|
+
const reqInt = instance.interceptors.request.use(getStartTime, logRequestError, {
|
|
60
|
+
synchronous: true,
|
|
61
|
+
});
|
|
54
62
|
const resInt = instance.interceptors.response.use(captureNetworkRequest, captureNetworkError, {
|
|
55
63
|
synchronous: true,
|
|
56
64
|
});
|
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.
|
|
33
|
+
this.version = '5.0.5-beta.2'; // 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.
|
|
138
|
+
trackerVersion: '5.0.5-beta.2',
|
|
139
139
|
projectKey: options.projectKey,
|
|
140
140
|
doNotTrack,
|
|
141
141
|
// TODO: add precise reason (an exact API missing)
|
package/lib/modules/axiosSpy.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NetworkRequest } from '../app/messages.gen.js';
|
|
2
2
|
import { getTimeOrigin } from '../utils.js';
|
|
3
3
|
export default function (app, instance, opts, sanitize, stringify) {
|
|
4
|
+
app.debug.log('Openreplay: attaching axios spy to instance', instance);
|
|
4
5
|
function captureResponseData(axiosResponseObj) {
|
|
5
6
|
const { headers: reqHs, data: reqData, method, url } = axiosResponseObj.config;
|
|
6
7
|
const { data: rData, headers: rHs, status: globStatus, response } = axiosResponseObj;
|
|
@@ -19,6 +20,7 @@ export default function (app, instance, opts, sanitize, stringify) {
|
|
|
19
20
|
},
|
|
20
21
|
});
|
|
21
22
|
if (!reqResInfo) {
|
|
23
|
+
app.debug.log('Openreplay: empty request/response info, skipping');
|
|
22
24
|
return;
|
|
23
25
|
}
|
|
24
26
|
const requestStart = axiosResponseObj.config.__openreplay_timing;
|
|
@@ -26,6 +28,7 @@ export default function (app, instance, opts, sanitize, stringify) {
|
|
|
26
28
|
app.send(NetworkRequest('xhr', String(method), String(reqResInfo.url), stringify(reqResInfo.request), stringify(reqResInfo.response), reqResInfo.status, requestStart + getTimeOrigin(), duration));
|
|
27
29
|
}
|
|
28
30
|
function getStartTime(config) {
|
|
31
|
+
app.debug.log('Openreplay: capturing API request', config);
|
|
29
32
|
config.__openreplay_timing = performance.now();
|
|
30
33
|
if (opts.sessionTokenHeader) {
|
|
31
34
|
const header = typeof opts.sessionTokenHeader === 'string'
|
|
@@ -48,7 +51,12 @@ export default function (app, instance, opts, sanitize, stringify) {
|
|
|
48
51
|
captureResponseData(error);
|
|
49
52
|
return Promise.reject(error);
|
|
50
53
|
}
|
|
51
|
-
|
|
54
|
+
function logRequestError(ev) {
|
|
55
|
+
app.debug.log('Openreplay: failed API request, skipping', ev);
|
|
56
|
+
}
|
|
57
|
+
const reqInt = instance.interceptors.request.use(getStartTime, logRequestError, {
|
|
58
|
+
synchronous: true,
|
|
59
|
+
});
|
|
52
60
|
const resInt = instance.interceptors.response.use(captureNetworkRequest, captureNetworkError, {
|
|
53
61
|
synchronous: true,
|
|
54
62
|
});
|