@cloudcare/browser-core 2.0.9 → 2.0.10
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.
|
@@ -9,27 +9,30 @@ exports.isIntakeRequest = isIntakeRequest;
|
|
|
9
9
|
var _tools = require("../helper/tools");
|
|
10
10
|
|
|
11
11
|
var TRIM_REGIX = /^\s+|\s+$/g;
|
|
12
|
+
var typeMap = {
|
|
13
|
+
rum: '/rum',
|
|
14
|
+
log: '/logging',
|
|
15
|
+
sessionReplay: '/rum/replay'
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
function getEndPointUrl(url, type) {
|
|
19
|
+
// type: rum, log,replay
|
|
20
|
+
var subUrl = typeMap[type];
|
|
21
|
+
if (!subUrl) return '';
|
|
22
|
+
|
|
23
|
+
if (url.indexOf('/') === 0) {
|
|
24
|
+
// 绝对路径这种 /xxx
|
|
25
|
+
url = location.origin + trim(url);
|
|
26
|
+
}
|
|
12
27
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return trim(url) + '/v1/write/rum';
|
|
28
|
+
if (url.lastIndexOf('/') === url.length - 1) return trim(url) + 'v1/write' + subUrl;
|
|
29
|
+
return trim(url) + '/v1/write' + subUrl;
|
|
16
30
|
}
|
|
17
31
|
|
|
18
32
|
function trim(str) {
|
|
19
33
|
return str.replace(TRIM_REGIX, '');
|
|
20
34
|
}
|
|
21
35
|
|
|
22
|
-
function getLogsEndPoint(url) {
|
|
23
|
-
if (url.lastIndexOf('/') === url.length - 1) return trim(url) + 'v1/write/logging';
|
|
24
|
-
return trim(url) + '/v1/write/logging';
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function getSessionReplayEndPoint(url) {
|
|
28
|
-
// return 'http://localhost:3002/write_data'
|
|
29
|
-
if (url.lastIndexOf('/') === url.length - 1) return trim(url) + 'v1/write/rum/replay';
|
|
30
|
-
return trim(url) + '/v1/write/rum/replay';
|
|
31
|
-
}
|
|
32
|
-
|
|
33
36
|
function computeTransportConfiguration(initConfiguration) {
|
|
34
37
|
var isIntakeUrl = function isIntakeUrl(url) {
|
|
35
38
|
return false;
|
|
@@ -48,9 +51,9 @@ function computeTransportConfiguration(initConfiguration) {
|
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
return {
|
|
51
|
-
datakitUrl:
|
|
52
|
-
logsEndpoint:
|
|
53
|
-
sessionReplayEndPoint:
|
|
54
|
+
datakitUrl: getEndPointUrl(initConfiguration.datakitUrl || initConfiguration.datakitOrigin, 'rum'),
|
|
55
|
+
logsEndpoint: getEndPointUrl(initConfiguration.datakitOrigin, 'log'),
|
|
56
|
+
sessionReplayEndPoint: getEndPointUrl(initConfiguration.datakitOrigin, 'sessionReplay'),
|
|
54
57
|
isIntakeUrl: isIntakeUrl,
|
|
55
58
|
isServerError: isServerError
|
|
56
59
|
};
|
|
@@ -62,6 +65,10 @@ function isIntakeRequest(url, configuration) {
|
|
|
62
65
|
|
|
63
66
|
if (configuration.logsEndpoint) {
|
|
64
67
|
notTakeRequest.push(configuration.logsEndpoint);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (configuration.sessionReplayEndPoint) {
|
|
71
|
+
notTakeRequest.push(configuration.sessionReplayEndPoint);
|
|
65
72
|
} // datakit 地址,log 地址,以及客户自定义过滤方法定义url
|
|
66
73
|
|
|
67
74
|
|
package/cjs/dataMap.js
CHANGED
|
@@ -73,7 +73,6 @@ var dataMap = {
|
|
|
73
73
|
dom_complete: 'view.dom_complete',
|
|
74
74
|
load_event: 'view.load_event',
|
|
75
75
|
first_input_time: 'view.first_input_time',
|
|
76
|
-
first_meaningful_paint: 'view.largest_contentful_paint',
|
|
77
76
|
first_paint_time: 'view.fpt',
|
|
78
77
|
resource_load_time: 'view.resource_load_time',
|
|
79
78
|
time_to_interactive: 'view.tti',
|
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
import { isFunction, isBoolean, some } from '../helper/tools';
|
|
2
2
|
var TRIM_REGIX = /^\s+|\s+$/g;
|
|
3
|
+
var typeMap = {
|
|
4
|
+
rum: '/rum',
|
|
5
|
+
log: '/logging',
|
|
6
|
+
sessionReplay: '/rum/replay'
|
|
7
|
+
};
|
|
3
8
|
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
function getEndPointUrl(url, type) {
|
|
10
|
+
// type: rum, log,replay
|
|
11
|
+
var subUrl = typeMap[type];
|
|
12
|
+
if (!subUrl) return '';
|
|
8
13
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
if (url.indexOf('/') === 0) {
|
|
15
|
+
// 绝对路径这种 /xxx
|
|
16
|
+
url = location.origin + trim(url);
|
|
17
|
+
}
|
|
12
18
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return trim(url) + '/v1/write/logging';
|
|
19
|
+
if (url.lastIndexOf('/') === url.length - 1) return trim(url) + 'v1/write' + subUrl;
|
|
20
|
+
return trim(url) + '/v1/write' + subUrl;
|
|
16
21
|
}
|
|
17
22
|
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
if (url.lastIndexOf('/') === url.length - 1) return trim(url) + 'v1/write/rum/replay';
|
|
21
|
-
return trim(url) + '/v1/write/rum/replay';
|
|
23
|
+
function trim(str) {
|
|
24
|
+
return str.replace(TRIM_REGIX, '');
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
export function computeTransportConfiguration(initConfiguration) {
|
|
@@ -39,9 +42,9 @@ export function computeTransportConfiguration(initConfiguration) {
|
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
return {
|
|
42
|
-
datakitUrl:
|
|
43
|
-
logsEndpoint:
|
|
44
|
-
sessionReplayEndPoint:
|
|
45
|
+
datakitUrl: getEndPointUrl(initConfiguration.datakitUrl || initConfiguration.datakitOrigin, 'rum'),
|
|
46
|
+
logsEndpoint: getEndPointUrl(initConfiguration.datakitOrigin, 'log'),
|
|
47
|
+
sessionReplayEndPoint: getEndPointUrl(initConfiguration.datakitOrigin, 'sessionReplay'),
|
|
45
48
|
isIntakeUrl: isIntakeUrl,
|
|
46
49
|
isServerError: isServerError
|
|
47
50
|
};
|
|
@@ -52,6 +55,10 @@ export function isIntakeRequest(url, configuration) {
|
|
|
52
55
|
|
|
53
56
|
if (configuration.logsEndpoint) {
|
|
54
57
|
notTakeRequest.push(configuration.logsEndpoint);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (configuration.sessionReplayEndPoint) {
|
|
61
|
+
notTakeRequest.push(configuration.sessionReplayEndPoint);
|
|
55
62
|
} // datakit 地址,log 地址,以及客户自定义过滤方法定义url
|
|
56
63
|
|
|
57
64
|
|
package/esm/dataMap.js
CHANGED
|
@@ -63,7 +63,6 @@ export var dataMap = {
|
|
|
63
63
|
dom_complete: 'view.dom_complete',
|
|
64
64
|
load_event: 'view.load_event',
|
|
65
65
|
first_input_time: 'view.first_input_time',
|
|
66
|
-
first_meaningful_paint: 'view.largest_contentful_paint',
|
|
67
66
|
first_paint_time: 'view.fpt',
|
|
68
67
|
resource_load_time: 'view.resource_load_time',
|
|
69
68
|
time_to_interactive: 'view.tti',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcare/browser-core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.10",
|
|
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": "197457783c66faf642df01e4a6149fd4fc559d37"
|
|
24
24
|
}
|
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
import { isFunction, isBoolean, some } from '../helper/tools'
|
|
2
2
|
var TRIM_REGIX = /^\s+|\s+$/g
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
var typeMap = {
|
|
4
|
+
rum: '/rum',
|
|
5
|
+
log: '/logging',
|
|
6
|
+
sessionReplay: '/rum/replay'
|
|
6
7
|
}
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
function getEndPointUrl(url, type) {
|
|
9
|
+
// type: rum, log,replay
|
|
10
|
+
var subUrl = typeMap[type]
|
|
11
|
+
if (!subUrl) return ''
|
|
12
|
+
if (url.indexOf('/') === 0) {
|
|
13
|
+
// 绝对路径这种 /xxx
|
|
14
|
+
url = location.origin + trim(url)
|
|
15
|
+
}
|
|
11
16
|
if (url.lastIndexOf('/') === url.length - 1)
|
|
12
|
-
return trim(url) + 'v1/write
|
|
13
|
-
return trim(url) + '/v1/write
|
|
17
|
+
return trim(url) + 'v1/write' + subUrl
|
|
18
|
+
return trim(url) + '/v1/write' + subUrl
|
|
14
19
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return trim(url) + 'v1/write/rum/replay'
|
|
19
|
-
return trim(url) + '/v1/write/rum/replay'
|
|
20
|
+
|
|
21
|
+
function trim(str) {
|
|
22
|
+
return str.replace(TRIM_REGIX, '')
|
|
20
23
|
}
|
|
24
|
+
|
|
21
25
|
export function computeTransportConfiguration(initConfiguration) {
|
|
22
26
|
var isIntakeUrl = function (url) {
|
|
23
27
|
return false
|
|
@@ -40,12 +44,14 @@ export function computeTransportConfiguration(initConfiguration) {
|
|
|
40
44
|
isServerError = initConfiguration.isServerError
|
|
41
45
|
}
|
|
42
46
|
return {
|
|
43
|
-
datakitUrl:
|
|
44
|
-
initConfiguration.datakitUrl || initConfiguration.datakitOrigin
|
|
47
|
+
datakitUrl: getEndPointUrl(
|
|
48
|
+
initConfiguration.datakitUrl || initConfiguration.datakitOrigin,
|
|
49
|
+
'rum'
|
|
45
50
|
),
|
|
46
|
-
logsEndpoint:
|
|
47
|
-
sessionReplayEndPoint:
|
|
48
|
-
initConfiguration.datakitOrigin
|
|
51
|
+
logsEndpoint: getEndPointUrl(initConfiguration.datakitOrigin, 'log'),
|
|
52
|
+
sessionReplayEndPoint: getEndPointUrl(
|
|
53
|
+
initConfiguration.datakitOrigin,
|
|
54
|
+
'sessionReplay'
|
|
49
55
|
),
|
|
50
56
|
isIntakeUrl: isIntakeUrl,
|
|
51
57
|
isServerError: isServerError
|
|
@@ -57,6 +63,9 @@ export function isIntakeRequest(url, configuration) {
|
|
|
57
63
|
if (configuration.logsEndpoint) {
|
|
58
64
|
notTakeRequest.push(configuration.logsEndpoint)
|
|
59
65
|
}
|
|
66
|
+
if (configuration.sessionReplayEndPoint) {
|
|
67
|
+
notTakeRequest.push(configuration.sessionReplayEndPoint)
|
|
68
|
+
}
|
|
60
69
|
// datakit 地址,log 地址,以及客户自定义过滤方法定义url
|
|
61
70
|
return (
|
|
62
71
|
some(notTakeRequest, function (takeUrl) {
|
package/src/dataMap.js
CHANGED
|
@@ -62,7 +62,6 @@ export var dataMap = {
|
|
|
62
62
|
dom_complete: 'view.dom_complete',
|
|
63
63
|
load_event: 'view.load_event',
|
|
64
64
|
first_input_time: 'view.first_input_time',
|
|
65
|
-
first_meaningful_paint: 'view.largest_contentful_paint',
|
|
66
65
|
first_paint_time: 'view.fpt',
|
|
67
66
|
resource_load_time: 'view.resource_load_time',
|
|
68
67
|
time_to_interactive: 'view.tti',
|