@cloudcare/rum-uniapp 2.1.17 → 2.1.20

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 (105) hide show
  1. package/README.md +42 -34
  2. package/cjs/boot/buildEnv.js +3 -4
  3. package/cjs/boot/rum.entry.js +12 -37
  4. package/cjs/boot/rum.js +2 -25
  5. package/cjs/core/baseInfo.js +6 -25
  6. package/cjs/core/boundedBuffer.js +1 -7
  7. package/cjs/core/configuration.js +15 -27
  8. package/cjs/core/contextManager.js +5 -17
  9. package/cjs/core/dataMap.js +5 -10
  10. package/cjs/core/downloadProxy.js +4 -26
  11. package/cjs/core/errorCollection.js +5 -35
  12. package/cjs/core/errorFilter.js +0 -8
  13. package/cjs/core/errorTools.js +2 -10
  14. package/cjs/core/heavyCustomerDataWarning.js +3 -9
  15. package/cjs/core/lifeCycle.js +8 -18
  16. package/cjs/core/observable.js +7 -13
  17. package/cjs/core/sdk.js +4 -13
  18. package/cjs/core/sessionManagement.js +8 -17
  19. package/cjs/core/transport.js +6 -53
  20. package/cjs/core/user.js +2 -7
  21. package/cjs/core/xhrProxy.js +4 -26
  22. package/cjs/helper/byteUtils.js +6 -12
  23. package/cjs/helper/commonContext.js +2 -3
  24. package/cjs/helper/enums.js +17 -28
  25. package/cjs/helper/jsonStringify.js +5 -12
  26. package/cjs/helper/limitModification.js +3 -21
  27. package/cjs/helper/tracekit.js +33 -145
  28. package/cjs/helper/utils.js +92 -306
  29. package/cjs/index.js +0 -1
  30. package/cjs/rumEventsCollection/action/actionCollection.js +0 -9
  31. package/cjs/rumEventsCollection/action/trackActions.js +6 -28
  32. package/cjs/rumEventsCollection/app/appCollection.js +0 -6
  33. package/cjs/rumEventsCollection/app/index.js +14 -26
  34. package/cjs/rumEventsCollection/assembly.js +0 -14
  35. package/cjs/rumEventsCollection/error/errorCollection.js +1 -16
  36. package/cjs/rumEventsCollection/internalContext.js +0 -2
  37. package/cjs/rumEventsCollection/page/index.js +5 -43
  38. package/cjs/rumEventsCollection/page/viewCollection.js +0 -8
  39. package/cjs/rumEventsCollection/parentContexts.js +3 -20
  40. package/cjs/rumEventsCollection/performanceCollection.js +0 -4
  41. package/cjs/rumEventsCollection/requestCollection.js +1 -14
  42. package/cjs/rumEventsCollection/resource/resourceCollection.js +0 -11
  43. package/cjs/rumEventsCollection/resource/resourceUtils.js +50 -46
  44. package/cjs/rumEventsCollection/setDataCollection.js +0 -16
  45. package/cjs/rumEventsCollection/tracing/ddtraceTracer.js +0 -6
  46. package/cjs/rumEventsCollection/tracing/jaegerTracer.js +3 -9
  47. package/cjs/rumEventsCollection/tracing/skywalkingTracer.js +3 -10
  48. package/cjs/rumEventsCollection/tracing/tracer.js +1 -25
  49. package/cjs/rumEventsCollection/tracing/w3cTraceParentTracer.js +1 -6
  50. package/cjs/rumEventsCollection/tracing/zipkinMultiTracer.js +3 -10
  51. package/cjs/rumEventsCollection/tracing/zipkinSingleTracer.js +1 -6
  52. package/cjs/rumEventsCollection/trackEventCounts.js +0 -8
  53. package/cjs/rumEventsCollection/trackPageActiveites.js +10 -33
  54. package/cjs/rumEventsCollection/transport/batch.js +0 -9
  55. package/esm/boot/buildEnv.js +1 -1
  56. package/esm/boot/rum.entry.js +9 -21
  57. package/esm/boot/rum.js +0 -4
  58. package/esm/core/baseInfo.js +0 -11
  59. package/esm/core/boundedBuffer.js +0 -3
  60. package/esm/core/configuration.js +13 -21
  61. package/esm/core/contextManager.js +3 -8
  62. package/esm/core/dataMap.js +2 -2
  63. package/esm/core/downloadProxy.js +2 -17
  64. package/esm/core/errorCollection.js +2 -15
  65. package/esm/core/errorFilter.js +0 -5
  66. package/esm/core/errorTools.js +0 -3
  67. package/esm/core/heavyCustomerDataWarning.js +3 -3
  68. package/esm/core/lifeCycle.js +0 -5
  69. package/esm/core/observable.js +0 -3
  70. package/esm/core/sdk.js +1 -6
  71. package/esm/core/sessionManagement.js +0 -3
  72. package/esm/core/transport.js +4 -38
  73. package/esm/core/user.js +2 -4
  74. package/esm/core/xhrProxy.js +2 -17
  75. package/esm/helper/byteUtils.js +4 -7
  76. package/esm/helper/commonContext.js +2 -2
  77. package/esm/helper/jsonStringify.js +4 -7
  78. package/esm/helper/limitModification.js +1 -11
  79. package/esm/helper/tracekit.js +30 -130
  80. package/esm/helper/utils.js +27 -125
  81. package/esm/rumEventsCollection/action/actionCollection.js +0 -4
  82. package/esm/rumEventsCollection/action/trackActions.js +6 -20
  83. package/esm/rumEventsCollection/app/appCollection.js +0 -1
  84. package/esm/rumEventsCollection/app/index.js +12 -18
  85. package/esm/rumEventsCollection/assembly.js +0 -6
  86. package/esm/rumEventsCollection/error/errorCollection.js +0 -7
  87. package/esm/rumEventsCollection/internalContext.js +0 -1
  88. package/esm/rumEventsCollection/page/index.js +5 -37
  89. package/esm/rumEventsCollection/page/viewCollection.js +0 -3
  90. package/esm/rumEventsCollection/parentContexts.js +0 -10
  91. package/esm/rumEventsCollection/requestCollection.js +0 -4
  92. package/esm/rumEventsCollection/resource/resourceCollection.js +0 -5
  93. package/esm/rumEventsCollection/resource/resourceUtils.js +48 -39
  94. package/esm/rumEventsCollection/setDataCollection.js +0 -13
  95. package/esm/rumEventsCollection/tracing/ddtraceTracer.js +0 -4
  96. package/esm/rumEventsCollection/tracing/jaegerTracer.js +3 -7
  97. package/esm/rumEventsCollection/tracing/skywalkingTracer.js +5 -9
  98. package/esm/rumEventsCollection/tracing/tracer.js +0 -14
  99. package/esm/rumEventsCollection/tracing/w3cTraceParentTracer.js +1 -4
  100. package/esm/rumEventsCollection/tracing/zipkinMultiTracer.js +3 -8
  101. package/esm/rumEventsCollection/tracing/zipkinSingleTracer.js +1 -4
  102. package/esm/rumEventsCollection/trackEventCounts.js +0 -4
  103. package/esm/rumEventsCollection/trackPageActiveites.js +9 -22
  104. package/esm/rumEventsCollection/transport/batch.js +0 -5
  105. package/package.json +6 -3
