@cloudcare/browser-core 1.0.11 → 1.0.15
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/configuration.js +10 -2
- package/cjs/errorCollection.js +1 -1
- package/cjs/xhrProxy.js +2 -0
- package/esm/configuration.js +11 -3
- package/esm/errorCollection.js +1 -1
- package/esm/xhrProxy.js +2 -0
- package/package.json +2 -2
- package/src/configuration.js +9 -3
- package/src/errorCollection.js +2 -3
- package/src/xhrProxy.js +1 -1
package/cjs/configuration.js
CHANGED
|
@@ -43,7 +43,11 @@ var DEFAULT_CONFIGURATION = {
|
|
|
43
43
|
//是否开启交互action收集
|
|
44
44
|
allowedDDTracingOrigins: [],
|
|
45
45
|
//
|
|
46
|
-
beforeSend: function beforeSend(event) {}
|
|
46
|
+
beforeSend: function beforeSend(event) {},
|
|
47
|
+
isServerError: function isServerError(request) {
|
|
48
|
+
return false;
|
|
49
|
+
} // 判断请求是否为error 请求
|
|
50
|
+
|
|
47
51
|
};
|
|
48
52
|
exports.DEFAULT_CONFIGURATION = DEFAULT_CONFIGURATION;
|
|
49
53
|
|
|
@@ -105,7 +109,11 @@ function commonInit(userConfiguration, buildEnv) {
|
|
|
105
109
|
transportConfiguration.trackInteractions = !!userConfiguration.trackInteractions;
|
|
106
110
|
}
|
|
107
111
|
|
|
108
|
-
|
|
112
|
+
if ('isServerError' in userConfiguration && (0, _tools.isFunction)(userConfiguration.isServerError) && (0, _tools.isBoolean)(userConfiguration.isServerError())) {
|
|
113
|
+
transportConfiguration.isServerError = userConfiguration.isServerError;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return (0, _tools.extend2Lev)({}, DEFAULT_CONFIGURATION, transportConfiguration);
|
|
109
117
|
}
|
|
110
118
|
|
|
111
119
|
function mustUseSecureCookie(userConfiguration) {
|
package/cjs/errorCollection.js
CHANGED
|
@@ -113,7 +113,7 @@ function trackNetworkError(configuration, errorObservable) {
|
|
|
113
113
|
});
|
|
114
114
|
|
|
115
115
|
function handleCompleteRequest(type, request) {
|
|
116
|
-
if (!(0, _configuration.isIntakeRequest)(request.url, configuration) &&
|
|
116
|
+
if (!(0, _configuration.isIntakeRequest)(request.url, configuration) && !request.isAborted && (isRejected(request) || isServerError(request) || configuration.isServerError(request))) {
|
|
117
117
|
errorObservable.notify({
|
|
118
118
|
message: format(type) + ' error ' + request.method + ' ' + request.url,
|
|
119
119
|
resource: {
|
package/cjs/xhrProxy.js
CHANGED
package/esm/configuration.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ONE_KILO_BYTE, ONE_SECOND, extend2Lev, isArray, includes } from './helper/tools';
|
|
1
|
+
import { ONE_KILO_BYTE, ONE_SECOND, extend2Lev, isArray, includes, isFunction, isBoolean } from './helper/tools';
|
|
2
2
|
import { getCurrentSite } from './cookie';
|
|
3
3
|
import { haveSameOrigin } from './helper/urlPolyfill';
|
|
4
4
|
var TRIM_REGIX = /^\s+|\s+$/g;
|
|
@@ -30,7 +30,11 @@ export var DEFAULT_CONFIGURATION = {
|
|
|
30
30
|
//是否开启交互action收集
|
|
31
31
|
allowedDDTracingOrigins: [],
|
|
32
32
|
//
|
|
33
|
-
beforeSend: function beforeSend(event) {}
|
|
33
|
+
beforeSend: function beforeSend(event) {},
|
|
34
|
+
isServerError: function isServerError(request) {
|
|
35
|
+
return false;
|
|
36
|
+
} // 判断请求是否为error 请求
|
|
37
|
+
|
|
34
38
|
};
|
|
35
39
|
|
|
36
40
|
function trim(str) {
|
|
@@ -91,7 +95,11 @@ export function commonInit(userConfiguration, buildEnv) {
|
|
|
91
95
|
transportConfiguration.trackInteractions = !!userConfiguration.trackInteractions;
|
|
92
96
|
}
|
|
93
97
|
|
|
94
|
-
|
|
98
|
+
if ('isServerError' in userConfiguration && isFunction(userConfiguration.isServerError) && isBoolean(userConfiguration.isServerError())) {
|
|
99
|
+
transportConfiguration.isServerError = userConfiguration.isServerError;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return extend2Lev({}, DEFAULT_CONFIGURATION, transportConfiguration);
|
|
95
103
|
}
|
|
96
104
|
|
|
97
105
|
function mustUseSecureCookie(userConfiguration) {
|
package/esm/errorCollection.js
CHANGED
|
@@ -87,7 +87,7 @@ export function trackNetworkError(configuration, errorObservable) {
|
|
|
87
87
|
});
|
|
88
88
|
|
|
89
89
|
function handleCompleteRequest(type, request) {
|
|
90
|
-
if (!isIntakeRequest(request.url, configuration) &&
|
|
90
|
+
if (!isIntakeRequest(request.url, configuration) && !request.isAborted && (isRejected(request) || isServerError(request) || configuration.isServerError(request))) {
|
|
91
91
|
errorObservable.notify({
|
|
92
92
|
message: format(type) + ' error ' + request.method + ' ' + request.url,
|
|
93
93
|
resource: {
|
package/esm/xhrProxy.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcare/browser-core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
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": "d8b3295bcb924ddd649b22ecffcf3ec6ccb4072d"
|
|
24
24
|
}
|
package/src/configuration.js
CHANGED
|
@@ -3,7 +3,9 @@ import {
|
|
|
3
3
|
ONE_SECOND,
|
|
4
4
|
extend2Lev,
|
|
5
5
|
isArray,
|
|
6
|
-
includes
|
|
6
|
+
includes,
|
|
7
|
+
isFunction,
|
|
8
|
+
isBoolean
|
|
7
9
|
} from './helper/tools'
|
|
8
10
|
import { getCurrentSite } from './cookie'
|
|
9
11
|
import { haveSameOrigin } from './helper/urlPolyfill'
|
|
@@ -32,7 +34,8 @@ export var DEFAULT_CONFIGURATION = {
|
|
|
32
34
|
logsEndpoint: '',
|
|
33
35
|
trackInteractions: false, //是否开启交互action收集
|
|
34
36
|
allowedDDTracingOrigins: [], //
|
|
35
|
-
beforeSend: function (event) {}
|
|
37
|
+
beforeSend: function (event) {},
|
|
38
|
+
isServerError: function(request) {return false} // 判断请求是否为error 请求
|
|
36
39
|
}
|
|
37
40
|
function trim(str) {
|
|
38
41
|
return str.replace(TRIM_REGIX, '')
|
|
@@ -94,7 +97,10 @@ export function commonInit(userConfiguration, buildEnv) {
|
|
|
94
97
|
if ('trackInteractions' in userConfiguration) {
|
|
95
98
|
transportConfiguration.trackInteractions = !!userConfiguration.trackInteractions
|
|
96
99
|
}
|
|
97
|
-
|
|
100
|
+
if ('isServerError' in userConfiguration && isFunction(userConfiguration.isServerError) && isBoolean(userConfiguration.isServerError())) {
|
|
101
|
+
transportConfiguration.isServerError = userConfiguration.isServerError
|
|
102
|
+
}
|
|
103
|
+
return extend2Lev({}, DEFAULT_CONFIGURATION, transportConfiguration)
|
|
98
104
|
}
|
|
99
105
|
function mustUseSecureCookie(userConfiguration) {
|
|
100
106
|
return (
|
package/src/errorCollection.js
CHANGED
|
@@ -108,9 +108,8 @@ export function trackNetworkError(configuration, errorObservable) {
|
|
|
108
108
|
function handleCompleteRequest(type, request) {
|
|
109
109
|
if (
|
|
110
110
|
!isIntakeRequest(request.url, configuration) &&
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
(isRejected(request) || isServerError(request))
|
|
111
|
+
!request.isAborted &&
|
|
112
|
+
(isRejected(request) || isServerError(request) || configuration.isServerError(request))
|
|
114
113
|
) {
|
|
115
114
|
errorObservable.notify({
|
|
116
115
|
message: format(type) + ' error ' + request.method + ' ' + request.url,
|
package/src/xhrProxy.js
CHANGED
|
@@ -71,6 +71,7 @@ function proxyXhr() {
|
|
|
71
71
|
|
|
72
72
|
var hasBeenReported = false
|
|
73
73
|
var reportXhr = function () {
|
|
74
|
+
_this.removeEventListener('loadend', reportXhr)
|
|
74
75
|
if (hasBeenReported) {
|
|
75
76
|
return
|
|
76
77
|
}
|
|
@@ -83,7 +84,6 @@ function proxyXhr() {
|
|
|
83
84
|
response: _this.response,
|
|
84
85
|
status: _this.status
|
|
85
86
|
})
|
|
86
|
-
|
|
87
87
|
each(onRequestCompleteCallbacks, function (callback) {
|
|
88
88
|
callback(xhrCompleteContext, _this)
|
|
89
89
|
})
|