@cloudcare/browser-core 2.0.11 → 2.0.13
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/browser/cookie.js +0 -1
- package/cjs/browser/fetchObservable.js +6 -1
- package/cjs/dataMap.js +3 -1
- package/cjs/helper/contextHistory.js +15 -3
- package/cjs/helper/serialisation/rowData.js +1 -1
- package/cjs/helper/tools.js +17 -3
- package/esm/browser/cookie.js +0 -1
- package/esm/browser/fetchObservable.js +6 -1
- package/esm/dataMap.js +3 -1
- package/esm/helper/contextHistory.js +16 -4
- package/esm/helper/serialisation/rowData.js +1 -1
- package/esm/helper/tools.js +17 -3
- package/package.json +2 -2
- package/src/browser/cookie.js +0 -2
- package/src/browser/fetchObservable.js +7 -2
- package/src/dataMap.js +3 -1
- package/src/helper/contextHistory.js +13 -4
- package/src/helper/serialisation/rowData.js +1 -8
- package/src/helper/tools.js +16 -3
package/cjs/browser/cookie.js
CHANGED
|
@@ -76,7 +76,12 @@ function afterSend(observable, responsePromise, startContext) {
|
|
|
76
76
|
context.error = response;
|
|
77
77
|
} else if ('status' in response) {
|
|
78
78
|
context.response = response;
|
|
79
|
-
|
|
79
|
+
|
|
80
|
+
try {
|
|
81
|
+
context.responseType = response.constructor === Response && response.type || ''; // issue The Response type getter can only be used on instances of Response
|
|
82
|
+
} catch (err) {
|
|
83
|
+
context.responseType = '';
|
|
84
|
+
}
|
|
80
85
|
|
|
81
86
|
context.status = response.status;
|
|
82
87
|
context.isAborted = false;
|
package/cjs/dataMap.js
CHANGED
|
@@ -159,7 +159,9 @@ var dataMap = {
|
|
|
159
159
|
action_error_count: 'action.error.count',
|
|
160
160
|
action_resource_count: 'action.resource.count',
|
|
161
161
|
action_frustration_types: 'action.frustration.type',
|
|
162
|
-
action_long_task_count: 'action.long_task.count'
|
|
162
|
+
action_long_task_count: 'action.long_task.count',
|
|
163
|
+
action_target: '_dd.action.target',
|
|
164
|
+
action_position: '_dd.action.position'
|
|
163
165
|
}
|
|
164
166
|
},
|
|
165
167
|
browser_log: {
|
|
@@ -14,9 +14,10 @@ var END_OF_TIMES = Infinity;
|
|
|
14
14
|
var CLEAR_OLD_CONTEXTS_INTERVAL = _tools.ONE_MINUTE;
|
|
15
15
|
exports.CLEAR_OLD_CONTEXTS_INTERVAL = CLEAR_OLD_CONTEXTS_INTERVAL;
|
|
16
16
|
|
|
17
|
-
function ContextHistory(expireDelay) {
|
|
17
|
+
function ContextHistory(expireDelay, maxEntries) {
|
|
18
18
|
this.expireDelay = expireDelay;
|
|
19
19
|
this.entries = [];
|
|
20
|
+
this.maxEntries = maxEntries;
|
|
20
21
|
|
|
21
22
|
var _this = this;
|
|
22
23
|
|
|
@@ -43,6 +44,11 @@ ContextHistory.prototype.add = function (context, startTime) {
|
|
|
43
44
|
entry.endTime = endTime;
|
|
44
45
|
}
|
|
45
46
|
};
|
|
47
|
+
|
|
48
|
+
if (this.maxEntries && this.entries.length >= this.maxEntries) {
|
|
49
|
+
this.entries.pop();
|
|
50
|
+
}
|
|
51
|
+
|
|
46
52
|
this.entries.unshift(entry);
|
|
47
53
|
return entry;
|
|
48
54
|
};
|
|
@@ -83,13 +89,19 @@ ContextHistory.prototype.closeActive = function (endTime) {
|
|
|
83
89
|
*/
|
|
84
90
|
|
|
85
91
|
|
|
86
|
-
ContextHistory.prototype.findAll = function (startTime) {
|
|
92
|
+
ContextHistory.prototype.findAll = function (startTime, duration) {
|
|
93
|
+
if (typeof duration === 'undefined') {
|
|
94
|
+
duration = 0;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
var endTime = (0, _tools.addDuration)(startTime, duration);
|
|
98
|
+
|
|
87
99
|
if (typeof startTime === 'undefined') {
|
|
88
100
|
startTime = END_OF_TIMES;
|
|
89
101
|
}
|
|
90
102
|
|
|
91
103
|
var result = (0, _tools.filter)(this.entries, function (entry) {
|
|
92
|
-
return entry.startTime <=
|
|
104
|
+
return entry.startTime <= endTime && startTime <= entry.endTime;
|
|
93
105
|
});
|
|
94
106
|
return (0, _tools.map)(result, function (entry) {
|
|
95
107
|
return entry.context;
|
|
@@ -36,7 +36,7 @@ function escapeJsonValue(value) {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
function escapeFieldValueStr(str) {
|
|
39
|
-
return '"' + str.replace(/\\/g, '\\\\').replace(/
|
|
39
|
+
return '"' + str.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"';
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
function escapeRowField(value) {
|
package/cjs/helper/tools.js
CHANGED
|
@@ -86,7 +86,7 @@ exports.values = exports.utf8Encode = exports.urlParse = exports.unique = export
|
|
|
86
86
|
exports.withSnakeCaseKeys = withSnakeCaseKeys;
|
|
87
87
|
exports.xhr = void 0;
|
|
88
88
|
|
|
89
|
-
var
|
|
89
|
+
var _display = require("./display");
|
|
90
90
|
|
|
91
91
|
var _timer = require("./timer");
|
|
92
92
|
|
|
@@ -385,9 +385,23 @@ var every = function every(arr, fn, self) {
|
|
|
385
385
|
|
|
386
386
|
exports.every = every;
|
|
387
387
|
|
|
388
|
-
var matchList = function matchList(list, value) {
|
|
388
|
+
var matchList = function matchList(list, value, useStartsWith) {
|
|
389
|
+
if (useStartsWith === undefined) {
|
|
390
|
+
useStartsWith = false;
|
|
391
|
+
}
|
|
392
|
+
|
|
389
393
|
return some(list, function (item) {
|
|
390
|
-
|
|
394
|
+
try {
|
|
395
|
+
if (typeof item === 'function') {
|
|
396
|
+
return item(value);
|
|
397
|
+
} else if (item instanceof RegExp) {
|
|
398
|
+
return item.test(value);
|
|
399
|
+
} else if (typeof item === 'string') {
|
|
400
|
+
return useStartsWith ? startsWith(value, item) : item === value;
|
|
401
|
+
}
|
|
402
|
+
} catch (e) {
|
|
403
|
+
_display.display.error(e);
|
|
404
|
+
}
|
|
391
405
|
});
|
|
392
406
|
}; // https://github.com/jquery/jquery/blob/a684e6ba836f7c553968d7d026ed7941e1a612d8/src/selector/escapeSelector.js
|
|
393
407
|
|
package/esm/browser/cookie.js
CHANGED
|
@@ -64,7 +64,12 @@ function afterSend(observable, responsePromise, startContext) {
|
|
|
64
64
|
context.error = response;
|
|
65
65
|
} else if ('status' in response) {
|
|
66
66
|
context.response = response;
|
|
67
|
-
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
context.responseType = response.constructor === Response && response.type || ''; // issue The Response type getter can only be used on instances of Response
|
|
70
|
+
} catch (err) {
|
|
71
|
+
context.responseType = '';
|
|
72
|
+
}
|
|
68
73
|
|
|
69
74
|
context.status = response.status;
|
|
70
75
|
context.isAborted = false;
|
package/esm/dataMap.js
CHANGED
|
@@ -149,7 +149,9 @@ export var dataMap = {
|
|
|
149
149
|
action_error_count: 'action.error.count',
|
|
150
150
|
action_resource_count: 'action.resource.count',
|
|
151
151
|
action_frustration_types: 'action.frustration.type',
|
|
152
|
-
action_long_task_count: 'action.long_task.count'
|
|
152
|
+
action_long_task_count: 'action.long_task.count',
|
|
153
|
+
action_target: '_dd.action.target',
|
|
154
|
+
action_position: '_dd.action.position'
|
|
153
155
|
}
|
|
154
156
|
},
|
|
155
157
|
browser_log: {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { relativeNow, ONE_MINUTE, filter, map } from './tools';
|
|
1
|
+
import { relativeNow, ONE_MINUTE, filter, map, addDuration } from './tools';
|
|
2
2
|
import { setInterval, clearInterval } from './timer';
|
|
3
3
|
var END_OF_TIMES = Infinity;
|
|
4
4
|
export var CLEAR_OLD_CONTEXTS_INTERVAL = ONE_MINUTE;
|
|
5
|
-
export function ContextHistory(expireDelay) {
|
|
5
|
+
export function ContextHistory(expireDelay, maxEntries) {
|
|
6
6
|
this.expireDelay = expireDelay;
|
|
7
7
|
this.entries = [];
|
|
8
|
+
this.maxEntries = maxEntries;
|
|
8
9
|
|
|
9
10
|
var _this = this;
|
|
10
11
|
|
|
@@ -31,6 +32,11 @@ ContextHistory.prototype.add = function (context, startTime) {
|
|
|
31
32
|
entry.endTime = endTime;
|
|
32
33
|
}
|
|
33
34
|
};
|
|
35
|
+
|
|
36
|
+
if (this.maxEntries && this.entries.length >= this.maxEntries) {
|
|
37
|
+
this.entries.pop();
|
|
38
|
+
}
|
|
39
|
+
|
|
34
40
|
this.entries.unshift(entry);
|
|
35
41
|
return entry;
|
|
36
42
|
};
|
|
@@ -71,13 +77,19 @@ ContextHistory.prototype.closeActive = function (endTime) {
|
|
|
71
77
|
*/
|
|
72
78
|
|
|
73
79
|
|
|
74
|
-
ContextHistory.prototype.findAll = function (startTime) {
|
|
80
|
+
ContextHistory.prototype.findAll = function (startTime, duration) {
|
|
81
|
+
if (typeof duration === 'undefined') {
|
|
82
|
+
duration = 0;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
var endTime = addDuration(startTime, duration);
|
|
86
|
+
|
|
75
87
|
if (typeof startTime === 'undefined') {
|
|
76
88
|
startTime = END_OF_TIMES;
|
|
77
89
|
}
|
|
78
90
|
|
|
79
91
|
var result = filter(this.entries, function (entry) {
|
|
80
|
-
return entry.startTime <=
|
|
92
|
+
return entry.startTime <= endTime && startTime <= entry.endTime;
|
|
81
93
|
});
|
|
82
94
|
return map(result, function (entry) {
|
|
83
95
|
return entry.context;
|
|
@@ -20,7 +20,7 @@ export function escapeJsonValue(value) {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
export function escapeFieldValueStr(str) {
|
|
23
|
-
return '"' + str.replace(/\\/g, '\\\\').replace(/
|
|
23
|
+
return '"' + str.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"';
|
|
24
24
|
}
|
|
25
25
|
export function escapeRowField(value) {
|
|
26
26
|
if (typeof value === 'object' && value) {
|
package/esm/helper/tools.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { display } from './display';
|
|
2
2
|
import { setTimeout, clearTimeout } from './timer';
|
|
3
3
|
var ArrayProto = Array.prototype;
|
|
4
4
|
var FuncProto = Function.prototype;
|
|
@@ -242,9 +242,23 @@ export var every = function every(arr, fn, self) {
|
|
|
242
242
|
|
|
243
243
|
return flag;
|
|
244
244
|
};
|
|
245
|
-
export var matchList = function matchList(list, value) {
|
|
245
|
+
export var matchList = function matchList(list, value, useStartsWith) {
|
|
246
|
+
if (useStartsWith === undefined) {
|
|
247
|
+
useStartsWith = false;
|
|
248
|
+
}
|
|
249
|
+
|
|
246
250
|
return some(list, function (item) {
|
|
247
|
-
|
|
251
|
+
try {
|
|
252
|
+
if (typeof item === 'function') {
|
|
253
|
+
return item(value);
|
|
254
|
+
} else if (item instanceof RegExp) {
|
|
255
|
+
return item.test(value);
|
|
256
|
+
} else if (typeof item === 'string') {
|
|
257
|
+
return useStartsWith ? startsWith(value, item) : item === value;
|
|
258
|
+
}
|
|
259
|
+
} catch (e) {
|
|
260
|
+
display.error(e);
|
|
261
|
+
}
|
|
248
262
|
});
|
|
249
263
|
}; // https://github.com/jquery/jquery/blob/a684e6ba836f7c553968d7d026ed7941e1a612d8/src/selector/escapeSelector.js
|
|
250
264
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcare/browser-core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.13",
|
|
4
4
|
"main": "cjs/index.js",
|
|
5
5
|
"module": "esm/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -20,5 +20,5 @@
|
|
|
20
20
|
"author": "dataflux",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"description": "DataFlux RUM Web 端数据指标监控",
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "770d3987076f77be6dee3ba6b2c11207ba593312"
|
|
24
24
|
}
|
package/src/browser/cookie.js
CHANGED
|
@@ -28,7 +28,6 @@ export function deleteCookie(name, options) {
|
|
|
28
28
|
setCookie(name, '', 0, options)
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
|
|
32
31
|
export function areCookiesAuthorized(options) {
|
|
33
32
|
if (document.cookie === undefined || document.cookie === null) {
|
|
34
33
|
return false
|
|
@@ -41,7 +40,6 @@ export function areCookiesAuthorized(options) {
|
|
|
41
40
|
setCookie(testCookieName, testCookieValue, ONE_SECOND, options)
|
|
42
41
|
return getCookie(testCookieName) === testCookieValue
|
|
43
42
|
} catch (error) {
|
|
44
|
-
console.error(error)
|
|
45
43
|
return false
|
|
46
44
|
}
|
|
47
45
|
}
|
|
@@ -79,8 +79,13 @@ function afterSend(observable, responsePromise, startContext) {
|
|
|
79
79
|
context.error = response
|
|
80
80
|
} else if ('status' in response) {
|
|
81
81
|
context.response = response
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
try {
|
|
83
|
+
context.responseType =
|
|
84
|
+
(response.constructor === Response && response.type) || '' // issue The Response type getter can only be used on instances of Response
|
|
85
|
+
} catch (err) {
|
|
86
|
+
context.responseType = ''
|
|
87
|
+
}
|
|
88
|
+
|
|
84
89
|
context.status = response.status
|
|
85
90
|
context.isAborted = false
|
|
86
91
|
}
|
package/src/dataMap.js
CHANGED
|
@@ -148,7 +148,9 @@ export var dataMap = {
|
|
|
148
148
|
action_error_count: 'action.error.count',
|
|
149
149
|
action_resource_count: 'action.resource.count',
|
|
150
150
|
action_frustration_types: 'action.frustration.type',
|
|
151
|
-
action_long_task_count: 'action.long_task.count'
|
|
151
|
+
action_long_task_count: 'action.long_task.count',
|
|
152
|
+
action_target: '_dd.action.target',
|
|
153
|
+
action_position: '_dd.action.position'
|
|
152
154
|
}
|
|
153
155
|
},
|
|
154
156
|
browser_log: {
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { relativeNow, ONE_MINUTE, filter, map } from './tools'
|
|
1
|
+
import { relativeNow, ONE_MINUTE, filter, map, addDuration } from './tools'
|
|
2
2
|
import { setInterval, clearInterval } from './timer'
|
|
3
3
|
var END_OF_TIMES = Infinity
|
|
4
4
|
|
|
5
5
|
export var CLEAR_OLD_CONTEXTS_INTERVAL = ONE_MINUTE
|
|
6
|
-
export function ContextHistory(expireDelay) {
|
|
6
|
+
export function ContextHistory(expireDelay, maxEntries) {
|
|
7
7
|
this.expireDelay = expireDelay
|
|
8
8
|
this.entries = []
|
|
9
|
+
this.maxEntries = maxEntries
|
|
9
10
|
var _this = this
|
|
10
11
|
this.clearOldContextsInterval = setInterval(function () {
|
|
11
12
|
_this.clearOldContexts()
|
|
12
13
|
}, CLEAR_OLD_CONTEXTS_INTERVAL)
|
|
13
14
|
}
|
|
15
|
+
|
|
14
16
|
ContextHistory.prototype.add = function (context, startTime) {
|
|
15
17
|
var _this = this
|
|
16
18
|
var entry = {
|
|
@@ -27,6 +29,9 @@ ContextHistory.prototype.add = function (context, startTime) {
|
|
|
27
29
|
entry.endTime = endTime
|
|
28
30
|
}
|
|
29
31
|
}
|
|
32
|
+
if (this.maxEntries && this.entries.length >= this.maxEntries) {
|
|
33
|
+
this.entries.pop()
|
|
34
|
+
}
|
|
30
35
|
this.entries.unshift(entry)
|
|
31
36
|
return entry
|
|
32
37
|
}
|
|
@@ -58,12 +63,16 @@ ContextHistory.prototype.closeActive = function (endTime) {
|
|
|
58
63
|
* Return all contexts that were active during `startTime`, or all currently active contexts if no
|
|
59
64
|
* `startTime` is provided.
|
|
60
65
|
*/
|
|
61
|
-
ContextHistory.prototype.findAll = function (startTime) {
|
|
66
|
+
ContextHistory.prototype.findAll = function (startTime, duration) {
|
|
67
|
+
if (typeof duration === 'undefined') {
|
|
68
|
+
duration = 0
|
|
69
|
+
}
|
|
70
|
+
var endTime = addDuration(startTime, duration)
|
|
62
71
|
if (typeof startTime === 'undefined') {
|
|
63
72
|
startTime = END_OF_TIMES
|
|
64
73
|
}
|
|
65
74
|
var result = filter(this.entries, function (entry) {
|
|
66
|
-
return entry.startTime <=
|
|
75
|
+
return entry.startTime <= endTime && startTime <= entry.endTime
|
|
67
76
|
})
|
|
68
77
|
return map(result, function (entry) {
|
|
69
78
|
return entry.context
|
|
@@ -21,14 +21,7 @@ export function escapeJsonValue(value) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export function escapeFieldValueStr(str) {
|
|
24
|
-
return (
|
|
25
|
-
'"' +
|
|
26
|
-
str
|
|
27
|
-
.replace(/\\/g, '\\\\')
|
|
28
|
-
.replace(/[\\]*"/g, '"')
|
|
29
|
-
.replace(/"/g, '\\"') +
|
|
30
|
-
'"'
|
|
31
|
-
)
|
|
24
|
+
return '"' + str.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"'
|
|
32
25
|
}
|
|
33
26
|
export function escapeRowField(value) {
|
|
34
27
|
if (typeof value === 'object' && value) {
|
package/src/helper/tools.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { display } from './display'
|
|
2
2
|
import { setTimeout, clearTimeout } from './timer'
|
|
3
3
|
var ArrayProto = Array.prototype
|
|
4
4
|
var FuncProto = Function.prototype
|
|
@@ -214,9 +214,22 @@ export var every = function (arr, fn, self) {
|
|
|
214
214
|
}
|
|
215
215
|
return flag
|
|
216
216
|
}
|
|
217
|
-
export var matchList = function (list, value) {
|
|
217
|
+
export var matchList = function (list, value, useStartsWith) {
|
|
218
|
+
if (useStartsWith === undefined) {
|
|
219
|
+
useStartsWith = false
|
|
220
|
+
}
|
|
218
221
|
return some(list, function (item) {
|
|
219
|
-
|
|
222
|
+
try {
|
|
223
|
+
if (typeof item === 'function') {
|
|
224
|
+
return item(value)
|
|
225
|
+
} else if (item instanceof RegExp) {
|
|
226
|
+
return item.test(value)
|
|
227
|
+
} else if (typeof item === 'string') {
|
|
228
|
+
return useStartsWith ? startsWith(value, item) : item === value
|
|
229
|
+
}
|
|
230
|
+
} catch (e) {
|
|
231
|
+
display.error(e)
|
|
232
|
+
}
|
|
220
233
|
})
|
|
221
234
|
}
|
|
222
235
|
// https://github.com/jquery/jquery/blob/a684e6ba836f7c553968d7d026ed7941e1a612d8/src/selector/escapeSelector.js
|