package/esm/core/user.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { extend, getType, each } from '../helper/utils';
2
+
2
3
  /**
3
4
  * Clone input data and ensure known user properties (id, name, email)
4
5
  * are strings, as defined here:
5
6
  * https://docs.datadoghq.com/logs/log_configuration/attributes_naming_convention/#user-related-attributes
6
7
  */
7
-
8
8
  export function sanitizeUser(newUser) {
9
9
  // We shallow clone only to prevent mutation of user data.
10
10
  var user = extend({}, newUser);
@@ -16,16 +16,14 @@ export function sanitizeUser(newUser) {
16
16
  });
17
17
  return user;
18
18
  }
19
+
19
20
  /**
20
21
  * Simple check to ensure user is valid
21
22
  */
22
-
23
23
  export function checkUser(newUser) {
24
24
  var isValid = getType(newUser) === 'object';
25
-
26
25
  if (!isValid) {
27
26
  console.error('Unsupported user:', newUser);
28
27
  }
29
-
30
28
  return isValid;
31
29
  }
@@ -17,7 +17,6 @@ export function startXhrProxy(userConfiguration) {
17
17
  }
18
18
  };
19
19
  }
20
-
21
20
  return xhrProxySingleton;
22
21
  }
23
22
  export function resetXhrProxy() {
@@ -28,13 +27,10 @@ export function resetXhrProxy() {
28
27
  sdk.request = originalXhrRequest;
29
28
  }
30
29
  }
