@cloudcare/browser-core 1.0.14 → 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.
@@ -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,6 +109,10 @@ function commonInit(userConfiguration, buildEnv) {
105
109
  transportConfiguration.trackInteractions = !!userConfiguration.trackInteractions;
106
110
  }
107
111
 
112
+ if ('isServerError' in userConfiguration && (0, _tools.isFunction)(userConfiguration.isServerError) && (0, _tools.isBoolean)(userConfiguration.isServerError())) {
113
+ transportConfiguration.isServerError = userConfiguration.isServerError;
114
+ }
115
+
108
116
  return (0, _tools.extend2Lev)({}, DEFAULT_CONFIGURATION, transportConfiguration);
109
117
  }
110
118
 
@@ -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) && !request.isAborted && (isRejected(request) || isServerError(request))) {
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: {
@@ -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,6 +95,10 @@ export function commonInit(userConfiguration, buildEnv) {
91
95
  transportConfiguration.trackInteractions = !!userConfiguration.trackInteractions;
92
96
  }
93
97
 
98
+ if ('isServerError' in userConfiguration && isFunction(userConfiguration.isServerError) && isBoolean(userConfiguration.isServerError())) {
99
+ transportConfiguration.isServerError = userConfiguration.isServerError;
100
+ }
101
+
94
102
  return extend2Lev({}, DEFAULT_CONFIGURATION, transportConfiguration);
95
103
  }
96
104
 
@@ -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) && !request.isAborted && (isRejected(request) || isServerError(request))) {
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudcare/browser-core",
3
- "version": "1.0.14",
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": "e1e2638c408f226504ec32e60dc98c919f75e727"
23
+ "gitHead": "d8b3295bcb924ddd649b22ecffcf3ec6ccb4072d"
24
24
  }
@@ -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,6 +97,9 @@ export function commonInit(userConfiguration, buildEnv) {
94
97
  if ('trackInteractions' in userConfiguration) {
95
98
  transportConfiguration.trackInteractions = !!userConfiguration.trackInteractions
96
99
  }
100
+ if ('isServerError' in userConfiguration && isFunction(userConfiguration.isServerError) && isBoolean(userConfiguration.isServerError())) {
101
+ transportConfiguration.isServerError = userConfiguration.isServerError
102
+ }
97
103
  return extend2Lev({}, DEFAULT_CONFIGURATION, transportConfiguration)
98
104
  }
99
105
  function mustUseSecureCookie(userConfiguration) {
@@ -109,7 +109,7 @@ export function trackNetworkError(configuration, errorObservable) {
109
109
  if (
110
110
  !isIntakeRequest(request.url, configuration) &&
111
111
  !request.isAborted &&
112
- (isRejected(request) || isServerError(request))
112
+ (isRejected(request) || isServerError(request) || configuration.isServerError(request))
113
113
  ) {
114
114
  errorObservable.notify({
115
115
  message: format(type) + ' error ' + request.method + ' ' + request.url,