@cloudcare/browser-core 1.0.14 → 1.0.17

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.
@@ -14,6 +14,8 @@ var _cookie = require("./cookie");
14
14
 
15
15
  var _urlPolyfill = require("./helper/urlPolyfill");
16
16
 
17
+ var _enums = require("./helper/enums");
18
+
17
19
  var TRIM_REGIX = /^\s+|\s+$/g;
18
20
  var DEFAULT_CONFIGURATION = {
19
21
  resourceSampleRate: 100,
@@ -39,11 +41,21 @@ var DEFAULT_CONFIGURATION = {
39
41
  batchBytesLimit: 16 * _tools.ONE_KILO_BYTE,
40
42
  datakitUrl: '',
41
43
  logsEndpoint: '',
44
+ traceType: _enums.TraceType.DDTRACE,
45
+ traceId128Bit: false,
42
46
  trackInteractions: false,
43
47
  //是否开启交互action收集
44
48
  allowedDDTracingOrigins: [],
45
- //
46
- beforeSend: function beforeSend(event) {}
49
+ //废弃
50
+ allowedTracingOrigins: [],
51
+ // 新增
52
+ isServiceSampling: false,
53
+ // 是否不抛弃采样是数据, 采用在服务端菜样的方式
54
+ beforeSend: function beforeSend(event) {},
55
+ isServerError: function isServerError(request) {
56
+ return false;
57
+ } // 判断请求是否为error 请求
58
+
47
59
  };
48
60
  exports.DEFAULT_CONFIGURATION = DEFAULT_CONFIGURATION;
49
61
 
@@ -79,6 +91,7 @@ function commonInit(userConfiguration, buildEnv) {
79
91
  applicationId: userConfiguration.applicationId,
80
92
  env: userConfiguration.env || '',
81
93
  version: userConfiguration.version || '',
94
+ service: userConfiguration.service || 'browser',
82
95
  sdkVersion: buildEnv.sdkVersion,
83
96
  sdkName: buildEnv.sdkName,
84
97
  datakitUrl: getDatakitUrl(userConfiguration.datakitUrl || userConfiguration.datakitOrigin),
@@ -90,7 +103,11 @@ function commonInit(userConfiguration, buildEnv) {
90
103
  };
91
104
 
92
105
  if ('allowedDDTracingOrigins' in userConfiguration) {
93
- transportConfiguration.allowedDDTracingOrigins = userConfiguration.allowedDDTracingOrigins;
106
+ transportConfiguration.allowedTracingOrigins = userConfiguration.allowedDDTracingOrigins;
107
+ }
108
+
109
+ if ('allowedTracingOrigins' in userConfiguration) {
110
+ transportConfiguration.allowedTracingOrigins = userConfiguration.allowedTracingOrigins;
94
111
  }
95
112
 
96
113
  if ('sampleRate' in userConfiguration) {
@@ -105,9 +122,30 @@ function commonInit(userConfiguration, buildEnv) {
105
122
  transportConfiguration.trackInteractions = !!userConfiguration.trackInteractions;
106
123
  }
107
124
 
125
+ if ('isServerError' in userConfiguration && (0, _tools.isFunction)(userConfiguration.isServerError) && (0, _tools.isBoolean)(userConfiguration.isServerError())) {
126
+ transportConfiguration.isServerError = userConfiguration.isServerError;
127
+ }
128
+
129
+ if ('traceId128Bit' in userConfiguration) {
130
+ transportConfiguration.traceId128Bit = !!userConfiguration.traceId128Bit;
131
+ }
132
+
133
+ if ('traceType' in userConfiguration && hasTraceType(userConfiguration.traceType)) {
134
+ transportConfiguration.traceType = userConfiguration.traceType;
135
+ }
136
+
137
+ if ('isServiceSampling' in userConfiguration && (0, _tools.isBoolean)(userConfiguration.isServiceSampling)) {
138
+ transportConfiguration.isServiceSampling = userConfiguration.isServiceSampling;
139
+ }
140
+
108
141
  return (0, _tools.extend2Lev)({}, DEFAULT_CONFIGURATION, transportConfiguration);
109
142
  }
110
143
 
144
+ function hasTraceType(traceType) {
145
+ if (traceType && (0, _tools.values)(_enums.TraceType).indexOf(traceType) > -1) return true;
146
+ return false;
147
+ }
148
+
111
149
  function mustUseSecureCookie(userConfiguration) {
112
150
  return !!userConfiguration.useSecureSessionCookie || !!userConfiguration.useCrossSiteSessionCookie;
113
151
  }
package/cjs/cookie.js CHANGED
@@ -42,6 +42,10 @@ function cacheCookieAccess(name, options) {
42
42
  setCookie(name, value, expireDelay, options);
43
43
  cache = value;
44
44
  cacheAccess();
45
+ },
46
+ clearCache: function clearCache() {
47
+ window.clearTimeout(timeout);
48
+ hasCache = false;
45
49
  }
46
50
  };
47
51
  }