31
-
32
30
  function proxyXhr(userConfiguration) {
33
31
  originalXhrRequest = sdk.request;
34
-
35
32
  sdk.request = function () {
36
33
  var _this = this;
37
-
38
34
  var dataflux_xhr = {
39
35
  method: arguments[0].method || 'GET',
40
36
  startTime: 0,
@@ -45,32 +41,24 @@ function proxyXhr(userConfiguration) {
45
41
  };
46
42
  dataflux_xhr.startTime = now();
47
43
  var originalSuccess = arguments[0].success;
48
-
49
44
  arguments[0].success = function () {
50
45
  reportXhr(arguments[0]);
51
-
52
46
  if (typeof originalSuccess === 'function') {
53
47
  originalSuccess.apply(_this, arguments);
54
48
  }
55
49
  };
56
-
57
50
  var originalFail = arguments[0].fail;
58
-
59
51
  arguments[0].fail = function () {
60
52
  reportXhr(arguments[0]);
61
-
62
53
  if (typeof originalFail === 'function') {
63
54
  originalFail.apply(_this, arguments);
64
55
  }
65
56
  };
66
-
67
57
  var hasBeenReported = false;
68
-
69
58
  var reportXhr = function reportXhr(res) {
70
59
  if (hasBeenReported) {
71
60
  return;
72
61
  }
73
-
74
62
  hasBeenReported = true;
75
63
  dataflux_xhr.duration = now() - dataflux_xhr.startTime;
76
64
  dataflux_xhr.response = JSON.stringify(res.data);
@@ -81,16 +69,14 @@ function proxyXhr(userConfiguration) {
81
69
  callback(dataflux_xhr);
82
70
  });
83
71
  };
84
-
85
72
  beforeSendCallbacks.forEach(function (callback) {
86
73
  callback(dataflux_xhr);
87
74
  });
88
- var result = originalXhrRequest.call(this, dataflux_xhr.option); // 判断结果是否为promise
89
-
75
+ var result = originalXhrRequest.call(this, dataflux_xhr.option);
76
+ // 判断结果是否为promise
90
77
  var isPromise = function isPromise(obj) {
91
78
  return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
92
79
  };
93
-
94
80
  if (isPromise(result) && userConfiguration.isVue2) {
95
81
  // vue2 版本,success, fail 都在then返回
96
82
  return result.then(function (res) {
@@ -99,7 +85,6 @@ function proxyXhr(userConfiguration) {
99
85
  } else {
100
86
  reportXhr(res[1]);
101
87
  }
102
-
103
88
  return res;
104
89
  });
105
90
  } else if (isPromise(result) && !userConfiguration.isVue2) {
@@ -1,19 +1,17 @@
1
1
  export var ONE_KIBI_BYTE = 1024;
2
- export var ONE_MEBI_BYTE = 1024 * ONE_KIBI_BYTE; // eslint-disable-next-line no-control-regex
3
-
2
+ export var ONE_MEBI_BYTE = 1024 * ONE_KIBI_BYTE;
3
+ // eslint-disable-next-line no-control-regex
4
4
  var HAS_MULTI_BYTES_CHARACTERS = /[^\u0000-\u007F]/;
5
5
  export function computeBytesCount(candidate) {
6
6
  // Accurate byte size computations can degrade performances when there is a lot of events to process
7
7
  if (!HAS_MULTI_BYTES_CHARACTERS.test(candidate)) {
8
8
  return candidate.length;
9
9
  }
10
-
11
10
  var total = 0,
12
- charCode; // utf-8编码
13
-
11
+ charCode;
12
+ // utf-8编码
14
13
  for (var i = 0, len = candidate.length; i < len; i++) {
15
14
  charCode = candidate.charCodeAt(i);
16
-
17
15
  if (charCode <= 0x007f) {
18
16
  total += 1;
19
17
  } else if (charCode <= 0x07ff) {
@@ -24,6 +22,5 @@ export function computeBytesCount(candidate) {
24
22
  total += 4;
25
23
  }
26
24
  }
27
-
28
25
  return total;
29
26
  }
@@ -1,7 +1,7 @@
1
1
  export function buildCommonContext(globalContextManager, userContextManager) {
2
2
  return {
3
3
  context: globalContextManager.getContext(),
4
- user: userContextManager.getContext() // hasReplay: recorderApi.isRecording() ? true : undefined,
5
-
4
+ user: userContextManager.getContext()
5
+ // hasReplay: recorderApi.isRecording() ? true : undefined,
6
6
  };
7
7
  }
@@ -1,4 +1,5 @@
1
1
  import { noop } from './utils';
2
+
2
3
  /**
3
4
  * Custom implementation of JSON.stringify that ignores some toJSON methods. We need to do that
4
5
  * because some sites badly override toJSON on certain objects. Removing all toJSON methods from
@@ -7,19 +8,17 @@ import { noop } from './utils';
7
8
  *
8
9
  * Note: this still assumes that JSON.stringify is correct.
9
10
  */
10
-
11
11
  export function jsonStringify(value, replacer, space) {
12
12
  if (typeof value !== 'object' || value === null) {
13
13
  return JSON.stringify(value);
14
- } // Note: The order matter here. We need to detach toJSON methods on parent classes before their
15
- // subclasses.
16
-
14
+ }
17
15
 
16
+ // Note: The order matter here. We need to detach toJSON methods on parent classes before their
17
+ // subclasses.
18
18
  var restoreObjectPrototypeToJson = detachToJsonMethod(Object.prototype);
19
19
  var restoreArrayPrototypeToJson = detachToJsonMethod(Array.prototype);
20
20
  var restoreValuePrototypeToJson = detachToJsonMethod(Object.getPrototypeOf(value));
21
21
  var restoreValueToJson = detachToJsonMethod(value);
22
-
23
22
  try {
24
23
  return JSON.stringify(value, replacer, space);
25
24
  } catch (error) {
@@ -34,13 +33,11 @@ export function jsonStringify(value, replacer, space) {
34
33
  export function detachToJsonMethod(value) {
35
34
  var object = value;
36
35
  var objectToJson = object.toJSON;
37
-
38
36
  if (objectToJson) {
39
37
  delete object.toJSON;
40
38
  return () => {
41
39
  object.toJSON = objectToJson;
42
40
  };
43
41
  }
44
-
45
42
  return noop;
46
43
  }
@@ -1,49 +1,40 @@
1
1
  import { extend2Lev, each } from './utils';
2
+
2
3
  /**
3
4
  * Current limitations:
4
5
  * - field path do not support array, 'a.b.c' only
5
6
  * - modifiable fields type must be string
6
7
  */
7
-
8
8
  export function limitModification(object, modifiableFieldPaths, modifier) {
9
9
  var clone = extend2Lev({}, object);
10
10
  var result = modifier(clone);
11
11
  each(modifiableFieldPaths, function (path) {
12
12
  var originalValue = get(object, path);
13
13
  var newValue = get(clone, path);
14
-
15
14
  if (typeof originalValue === 'string' && typeof newValue === 'string') {
16
15
  set(object, path, newValue);
17
16
  }
18
17
  });
19
18
  return result;
20
19
  }
21
-
22
20
  function get(object, path) {
23
21
  var current = object;
24
-
25
22
  for (var field of path.split('.')) {
26
23
  if (!isValidObjectContaining(current, field)) {
27
24
  return;
28
25
  }
29
-
30
26
  current = current[field];
31
27
  }
32
-
33
28
  return current;
34
29
  }
35
-
36
30
  function set(object, path, value) {
37
31
  var current = object;
38
32
  var fields = path.split('.');
39
-
40
33
  for (var i = 0; i < fields.length; i += 1) {
41
34
  var field = fields[i];
42
-
43
35
  if (!isValidObjectContaining(current, field)) {
44
36
  return;
45
37
  }
46
-
47
38
  if (i !== fields.length - 1) {
48
39
  current = current[field];
49
40
  } else {
@@ -51,7 +42,6 @@ function set(object, path, value) {
51
42
  }
52
43
  }
53
44
  }
54
-
55
45
  function isValidObjectContaining(object, field) {
56
46
  return typeof object === 'object' && object !== null && field in object;
57
47
  }