@cloudcare/rum-uniapp 1.0.3 → 2.1.2

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.
Files changed (70) hide show
  1. package/README.md +11 -8
  2. package/cjs/boot/buildEnv.js +1 -1
  3. package/cjs/boot/rum.entry.js +73 -2
  4. package/cjs/boot/rum.js +15 -3
  5. package/cjs/core/baseInfo.js +0 -6
  6. package/cjs/core/boundedBuffer.js +28 -0
  7. package/cjs/core/configuration.js +26 -1
  8. package/cjs/core/dataMap.js +5 -1
  9. package/cjs/core/errorCollection.js +5 -6
  10. package/cjs/core/errorFilter.js +47 -0
  11. package/cjs/core/errorTools.js +2 -1
  12. package/cjs/core/lifeCycle.js +1 -0
  13. package/cjs/core/sdk.js +0 -1
  14. package/cjs/core/sessionManagement.js +45 -0
  15. package/cjs/core/transport.js +114 -69
  16. package/cjs/core/xhrProxy.js +3 -2
  17. package/cjs/helper/enums.js +22 -7
  18. package/cjs/helper/limitModification.js +83 -0
  19. package/cjs/helper/tracekit.js +1 -1
  20. package/cjs/helper/utils.js +248 -6
  21. package/cjs/rumEventsCollection/action/actionCollection.js +19 -1
  22. package/cjs/rumEventsCollection/app/appCollection.js +0 -1
  23. package/cjs/rumEventsCollection/assembly.js +41 -14
  24. package/cjs/rumEventsCollection/error/errorCollection.js +37 -5
  25. package/cjs/rumEventsCollection/internalContext.js +34 -0
  26. package/cjs/rumEventsCollection/page/index.js +2 -11
  27. package/cjs/rumEventsCollection/requestCollection.js +9 -2
  28. package/cjs/rumEventsCollection/resource/resourceCollection.js +20 -2
  29. package/cjs/rumEventsCollection/tracing/ddtraceTracer.js +50 -0
  30. package/cjs/rumEventsCollection/tracing/jaegerTracer.js +58 -0
  31. package/cjs/rumEventsCollection/tracing/skywalkingTracer.js +75 -0
  32. package/cjs/rumEventsCollection/tracing/tracer.js +108 -0
  33. package/cjs/rumEventsCollection/tracing/w3cTraceParentTracer.js +51 -0
  34. package/cjs/rumEventsCollection/tracing/zipkinMultiTracer.js +58 -0
  35. package/cjs/rumEventsCollection/tracing/zipkinSingleTracer.js +51 -0
  36. package/esm/boot/buildEnv.js +1 -1
  37. package/esm/boot/rum.entry.js +71 -3
  38. package/esm/boot/rum.js +13 -3
  39. package/esm/core/baseInfo.js +0 -5
  40. package/esm/core/boundedBuffer.js +20 -0
  41. package/esm/core/configuration.js +28 -3
  42. package/esm/core/dataMap.js +5 -1
  43. package/esm/core/errorCollection.js +5 -6
  44. package/esm/core/errorFilter.js +38 -0
  45. package/esm/core/errorTools.js +2 -1
  46. package/esm/core/lifeCycle.js +1 -0
  47. package/esm/core/sdk.js +0 -1
  48. package/esm/core/sessionManagement.js +20 -0
  49. package/esm/core/transport.js +111 -70
  50. package/esm/core/xhrProxy.js +3 -2
  51. package/esm/helper/enums.js +16 -2
  52. package/esm/helper/limitModification.js +57 -0
  53. package/esm/helper/tracekit.js +1 -1
  54. package/esm/helper/utils.js +213 -5
  55. package/esm/rumEventsCollection/action/actionCollection.js +20 -2
  56. package/esm/rumEventsCollection/app/appCollection.js +0 -1
  57. package/esm/rumEventsCollection/assembly.js +40 -15
  58. package/esm/rumEventsCollection/error/errorCollection.js +36 -5
  59. package/esm/rumEventsCollection/internalContext.js +27 -0
  60. package/esm/rumEventsCollection/page/index.js +2 -11
  61. package/esm/rumEventsCollection/requestCollection.js +8 -2
  62. package/esm/rumEventsCollection/resource/resourceCollection.js +21 -3
  63. package/esm/rumEventsCollection/tracing/ddtraceTracer.js +42 -0
  64. package/esm/rumEventsCollection/tracing/jaegerTracer.js +50 -0
  65. package/esm/rumEventsCollection/tracing/skywalkingTracer.js +66 -0
  66. package/esm/rumEventsCollection/tracing/tracer.js +90 -0
  67. package/esm/rumEventsCollection/tracing/w3cTraceParentTracer.js +43 -0
  68. package/esm/rumEventsCollection/tracing/zipkinMultiTracer.js +50 -0
  69. package/esm/rumEventsCollection/tracing/zipkinSingleTracer.js +43 -0
  70. package/package.json +1 -1