package/cjs/dataMap.js CHANGED
@@ -18,6 +18,7 @@ var commonTags = {
18
18
  user_name: 'user.name',
19
19
  session_id: 'session.id',
20
20
  session_type: 'session.type',
21
+ session_sampling: 'session.is_sampling',
21
22
  is_signin: 'user.is_signin',
22
23
  os: 'device.os',
23
24
  os_version: 'device.os_version',
@@ -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: {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.RequestType = exports.RumEventType = exports.ActionType = exports.ResourceType = exports.DOM_EVENT = void 0;
6
+ exports.ErrorHandling = exports.TraceType = exports.RequestType = exports.RumEventType = exports.ActionType = exports.ResourceType = exports.DOM_EVENT = void 0;
7
7
  var DOM_EVENT = {
8
8
  BEFORE_UNLOAD: 'beforeunload',
9
9
  CLICK: 'click',
@@ -53,4 +53,18 @@ var RequestType = {
53
53
  FETCH: ResourceType.FETCH,
54
54
  XHR: ResourceType.XHR
55
55
  };
56
- exports.RequestType = RequestType;
56
+ exports.RequestType = RequestType;
57
+ var TraceType = {
58
+ DDTRACE: 'ddtrace',
59
+ ZIPKIN_MULTI_HEADER: 'zipkin',
60
+ ZIPKIN_SINGLE_HEADER: 'zipkin_single_header',
61
+ W3C_TRACEPARENT: 'w3c_traceparent',
62
+ SKYWALKING_V3: 'skywalking_v3',
63
+ JAEGER: 'jaeger'
64
+ };
65
+ exports.TraceType = TraceType;
66
+ var ErrorHandling = {
67
+ HANDLED: 'handled',
68
+ UNHANDLED: 'unhandled'
69
+ };
70
+ exports.ErrorHandling = ErrorHandling;
@@ -803,8 +803,8 @@ var urlParse = function urlParse(para) {
803
803
 
804
804
  URLParser.prototype.getUrl = function () {
805
805
  var url = '';
806
- url += this._values.Origin;
807
- url += this._values.Port ? ':' + this._values.Port : '';
806
+ url += this._values.Origin; // url += this._values.Port ? ':' + this._values.Port : ''
807
+
808
808
  url += this._values.Path;
809
809
  url += this._values.QueryString ? '?' + this._values.QueryString : '';
810
810
  return url;
@@ -825,8 +825,11 @@ var urlParse = function urlParse(para) {
825
825
  }
826
826
  }
827
827
 
828
+ this._values['Path'] = this._values['Path'] || '/';
828
829
  this._values['Hostname'] = this._values['Host'].replace(/:\d+$/, '');
829
- this._values['Origin'] = this._values['Protocol'] + '://' + this._values['Hostname'];
830
+ this._values['Origin'] = this._values['Protocol'] + '://' + this._values['Hostname'] + (this._values.Port ? ':' + this._values.Port : ''); // this._values['Hostname'] = this._values['Host'].replace(/:\d+$/, '')
831
+ // this._values['Origin'] =
832
+ // this._values['Protocol'] + '://' + this._values['Hostname']
830
833
  };
831
834
 
832
835
  return new URLParser(para);
@@ -53,6 +53,7 @@ function startSessionManagement(options, productKey, computeSessionState) {
53
53
  var currentSession = retrieveActiveSession(sessionCookie);
54
54
  var currentSessionId = currentSession.id;
55
55
  var expandOrRenewSession = (0, _tools.throttle)(function () {
56
+ sessionCookie.clearCache();
56
57
  var session = retrieveActiveSession(sessionCookie);
57
58
  var state = computeSessionState(session[productKey]);
58
59
  session[productKey] = state.trackingType;
@@ -72,6 +73,7 @@ function startSessionManagement(options, productKey, computeSessionState) {
72
73
  }, _cookie.COOKIE_ACCESS_DELAY);
73
74
 
74
75
  var expandSession = function expandSession() {
76
+ sessionCookie.clearCache();
75
77
  var session = retrieveActiveSession(sessionCookie);
76
78
  persistSession(session, sessionCookie);
77
79
  };
package/cjs/transport.js CHANGED
@@ -47,7 +47,10 @@ var HttpRequest = httpRequest;
47
47
  exports.HttpRequest = HttpRequest;
48
48
 
49
49
  var processedMessageByDataMap = function processedMessageByDataMap(message) {
50
- if (!message || !message.type) return '';
50
+ if (!message || !message.type) return {
51
+ rowStr: '',
52
+ rowData: undefined
53
+ };
51
54
  var rowData = {
52
55
  tags: {},
53
56
  fields: {}
@@ -1,6 +1,7 @@
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, values } from './helper/tools';
2
2
  import { getCurrentSite } from './cookie';
3
3
  import { haveSameOrigin } from './helper/urlPolyfill';
4
+ import { TraceType } from './helper/enums';
4
5
  var TRIM_REGIX = /^\s+|\s+$/g;
5
6
  export var DEFAULT_CONFIGURATION = {
6
7
  resourceSampleRate: 100,
@@ -26,11 +27,21 @@ export var DEFAULT_CONFIGURATION = {
26
27
  batchBytesLimit: 16 * ONE_KILO_BYTE,
27
28
  datakitUrl: '',
28
29
  logsEndpoint: '',
30
+ traceType: TraceType.DDTRACE,
31
+ traceId128Bit: false,
29
32
  trackInteractions: false,
30
33
  //是否开启交互action收集
31
34
  allowedDDTracingOrigins: [],
32
- //
33
- beforeSend: function beforeSend(event) {}
35
+ //废弃
36
+ allowedTracingOrigins: [],
37
+ // 新增
38
+ isServiceSampling: false,
39
+ // 是否不抛弃采样是数据, 采用在服务端菜样的方式
40
+ beforeSend: function beforeSend(event) {},
41
+ isServerError: function isServerError(request) {
42
+ return false;
43
+ } // 判断请求是否为error 请求
44
+
34
45
  };
35
46
 
36
47
  function trim(str) {
@@ -65,6 +76,7 @@ export function commonInit(userConfiguration, buildEnv) {
65
76
  applicationId: userConfiguration.applicationId,
66
77
  env: userConfiguration.env || '',
67
78
  version: userConfiguration.version || '',
79
+ service: userConfiguration.service || 'browser',
68
80
  sdkVersion: buildEnv.sdkVersion,
69
81
  sdkName: buildEnv.sdkName,
70
82
  datakitUrl: getDatakitUrl(userConfiguration.datakitUrl || userConfiguration.datakitOrigin),
@@ -76,7 +88,11 @@ export function commonInit(userConfiguration, buildEnv) {
76
88
  };
77
89
 
78
90
  if ('allowedDDTracingOrigins' in userConfiguration) {
79
- transportConfiguration.allowedDDTracingOrigins = userConfiguration.allowedDDTracingOrigins;
91
+ transportConfiguration.allowedTracingOrigins = userConfiguration.allowedDDTracingOrigins;
92
+ }
93
+
94
+ if ('allowedTracingOrigins' in userConfiguration) {
95
+ transportConfiguration.allowedTracingOrigins = userConfiguration.allowedTracingOrigins;
80
96
  }
81
97
 
82
98
  if ('sampleRate' in userConfiguration) {
@@ -91,9 +107,30 @@ export function commonInit(userConfiguration, buildEnv) {
91
107
  transportConfiguration.trackInteractions = !!userConfiguration.trackInteractions;
92
108
  }
93
109
 
110
+ if ('isServerError' in userConfiguration && isFunction(userConfiguration.isServerError) && isBoolean(userConfiguration.isServerError())) {
111
+ transportConfiguration.isServerError = userConfiguration.isServerError;
112
+ }
113
+
114
+ if ('traceId128Bit' in userConfiguration) {
115
+ transportConfiguration.traceId128Bit = !!userConfiguration.traceId128Bit;
116
+ }
117
+
118
+ if ('traceType' in userConfiguration && hasTraceType(userConfiguration.traceType)) {
119
+ transportConfiguration.traceType = userConfiguration.traceType;
120
+ }
121
+
122
+ if ('isServiceSampling' in userConfiguration && isBoolean(userConfiguration.isServiceSampling)) {
123
+ transportConfiguration.isServiceSampling = userConfiguration.isServiceSampling;
124
+ }
125
+
94
126
  return extend2Lev({}, DEFAULT_CONFIGURATION, transportConfiguration);
95
127
  }
96
128
 
129
+ function hasTraceType(traceType) {
130
+ if (traceType && values(TraceType).indexOf(traceType) > -1) return true;
131
+ return false;
132
+ }
133
+
97
134
  function mustUseSecureCookie(userConfiguration) {
98
135
  return !!userConfiguration.useSecureSessionCookie || !!userConfiguration.useCrossSiteSessionCookie;
99
136
  }
package/esm/cookie.js CHANGED
@@ -27,6 +27,10 @@ export function cacheCookieAccess(name, options) {
27
27
  setCookie(name, value, expireDelay, options);
28
28
  cache = value;
29
29
  cacheAccess();
30
+ },
31
+ clearCache: function clearCache() {
32
+ window.clearTimeout(timeout);
33
+ hasCache = false;
30
34
  }
31
35
  };
32
36
  }
package/esm/dataMap.js CHANGED
@@ -10,6 +10,7 @@ export var commonTags = {
10
10
  user_name: 'user.name',
11
11
  session_id: 'session.id',
12
12
  session_type: 'session.type',
13
+ session_sampling: 'session.is_sampling',
13
14
  is_signin: 'user.is_signin',
14
15
  os: 'device.os',
15
16
  os_version: 'device.os_version',
@@ -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: {
@@ -42,4 +42,16 @@ export var RumEventType = {
42
42
  export var RequestType = {
43
43
  FETCH: ResourceType.FETCH,
44
44
  XHR: ResourceType.XHR
45
+ };
46
+ export var TraceType = {
47
+ DDTRACE: 'ddtrace',
48
+ ZIPKIN_MULTI_HEADER: 'zipkin',
49
+ ZIPKIN_SINGLE_HEADER: 'zipkin_single_header',
50
+ W3C_TRACEPARENT: 'w3c_traceparent',
51
+ SKYWALKING_V3: 'skywalking_v3',
52
+ JAEGER: 'jaeger'
53
+ };
54
+ export var ErrorHandling = {
55
+ HANDLED: 'handled',
56
+ UNHANDLED: 'unhandled'
45
57
  };
@@ -625,8 +625,8 @@ export var urlParse = function urlParse(para) {
625
625
 
626
626
  URLParser.prototype.getUrl = function () {
627
627
  var url = '';
628
- url += this._values.Origin;
629
- url += this._values.Port ? ':' + this._values.Port : '';
628
+ url += this._values.Origin; // url += this._values.Port ? ':' + this._values.Port : ''
629
+
630
630
  url += this._values.Path;
631
631
  url += this._values.QueryString ? '?' + this._values.QueryString : '';
632
632
  return url;
@@ -647,8 +647,11 @@ export var urlParse = function urlParse(para) {
647
647
  }
648
648
  }
649
649
 
650
+ this._values['Path'] = this._values['Path'] || '/';
650
651
  this._values['Hostname'] = this._values['Host'].replace(/:\d+$/, '');
651
- this._values['Origin'] = this._values['Protocol'] + '://' + this._values['Hostname'];
652
+ this._values['Origin'] = this._values['Protocol'] + '://' + this._values['Hostname'] + (this._values.Port ? ':' + this._values.Port : ''); // this._values['Hostname'] = this._values['Host'].replace(/:\d+$/, '')
653
+ // this._values['Origin'] =
654
+ // this._values['Protocol'] + '://' + this._values['Hostname']
652
655
  };
653
656
 
654
657
  return new URLParser(para);
@@ -31,6 +31,7 @@ export function startSessionManagement(options, productKey, computeSessionState)
31
31
  var currentSession = retrieveActiveSession(sessionCookie);
32
32
  var currentSessionId = currentSession.id;
33
33
  var expandOrRenewSession = throttle(function () {
34
+ sessionCookie.clearCache();
34
35
  var session = retrieveActiveSession(sessionCookie);
35
36
  var state = computeSessionState(session[productKey]);
36
37
  session[productKey] = state.trackingType;
@@ -50,6 +51,7 @@ export function startSessionManagement(options, productKey, computeSessionState)
50
51
  }, COOKIE_ACCESS_DELAY);
51
52
 
52
53
  var expandSession = function expandSession() {
54
+ sessionCookie.clearCache();
53
55
  var session = retrieveActiveSession(sessionCookie);
54
56
  persistSession(session, sessionCookie);
55
57
  };
package/esm/transport.js CHANGED
@@ -35,7 +35,10 @@ httpRequest.prototype = {
35
35
  };
36
36
  export var HttpRequest = httpRequest;
37
37
  export var processedMessageByDataMap = function processedMessageByDataMap(message) {
38
- if (!message || !message.type) return '';
38
+ if (!message || !message.type) return {
39
+ rowStr: '',
40
+ rowData: undefined
41
+ };
39
42
  var rowData = {
40
43
  tags: {},
41
44
  fields: {}
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.17",
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": "aa44bc2dbca2017e36e0561d810825e89715d847"
24
24
  }
@@ -3,10 +3,14 @@ import {
3
3
  ONE_SECOND,
4
4
  extend2Lev,
5
5
  isArray,
6
- includes
6
+ includes,
7
+ isFunction,
8
+ isBoolean,
9
+ values
7
10
  } from './helper/tools'
8
11
  import { getCurrentSite } from './cookie'
9
12
  import { haveSameOrigin } from './helper/urlPolyfill'
13
+ import { TraceType } from './helper/enums'
10
14
  var TRIM_REGIX = /^\s+|\s+$/g
11
15
  export var DEFAULT_CONFIGURATION = {
12
16
  resourceSampleRate: 100,
@@ -30,9 +34,14 @@ export var DEFAULT_CONFIGURATION = {
30
34
  batchBytesLimit: 16 * ONE_KILO_BYTE,
31
35
  datakitUrl: '',
32
36
  logsEndpoint: '',
37
+ traceType: TraceType.DDTRACE,
38
+ traceId128Bit: false,
33
39
  trackInteractions: false, //是否开启交互action收集
34
- allowedDDTracingOrigins: [], //
35
- beforeSend: function (event) {}
40
+ allowedDDTracingOrigins: [], //废弃
41
+ allowedTracingOrigins:[], // 新增
42
+ isServiceSampling: false, // 是否不抛弃采样是数据, 采用在服务端菜样的方式
43
+ beforeSend: function (event) {},
44
+ isServerError: function(request) {return false} // 判断请求是否为error 请求
36
45
  }
37
46
  function trim(str) {
38
47
  return str.replace(TRIM_REGIX, '')
@@ -68,6 +77,7 @@ export function commonInit(userConfiguration, buildEnv) {
68
77
  applicationId: userConfiguration.applicationId,
69
78
  env: userConfiguration.env || '',
70
79
  version: userConfiguration.version || '',
80
+ service: userConfiguration.service || 'browser',
71
81
  sdkVersion: buildEnv.sdkVersion,
72
82
  sdkName: buildEnv.sdkName,
73
83
  datakitUrl: getDatakitUrl(
@@ -78,10 +88,12 @@ export function commonInit(userConfiguration, buildEnv) {
78
88
  cookieOptions: buildCookieOptions(userConfiguration)
79
89
  }
80
90
  if ('allowedDDTracingOrigins' in userConfiguration) {
81
- transportConfiguration.allowedDDTracingOrigins =
91
+ transportConfiguration.allowedTracingOrigins =
82
92
  userConfiguration.allowedDDTracingOrigins
83
93
  }
84
-
94
+ if ('allowedTracingOrigins' in userConfiguration) {
95
+ transportConfiguration.allowedTracingOrigins = userConfiguration.allowedTracingOrigins
96
+ }
85
97
  if ('sampleRate' in userConfiguration) {
86
98
  transportConfiguration.sampleRate = userConfiguration.sampleRate
87
99
  }
@@ -94,8 +106,24 @@ export function commonInit(userConfiguration, buildEnv) {
94
106
  if ('trackInteractions' in userConfiguration) {
95
107
  transportConfiguration.trackInteractions = !!userConfiguration.trackInteractions
96
108
  }
109
+ if ('isServerError' in userConfiguration && isFunction(userConfiguration.isServerError) && isBoolean(userConfiguration.isServerError())) {
110
+ transportConfiguration.isServerError = userConfiguration.isServerError
111
+ }
112
+ if ('traceId128Bit' in userConfiguration) {
113
+ transportConfiguration.traceId128Bit = !!userConfiguration.traceId128Bit
114
+ }
115
+ if ('traceType' in userConfiguration && hasTraceType(userConfiguration.traceType)) {
116
+ transportConfiguration.traceType = userConfiguration.traceType
117
+ }
118
+ if ('isServiceSampling' in userConfiguration && isBoolean(userConfiguration.isServiceSampling)) {
119
+ transportConfiguration.isServiceSampling = userConfiguration.isServiceSampling
120
+ }
97
121
  return extend2Lev({}, DEFAULT_CONFIGURATION, transportConfiguration)
98
122
  }
123
+ function hasTraceType(traceType) {
124
+ if (traceType && values(TraceType).indexOf(traceType) > -1) return true
125
+ return false
126
+ }
99
127
  function mustUseSecureCookie(userConfiguration) {
100
128
  return (
101
129
  !!userConfiguration.useSecureSessionCookie ||
package/src/cookie.js CHANGED
@@ -26,7 +26,11 @@ export function cacheCookieAccess(name, options) {
26
26
  setCookie(name, value, expireDelay, options)
27
27
  cache = value
28
28
  cacheAccess()
29
- }
29
+ },
30
+ clearCache: function() {
31
+ window.clearTimeout(timeout)
32
+ hasCache = false
33
+ },
30
34
  }
31
35
  }
32
36
 
package/src/dataMap.js CHANGED
@@ -10,6 +10,7 @@ export var commonTags = {
10
10
  user_name: 'user.name',
11
11
  session_id: 'session.id',
12
12
  session_type: 'session.type',
13
+ session_sampling: 'session.is_sampling',
13
14
  is_signin: 'user.is_signin',
14
15
  os: 'device.os',
15
16
  os_version: 'device.os_version',
@@ -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,
@@ -45,3 +45,16 @@ export var RequestType = {
45
45
  FETCH: ResourceType.FETCH,
46
46
  XHR: ResourceType.XHR
47
47
  }
48
+
49
+ export var TraceType = {
50
+ DDTRACE: 'ddtrace',
51
+ ZIPKIN_MULTI_HEADER: 'zipkin',
52
+ ZIPKIN_SINGLE_HEADER: 'zipkin_single_header',
53
+ W3C_TRACEPARENT: 'w3c_traceparent',
54
+ SKYWALKING_V3: 'skywalking_v3',
55
+ JAEGER: 'jaeger',
56
+ }
57
+ export var ErrorHandling = {
58
+ HANDLED: 'handled',
59
+ UNHANDLED: 'unhandled',
60
+ }
@@ -613,7 +613,7 @@ export var urlParse = function (para) {
613
613
  URLParser.prototype.getUrl = function () {
614
614
  var url = ''
615
615
  url += this._values.Origin
616
- url += this._values.Port ? ':' + this._values.Port : ''
616
+ // url += this._values.Port ? ':' + this._values.Port : ''
617
617
  url += this._values.Path
618
618
  url += this._values.QueryString ? '?' + this._values.QueryString : ''
619
619
  return url
@@ -629,9 +629,13 @@ export var urlParse = function (para) {
629
629
  this._values[c] = b[this._fields[c]]
630
630
  }
631
631
  }
632
- this._values['Hostname'] = this._values['Host'].replace(/:\d+$/, '')
633
- this._values['Origin'] =
634
- this._values['Protocol'] + '://' + this._values['Hostname']
632
+ this._values['Path'] = this._values['Path'] || '/'
633
+ this._values['Hostname'] = this._values['Host'].replace(/:\d+$/, '')
634
+ this._values['Origin'] =
635
+ this._values['Protocol'] + '://' + this._values['Hostname'] + (this._values.Port ? ':' + this._values.Port : '')
636
+ // this._values['Hostname'] = this._values['Host'].replace(/:\d+$/, '')
637
+ // this._values['Origin'] =
638
+ // this._values['Protocol'] + '://' + this._values['Hostname']
635
639
  }
636
640
  return new URLParser(para)
637
641
  }
@@ -41,6 +41,7 @@ export function startSessionManagement(
41
41
  var currentSession = retrieveActiveSession(sessionCookie)
42
42
  var currentSessionId = currentSession.id
43
43
  var expandOrRenewSession = throttle(function () {
44
+ sessionCookie.clearCache()
44
45
  var session = retrieveActiveSession(sessionCookie)
45
46
  var state = computeSessionState(session[productKey])
46
47
  session[productKey] = state.trackingType
@@ -59,6 +60,7 @@ export function startSessionManagement(
59
60
  }, COOKIE_ACCESS_DELAY)
60
61
 
61
62
  var expandSession = function () {
63
+ sessionCookie.clearCache()
62
64
  var session = retrieveActiveSession(sessionCookie)
63
65
  persistSession(session, sessionCookie)
64
66
  }
package/src/transport.js CHANGED
@@ -44,7 +44,10 @@ httpRequest.prototype = {
44
44
 
45
45
  export var HttpRequest = httpRequest
46
46
  export var processedMessageByDataMap = function (message) {
47
- if (!message || !message.type) return ''
47
+ if (!message || !message.type) return {
48
+ rowStr: '',
49
+ rowData: undefined
50
+ }
48
51
  var rowData = { tags: {}, fields: {} }
49
52
  var hasFileds = false
50
53
  var rowStr = ''