@@ -1,7 +1,15 @@
1
- import { isPercentage } from '../helper/utils';
1
+ import { isPercentage, extend2Lev, now, createContextManager, defineGlobal, getGlobalObject, isString, isObject } from '../helper/utils';
2
2
  import { startRum } from './rum';
3
+ import { ActionType } from '../helper/enums';
3
4
  export var makeRum = function makeRum(startRumImpl) {
4
5
  var isAlreadyInitialized = false;
6
+ var globalContextManager = createContextManager();
7
+ var user = {};
8
+
9
+ var _getInternalContext = function getInternalContext() {};
10
+
11
+ var addActionStrategy = function addActionStrategy() {};
12
+
5
13
  var rumGlobal = {
6
14
  init: function init(Vue, userConfiguration) {
7
15
  if (typeof userConfiguration === 'undefined') {
@@ -14,8 +22,45 @@ export var makeRum = function makeRum(startRumImpl) {
14
22
  return;
15
23
  }
16
24
 
17
- startRumImpl(Vue, userConfiguration);
25
+ var _startRumImpl = startRumImpl(Vue, userConfiguration, function () {
26
+ return {
27
+ user: user,
28
+ context: globalContextManager.get()
29
+ };
30
+ });
31
+
32
+ _getInternalContext = _startRumImpl.getInternalContext;
33
+ addActionStrategy = _startRumImpl.addAction;
18
34
  isAlreadyInitialized = true;
35
+ },
36
+ getInternalContext: function getInternalContext(startTime) {
37
+ return _getInternalContext(startTime);
38
+ },
39
+ addRumGlobalContext: globalContextManager.add,
40
+ removeRumGlobalContext: globalContextManager.remove,
41
+ getRumGlobalContext: globalContextManager.get,
42
+ setRumGlobalContext: globalContextManager.set,
43
+ addAction: function addAction(name, context) {
44
+ if (isObject(context) && isString(name)) {
45
+ addActionStrategy({
46
+ name: name,
47
+ context: extend2Lev({}, context),
48
+ startClocks: now(),
49
+ type: ActionType.custom
50
+ });
51
+ }
52
+ },
53
+ setUser: function setUser(newUser) {
54
+ var sanitizedUser = sanitizeUser(newUser);
55
+
56
+ if (sanitizedUser) {
57
+ user = sanitizedUser;
58
+ } else {
59
+ console.error('Unsupported user:', newUser);
60
+ }
61
+ },
62
+ removeUser: function removeUser() {
63
+ user = {};
19
64
  }
20
65
  };
21
66
  return rumGlobal;
@@ -43,5 +88,28 @@ export var makeRum = function makeRum(startRumImpl) {
43
88
 
44
89
  return true;
45
90
  }
91
+
92
+ function sanitizeUser(newUser) {
93
+ if (typeof newUser !== 'object' || !newUser) {
94
+ return;
95
+ }
96
+
97
+ var result = extend2Lev({}, newUser);
98
+
99
+ if ('id' in result) {
100
+ result.id = String(result.id);
101
+ }
102
+
103
+ if ('name' in result) {
104
+ result.name = String(result.name);
105
+ }
106
+
107
+ if ('email' in result) {
108
+ result.email = String(result.email);
109
+ }
110
+
111
+ return result;
112
+ }
46
113
  };
47
- export var datafluxRum = makeRum(startRum);
114
+ export var datafluxRum = makeRum(startRum);
115
+ defineGlobal(getGlobalObject(), 'DATAFLUX_RUM_MIN', datafluxRum);
package/esm/boot/rum.js CHANGED
@@ -12,13 +12,16 @@ import { startAppCollection } from '../rumEventsCollection/app/appCollection';
12
12
  import { startPagePerformanceObservable } from '../rumEventsCollection/performanceCollection';
13
13
  import { startSetDataColloction } from '../rumEventsCollection/setDataCollection';
14
14
  import { startActionCollection } from '../rumEventsCollection/action/actionCollection';
15
+ import { sessionManagement } from '../core/sessionManagement';
16
+ import { startInternalContext } from '../rumEventsCollection/internalContext';
15
17
  import { sdk } from '../core/sdk';
16
- export var startRum = function startRum(Vue, userConfiguration) {
18
+ export var startRum = function startRum(Vue, userConfiguration, getCommonContext) {
17
19
  var configuration = commonInit(userConfiguration, buildEnv);
18
20
  var lifeCycle = new LifeCycle();
19
21
  var parentContexts = startParentContexts(lifeCycle);
20
22
  var batch = startRumBatch(configuration, lifeCycle);
21
- startRumAssembly(userConfiguration.applicationId, configuration, lifeCycle, parentContexts);
23
+ var session = new sessionManagement(configuration);
24
+ startRumAssembly(userConfiguration.applicationId, configuration, session, lifeCycle, parentContexts, getCommonContext);
22
25
  startAppCollection(lifeCycle, configuration);
23
26
  startResourceCollection(lifeCycle, configuration);
24
27
  startViewCollection(lifeCycle, configuration, Vue);
@@ -26,5 +29,12 @@ export var startRum = function startRum(Vue, userConfiguration) {
26
29
  startRequestCollection(lifeCycle, configuration);
27
30
  startPagePerformanceObservable(lifeCycle, configuration);
28
31
  startSetDataColloction(lifeCycle, Vue);
29
- startActionCollection(lifeCycle, configuration, Vue);
32
+
33
+ var _startActionCollection = startActionCollection(lifeCycle, configuration, Vue);
34
+
35
+ var internalContext = startInternalContext(userConfiguration.applicationId, session, parentContexts);
36
+ return {
37
+ addAction: _startActionCollection.addAction,
38
+ getInternalContext: internalContext.get
39
+ };
30
40
  };
@@ -4,7 +4,6 @@ import { CLIENT_ID_TOKEN } from '../helper/enums';
4
4
 
5
5
  class BaseInfo {
6
6
  constructor() {
7
- this.sessionId = UUID();
8
7
  this.getDeviceInfo();
9
8
  this.getNetWork();
10
9
  }
@@ -63,10 +62,6 @@ class BaseInfo {
63
62
  });
64
63
  }
65
64
 
66
- getSessionId() {
67
- return this.sessionId;
68
- }
69
-
70
65
  }
71
66
 
72
67
  export default new BaseInfo();
@@ -0,0 +1,20 @@
1
+ var _BoundedBuffer = function _BoundedBuffer() {
2
+ this.buffer = [];
3
+ };
4
+
5
+ _BoundedBuffer.prototype = {
6
+ add: function add(item) {
7
+ var length = this.buffer.push(item);
8
+
9
+ if (length > this.limit) {
10
+ this.buffer.splice(0, 1);
11
+ }
12
+ },
13
+ drain: function drain(fn) {
14
+ this.buffer.forEach(function (item) {
15
+ fn(item);
16
+ });
17
+ this.buffer.length = 0;
18
+ }
19
+ };
20
+ export var BoundedBuffer = _BoundedBuffer;
@@ -1,5 +1,5 @@
1
- import { extend2Lev, urlParse } from '../helper/utils';
2
- import { ONE_KILO_BYTE, ONE_SECOND } from '../helper/enums';
1
+ import { extend2Lev, urlParse, values } from '../helper/utils';
2
+ import { ONE_KILO_BYTE, ONE_SECOND, TraceType } from '../helper/enums';
3
3
  var TRIM_REGIX = /^\s+|\s+$/g;
4
4
  export var DEFAULT_CONFIGURATION = {
5
5
  sampleRate: 100,
@@ -23,7 +23,11 @@ export var DEFAULT_CONFIGURATION = {
23
23
  * arbitrary value, byte precision not needed
24
24
  */
25
25
  requestErrorResponseLengthLimit: 32 * ONE_KILO_BYTE,
26
- trackInteractions: false
26
+ trackInteractions: false,
27
+ traceType: TraceType.DDTRACE,
28
+ traceId128Bit: false,
29
+ allowedTracingOrigins: [] // 新增
30
+
27
31
  };
28
32
 
29
33
  function trim(str) {
@@ -50,9 +54,30 @@ export function commonInit(userConfiguration, buildEnv) {
50
54
  transportConfiguration.trackInteractions = !!userConfiguration.trackInteractions;
51
55
  }
52
56
 
57
+ if ('allowedTracingOrigins' in userConfiguration) {
58
+ transportConfiguration.allowedTracingOrigins = userConfiguration.allowedTracingOrigins;
59
+ }
60
+
61
+ if ('traceId128Bit' in userConfiguration) {
62
+ transportConfiguration.traceId128Bit = !!userConfiguration.traceId128Bit;
63
+ }
64
+
65
+ if ('traceType' in userConfiguration && hasTraceType(userConfiguration.traceType)) {
66
+ transportConfiguration.traceType = userConfiguration.traceType;
67
+ }
68
+
69
+ if ('sampleRate' in userConfiguration) {
70
+ transportConfiguration.sampleRate = userConfiguration.sampleRate;
71
+ }
72
+
53
73
  return extend2Lev(DEFAULT_CONFIGURATION, transportConfiguration);
54
74
  }
55
75
 
76
+ function hasTraceType(traceType) {
77
+ if (traceType && values(TraceType).indexOf(traceType) > -1) return true;
78
+ return false;
79
+ }
80
+
56
81
  var haveSameOrigin = function haveSameOrigin(url1, url2) {
57
82
  var parseUrl1 = urlParse(url1).getParse();
58
83
  var parseUrl2 = urlParse(url2).getParse();
@@ -6,7 +6,9 @@ export var commonTags = {
6
6
  app_id: 'application.id',
7
7
  env: '_dd.env',
8
8
  version: '_dd.version',
9
- userid: 'user.user_id',
9
+ userid: 'user.id',
10
+ user_email: 'user.email',
11
+ user_name: 'user.name',
10
12
  session_id: 'session.id',
11
13
  session_type: 'session.type',
12
14
  is_signin: 'user.is_signin',
@@ -50,6 +52,8 @@ export var dataMap = {
50
52
  resource: {
51
53
  type: RumEventType.RESOURCE,
52
54
  tags: {
55
+ trace_id: '_dd.trace_id',
56
+ span_id: '_dd.span_id',
53
57
  resource_type: 'resource.type',
54
58
  resource_status: 'resource.status',
55
59
  resource_status_group: 'resource.status_group',
@@ -79,17 +79,16 @@ export function startRuntimeErrorTracking(errorObservable) {
79
79
  export function stopRuntimeErrorTracking() {
80
80
  report.unsubscribe(traceKitReportHandler);
81
81
  }
82
- var filteredErrorsObservable;
82
+ var errorObservable;
83
83
  export function startAutomaticErrorCollection(configuration) {
84
- if (!filteredErrorsObservable) {
85
- var errorObservable = new Observable();
84
+ if (!errorObservable) {
85
+ errorObservable = new Observable();
86
86
  trackNetworkError(configuration, errorObservable);
87
87
  startConsoleTracking(errorObservable);
88
- startRuntimeErrorTracking(errorObservable);
89
- filteredErrorsObservable = filterErrors(configuration, errorObservable);
88
+ startRuntimeErrorTracking(errorObservable); // filteredErrorsObservable = filterErrors(configuration, errorObservable)
90
89
  }
91
90
 
92
- return filteredErrorsObservable;
91
+ return errorObservable;
93
92
  }
94
93
  export function trackNetworkError(configuration, errorObservable) {
95
94
  startXhrProxy().onRequestComplete(function (context) {
@@ -0,0 +1,38 @@
1
+ import { ErrorSource } from './errorTools';
2
+ import { now, ONE_MINUTE } from '../helper/utils';
3
+ export function createErrorFilter(configuration, onLimitReached) {
4
+ var errorCount = 0;
5
+ var allowNextError = false;
6
+ return {
7
+ isLimitReached: function isLimitReached() {
8
+ if (errorCount === 0) {
9
+ setTimeout(function () {
10
+ errorCount = 0;
11
+ }, ONE_MINUTE);
12
+ }
13
+
14
+ errorCount += 1;
15
+
16
+ if (errorCount <= configuration.maxErrorsByMinute || allowNextError) {
17
+ allowNextError = false;
18
+ return false;
19
+ }
20
+
21
+ if (errorCount === configuration.maxErrorsByMinute + 1) {
22
+ allowNextError = true;
23
+
24
+ try {
25
+ onLimitReached({
26
+ message: "Reached max number of errors by minute: ".concat(configuration.maxErrorsByMinute),
27
+ source: ErrorSource.AGENT,
28
+ startTime: now()
29
+ });
30
+ } finally {
31
+ allowNextError = false;
32
+ }
33
+ }
34
+
35
+ return true;
36
+ }
37
+ };
38
+ }
@@ -3,7 +3,8 @@ export var ErrorSource = {
3
3
  CONSOLE: 'console',
4
4
  NETWORK: 'network',
5
5
  SOURCE: 'source',
6
- LOGGER: 'logger'
6
+ LOGGER: 'logger',
7
+ CUSTOM: 'custom'
7
8
  };
8
9
  export function formatUnknownError(stackTrace, errorObject, nonErrorPrefix) {
9
10
  if (!stackTrace || stackTrace.message === undefined && !(errorObject instanceof Error)) {
@@ -40,5 +40,6 @@ export var LifeCycleEventType = {
40
40
  REQUEST_STARTED: 'REQUEST_STARTED',
41
41
  REQUEST_COMPLETED: 'REQUEST_COMPLETED',
42
42
  RAW_RUM_EVENT_COLLECTED: 'RAW_RUM_EVENT_COLLECTED',
43
+ RAW_ERROR_COLLECTED: 'RAW_ERROR_COLLECTED',
43
44
  RUM_EVENT_COLLECTED: 'RUM_EVENT_COLLECTED'
44
45
  };
package/esm/core/sdk.js CHANGED
@@ -34,7 +34,6 @@ function getSDK() {
34
34
  console.warn('unsupport platform, Fail to start');
35
35
  }
36
36
 
37
- console.log('------get SDK-------');
38
37
  return {
39
38
  sdk,
40
39
  tracker
@@ -0,0 +1,20 @@
1
+ import { UUID, performDraw } from '../helper/utils';
2
+ export var SessionType = {
3
+ SYNTHETICS: 'synthetics',
4
+ USER: 'user'
5
+ };
6
+ export class sessionManagement {
7
+ constructor(configuration) {
8
+ this.sessionId = UUID();
9
+ this.isTrack = performDraw(configuration.sampleRate);
10
+ }
11
+
12
+ getSessionId() {
13
+ return this.sessionId;
14
+ }
15
+
16
+ isTracked() {
17
+ return this.isTrack;
18
+ }
19
+
20
+ }
@@ -1,9 +1,11 @@
1
- import { findByPath, escapeRowData, isNumber, each, isString, values, extend } from '../helper/utils';
1
+ import { findByPath, escapeRowData, isNumber, each, isString, values, extend, isObject, isEmptyObject, isArray, isBoolean, toServerDuration } from '../helper/utils';
2
2
  import { sdk } from '../core/sdk';
3
3
  import { LifeCycleEventType } from '../core/lifeCycle';
4
- import { commonTags, dataMap } from './dataMap'; // https://en.wikipedia.org/wiki/UTF-8
4
+ import { commonTags, dataMap } from './dataMap';
5
+ import { RumEventType } from '../helper/enums'; // https://en.wikipedia.org/wiki/UTF-8
5
6
 
6
7
  var HAS_MULTI_BYTES_CHARACTERS = /[^\u0000-\u007F]/;
8
+ var CUSTOM_KEYS = 'custom_keys';
7
9
 
8
10
  function addBatchPrecision(url) {
9
11
  if (!url) return url;
@@ -29,6 +31,112 @@ httpRequest.prototype = {
29
31
  }
30
32
  };
31
33
  export var HttpRequest = httpRequest;
34
+ export var processedMessageByDataMap = function processedMessageByDataMap(message) {
35
+ if (!message || !message.type) return {
36
+ rowStr: '',
37
+ rowData: undefined
38
+ };
39
+ var rowData = {
40
+ tags: {},
41
+ fields: {}
42
+ };
43
+ var hasFileds = false;
44
+ var rowStr = '';
45
+ each(dataMap, function (value, key) {
46
+ if (value.type === message.type) {
47
+ if (value.alias_key) {
48
+ rowStr += value.alias_key + ',';
49
+ } else {
50
+ rowStr += key + ',';
51
+ }
52
+
53
+ rowData.measurement = key;
54
+ var tagsStr = [];
55
+ var tags = extend({}, commonTags, value.tags);
56
+ var filterFileds = ['date', 'type']; // 已经在datamap中定义过的fields和tags
57
+
58
+ each(tags, function (value_path, _key) {
59
+ var _value = findByPath(message, value_path);
60
+
61
+ filterFileds.push(_key);
62
+
63
+ if (_value || isNumber(_value)) {
64
+ rowData.tags[_key] = _value;
65
+ tagsStr.push(escapeRowData(_key) + '=' + escapeRowData(_value));
66
+ }
67
+ });
68
+
69
+ if (message.tags && isObject(message.tags) && !isEmptyObject(message.tags)) {
70
+ // 自定义tag
71
+ var _tagKeys = [];
72
+ each(message.tags, function (_value, _key) {
73
+ // 如果和之前tag重名,则舍弃
74
+ if (filterFileds.indexOf(_key) > -1) return;
75
+ filterFileds.push(_key);
76
+
77
+ if (_value || isNumber(_value)) {
78
+ _tagKeys.push(_key);
79
+
80
+ rowData.tags[_key] = _value;
81
+ tagsStr.push(escapeRowData(_key) + '=' + escapeRowData(_value));
82
+ }
83
+ });
84
+
85
+ if (_tagKeys.length) {
86
+ rowData.tags[CUSTOM_KEYS] = _tagKeys;
87
+ tagsStr.push(escapeRowData(CUSTOM_KEYS) + '=' + escapeRowData(_tagKeys));
88
+ }
89
+ }
90
+
91
+ var fieldsStr = [];
92
+ each(value.fields, function (_value, _key) {
93
+ if (isArray(_value) && _value.length === 2) {
94
+ var type = _value[0],
95
+ value_path = _value[1];
96
+
97
+ var _valueData = findByPath(message, value_path);
98
+
99
+ filterFileds.push(_key);
100
+
101
+ if (_valueData || isNumber(_valueData)) {
102
+ rowData.fields[_key] = _valueData; // 这里不需要转译
103
+
104
+ _valueData = type === 'string' ? '"' + _valueData.replace(/[\\]*"/g, '"').replace(/"/g, '\\"') + '"' : escapeRowData(_valueData);
105
+ fieldsStr.push(escapeRowData(_key) + '=' + _valueData);
106
+ }
107
+ } else if (isString(_value)) {
108
+ var _valueData = findByPath(message, _value);
109
+
110
+ filterFileds.push(_key);
111
+
112
+ if (_valueData || isNumber(_valueData)) {
113
+ rowData.fields[_key] = _valueData; // 这里不需要转译
114
+
115
+ _valueData = escapeRowData(_valueData);
116
+ fieldsStr.push(escapeRowData(_key) + '=' + _valueData);
117
+ }
118
+ }
119
+ });
120
+
121
+ if (tagsStr.length) {
122
+ rowStr += tagsStr.join(',');
123
+ }
124
+
125
+ if (fieldsStr.length) {
126
+ rowStr += ' ';
127
+ rowStr += fieldsStr.join(',');
128
+ hasFileds = true;
129
+ }
130
+
131
+ rowStr = rowStr + ' ' + message.date;
132
+ rowData.time = toServerDuration(message.date); // 这里不需要转译
133
+ }
134
+ });
135
+ return {
136
+ rowStr: hasFileds ? rowStr : '',
137
+ rowData: hasFileds ? rowData : undefined
138
+ };
139
+ };
32
140
 
33
141
  function batch(request, maxSize, bytesLimit, maxMessageSize, flushTimeout, lifeCycle) {
34
142
  this.request = request;
@@ -63,74 +171,7 @@ batch.prototype = {
63
171
  }
64
172
  },
65
173
  processSendData: function processSendData(message) {
66
- // var data = safeJSONParse(message)
67
- if (!message || !message.type) return '';
68
- var rowStr = '';
69
- var hasFileds = false;
70
- each(dataMap, function (value, key) {
71
- if (value.type === message.type) {
72
- // 做一下别名处理
73
- if (value.alias_key) {
74
- rowStr += value.alias_key + ',';
75
- } else {
76
- rowStr += key + ',';
77
- }
78
-
79
- var tagsStr = [];
80
- var tags = extend({}, commonTags, value.tags);
81
- each(tags, function (value_path, _key) {
82
- var _value = findByPath(message, value_path);
83
-
84
- if (_value || isNumber(_value)) {
85
- tagsStr.push(escapeRowData(_key) + '=' + escapeRowData(_value));
86
- }
87
- });
88
-
89
- if (message.tags.length) {
90
- // 自定义tag
91
- each(message.tags, function (_value, _key) {
92
- if (_value || isNumber(_value)) {
93
- tagsStr.push(escapeRowData(_key) + '=' + escapeRowData(_value));
94
- }
95
- });
96
- }
97
-
98
- var fieldsStr = [];
99
- each(value.fields, function (_value, _key) {
100
- if (Array.isArray(_value) && _value.length === 2) {
101
- var type = _value[0],
102
- value_path = _value[1];
103
-
104
- var _valueData = findByPath(message, value_path);
105
-
106
- if (_valueData || isNumber(_valueData)) {
107
- _valueData = type === 'string' ? '"' + String(_valueData).replace(/[\\]*"/g, '"').replace(/"/g, '\\"') + '"' : escapeRowData(_valueData);
108
- fieldsStr.push(escapeRowData(_key) + '=' + _valueData);
109
- }
110
- } else if (isString(_value)) {
111
- var _valueData = findByPath(message, _value);
112
-
113
- if (_valueData || isNumber(_valueData)) {
114
- _valueData = escapeRowData(_valueData);
115
- fieldsStr.push(escapeRowData(_key) + '=' + _valueData);
116
- }
117
- }
118
- });
119
-
120
- if (tagsStr.length) {
121
- rowStr += tagsStr.join(',');
122
- }
123
-
124
- if (fieldsStr.length) {
125
- rowStr += ' ';
126
- rowStr += fieldsStr.join(',');
127
- hasFileds = true;
128
- }
129
-
130
- rowStr = rowStr + ' ' + message.date;
131
- }
132
- });
133
- return hasFileds ? rowStr : '';
174
+ return processedMessageByDataMap(message).rowStr;
134
175
  },
135
176
  sizeInBytes: function sizeInBytes(candidate) {
136
177
  // Accurate byte size computations can degrade performances when there is a lot of events to process
@@ -40,7 +40,8 @@ function proxyXhr() {
40
40
  startTime: 0,
41
41
  url: arguments[0].url,
42
42
  type: RequestType.XHR,
43
- responseType: arguments[0].responseType || 'text'
43
+ responseType: arguments[0].responseType || 'text',
44
+ option: arguments[0]
44
45
  };
45
46
  dataflux_xhr.startTime = now();
46
47
  var originalSuccess = arguments[0].success;
@@ -84,6 +85,6 @@ function proxyXhr() {
84
85
  beforeSendCallbacks.forEach(function (callback) {
85
86
  callback(dataflux_xhr);
86
87
  });
87
- return originalXhrRequest.apply(this, arguments);
88
+ return originalXhrRequest.call(this, dataflux_xhr.option);
88
89
  };
89
90
  }
@@ -10,7 +10,8 @@ export var RumEventType = {
10
10
  VIEW: 'view',
11
11
  RESOURCE: 'resource',
12
12
  APP: 'app',
13
- ACTION: 'action'
13
+ ACTION: 'action',
14
+ LOGGER: 'logger'
14
15
  };
15
16
  export var RequestType = {
16
17
  XHR: 'network',
@@ -19,7 +20,8 @@ export var RequestType = {
19
20
  export var ActionType = {
20
21
  tap: 'tap',
21
22
  longpress: 'longpress',
22
- longtap: 'longtap'
23
+ longtap: 'longtap',
24
+ custom: 'custom'
23
25
  };
24
26
  export var MpHook = {
25
27
  data: 1,
@@ -33,4 +35,16 @@ export var MpHook = {
33
35
  onResize: 1,
34
36
  onHide: 1,
35
37
  onUnload: 1
38
+ };
39
+ export var TraceType = {
40
+ DDTRACE: 'ddtrace',
41
+ ZIPKIN_MULTI_HEADER: 'zipkin',
42
+ ZIPKIN_SINGLE_HEADER: 'zipkin_single_header',
43
+ W3C_TRACEPARENT: 'w3c_traceparent',
44
+ SKYWALKING_V3: 'skywalking_v3',
45
+ JAEGER: 'jaeger'
46
+ };
47
+ export var ErrorHandling = {
48
+ HANDLED: 'handled',
49
+ UNHANDLED: 'unhandled'
36
50
  };
@@ -0,0 +1,57 @@
1
+ import { extend2Lev, each } from './utils';
2
+ /**
3
+ * Current limitations:
4
+ * - field path do not support array, 'a.b.c' only
5
+ * - modifiable fields type must be string
6
+ */
7
+
8
+ export function limitModification(object, modifiableFieldPaths, modifier) {
9
+ var clone = extend2Lev({}, object);
10
+ var result = modifier(clone);
11
+ each(modifiableFieldPaths, function (path) {
12
+ var originalValue = get(object, path);
13
+ var newValue = get(clone, path);
14
+
15
+ if (typeof originalValue === 'string' && typeof newValue === 'string') {
16
+ set(object, path, newValue);
17
+ }
18
+ });
19
+ return result;
20
+ }
21
+
22
+ function get(object, path) {
23
+ var current = object;
24
+
25
+ for (var field of path.split('.')) {
26
+ if (!isValidObjectContaining(current, field)) {
27
+ return;
28
+ }
29
+
30
+ current = current[field];
31
+ }
32
+
33
+ return current;
34
+ }
35
+
36
+ function set(object, path, value) {
37
+ var current = object;
38
+ var fields = path.split('.');
39
+
40
+ for (var i = 0; i < fields.length; i += 1) {
41
+ var field = fields[i];
42
+
43
+ if (!isValidObjectContaining(current, field)) {
44
+ return;
45
+ }
46
+
47
+ if (i !== fields.length - 1) {
48
+ current = current[field];
49
+ } else {
50
+ current[field] = value;
51
+ }
52
+ }
53
+ }
54
+
55
+ function isValidObjectContaining(object, field) {
56
+ return typeof object === 'object' && object !== null && field in object;
57
+ }
@@ -904,7 +904,7 @@ export var computeStackTrace = function computeStackTraceWrapper() {
904
904
  var ERROR_TYPES_RE = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/;
905
905
 
906
906
  function extractMessage(ex) {
907
- var message = ex && ex.message; // console.log('message',message)
907
+ var message = ex && ex.message;
908
908
 
909
909
  if (!message) {
910
910
  return 'No error message';