@cloudcare/rum-uniapp 2.1.18 → 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 +11 -36
  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 +8 -20
  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
@@ -4,32 +4,22 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.clearTracingIfCancelled = clearTracingIfCancelled;
7
- exports.startTracer = startTracer;
8
7
  exports.injectHeadersIfTracingAllowed = injectHeadersIfTracingAllowed;
9
-
8
+ exports.startTracer = startTracer;
10
9
  var _utils = require("../../helper/utils");
11
-
12
10
  var _enums = require("../../helper/enums");
13
-
14
11
  var _ddtraceTracer = require("./ddtraceTracer");
15
-
16
12
  var _skywalkingTracer = require("./skywalkingTracer");
17
-
18
13
  var _jaegerTracer = require("./jaegerTracer");
19
-
20
14
  var _zipkinSingleTracer = require("./zipkinSingleTracer");
21
-
22
15
  var _zipkinMultiTracer = require("./zipkinMultiTracer");
23
-
24
16
  var _w3cTraceParentTracer = require("./w3cTraceParentTracer");
25
-
26
17
  function clearTracingIfCancelled(context) {
27
18
  if (context.status === 0) {
28
19
  context.traceId = undefined;
29
20
  context.spanId = undefined;
30
21
  }
31
22
  }
32
-
33
23
  function startTracer(configuration) {
34
24
  return {
35
25
  clearTracingIfCancelled: clearTracingIfCancelled,
@@ -37,19 +27,16 @@ function startTracer(configuration) {
37
27
  return injectHeadersIfTracingAllowed(configuration, context, function (tracingHeaders) {
38
28
  context.option = (0, _utils.extend)({}, context.option);
39
29
  var header = {};
40
-
41
30
  if (context.option.header) {
42
31
  (0, _utils.each)(context.option.header, function (value, key) {
43
32
  header[key] = value;
44
33
  });
45
34
  }
46
-
47
35
  context.option.header = (0, _utils.extend)(header, tracingHeaders);
48
36
  });
49
37
  }
50
38
  };
51
39
  }
52
-
53
40
  function isAllowedUrl(configuration, requestUrl) {
54
41
  var requestOrigin = (0, _utils.getOrigin)(requestUrl);
55
42
  var flag = false;
@@ -61,47 +48,36 @@ function isAllowedUrl(configuration, requestUrl) {
61
48
  });
62
49
  return flag;
63
50
  }
64
-
65
51
  function injectHeadersIfTracingAllowed(configuration, context, inject) {
66
52
  if (!isAllowedUrl(configuration, context.url) || !configuration.traceType) {
67
53
  return;
68
54
  }
69
-
70
55
  var tracer;
71
-
72
56
  switch (configuration.traceType) {
73
57
  case _enums.TraceType.DDTRACE:
74
58
  tracer = new _ddtraceTracer.DDtraceTracer();
75
59
  break;
76
-
77
60
  case _enums.TraceType.SKYWALKING_V3:
78
61
  tracer = new _skywalkingTracer.SkyWalkingTracer(configuration, context.url);
79
62
  break;
80
-
81
63
  case _enums.TraceType.ZIPKIN_MULTI_HEADER:
82
64
  tracer = new _zipkinMultiTracer.ZipkinMultiTracer(configuration);
83
65
  break;
84
-
85
66
  case _enums.TraceType.JAEGER:
86
67
  tracer = new _jaegerTracer.JaegerTracer(configuration);
87
68
  break;
88
-
89
69
  case _enums.TraceType.W3C_TRACEPARENT:
90
70
  tracer = new _w3cTraceParentTracer.W3cTraceParentTracer(configuration);
91
71
  break;
92
-
93
72
  case _enums.TraceType.ZIPKIN_SINGLE_HEADER:
94
73
  tracer = new _zipkinSingleTracer.ZipkinSingleTracer(configuration);
95
74
  break;
96
-
97
75
  default:
98
76
  break;
99
77
  }
100
-
101
78
  if (!tracer || !tracer.isTracingSupported()) {
102
79
  return;
103
80
  }
104
-
105
81
  context.traceId = tracer.getTraceId();
106
82
  context.spanId = tracer.getSpanId();
107
83
  inject(tracer.makeTracingHeaders());
@@ -4,31 +4,26 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.W3cTraceParentTracer = W3cTraceParentTracer;
7
-
8
7
  // === Generate a random 64-bit number in fixed-length hex format
9
8
  function randomTraceId() {
10
9
  var digits = '0123456789abcdef';
11
10
  var n = '';
12
-
13
11
  for (var i = 0; i < 16; i += 1) {
14
12
  var rand = Math.floor(Math.random() * 16);
15
13
  n += digits[rand];
16
14
  }
17
-
18
15
  return n;
19
16
  }
17
+
20
18
  /**
21
19
  *
22
20
  * @param {*} configuration 配置信息
23
21
  */
24
-
25
-
26
22
  function W3cTraceParentTracer(configuration) {
27
23
  var rootSpanId = randomTraceId();
28
24
  this._traceId = randomTraceId() + rootSpanId;
29
25
  this._spanId = rootSpanId;
30
26
  }
31
-
32
27
  W3cTraceParentTracer.prototype = {
33
28
  isTracingSupported: function isTracingSupported() {
34
29
  return true;
@@ -4,38 +4,31 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.ZipkinMultiTracer = ZipkinMultiTracer;
7
-
8
7
  // === Generate a random 64-bit number in fixed-length hex format
9
8
  function randomTraceId() {
10
9
  var digits = '0123456789abcdef';
11
10
  var n = '';
12
-
13
11
  for (var i = 0; i < 16; i += 1) {
14
12
  var rand = Math.floor(Math.random() * 16);
15
13
  n += digits[rand];
16
14
  }
17
-
18
15
  return n;
19
16
  }
17
+
20
18
  /**
21
19
  *
22
20
  * @param {*} configuration 配置信息
23
21
  */
24
-
25
-
26
22
  function ZipkinMultiTracer(configuration) {
27
23
  var rootSpanId = randomTraceId();
28
-
29
24
  if (configuration.traceId128Bit) {
30
25
  // 128bit生成traceid
31
26
  this._traceId = randomTraceId() + rootSpanId;
32
27
  } else {
33
28
  this._traceId = rootSpanId;
34
29
  }
35
-
36
30
  this._spanId = rootSpanId;
37
31
  }
38
-
39
32
  ZipkinMultiTracer.prototype = {
40
33
  isTracingSupported: function isTracingSupported() {
41
34
  return true;
@@ -51,8 +44,8 @@ ZipkinMultiTracer.prototype = {
51
44
  'X-B3-TraceId': this.getTraceId(),
52
45
  'X-B3-SpanId': this.getSpanId(),
53
46
  // 'X-B3-ParentSpanId': '',
54
- 'X-B3-Sampled': '1' // 'X-B3-Flags': '0'
55
-
47
+ 'X-B3-Sampled': '1'
48
+ // 'X-B3-Flags': '0'
56
49
  };
57
50
  }
58
51
  };
@@ -4,31 +4,26 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.ZipkinSingleTracer = ZipkinSingleTracer;
7
-
8
7
  // === Generate a random 64-bit number in fixed-length hex format
9
8
  function randomTraceId() {
10
9
  var digits = '0123456789abcdef';
11
10
  var n = '';
12
-
13
11
  for (var i = 0; i < 16; i += 1) {
14
12
  var rand = Math.floor(Math.random() * 16);
15
13
  n += digits[rand];
16
14
  }
17
-
18
15
  return n;
19
16
  }
17
+
20
18
  /**
21
19
  *
22
20
  * @param {*} configuration 配置信息
23
21
  */
24
-
25
-
26
22
  function ZipkinSingleTracer(configuration) {
27
23
  var rootSpanId = randomTraceId();
28
24
  this._traceId = randomTraceId() + rootSpanId;
29
25
  this._spanId = rootSpanId;
30
26
  }
31
-
32
27
  ZipkinSingleTracer.prototype = {
33
28
  isTracingSupported: function isTracingSupported() {
34
29
  return true;
@@ -4,18 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.trackEventCounts = trackEventCounts;
7
-
8
7
  var _utils = require("../helper/utils");
9
-
10
8
  var _enums = require("../helper/enums");
11
-
12
9
  var _lifeCycle = require("../core/lifeCycle");
13
-
14
10
  function trackEventCounts(lifeCycle, callback) {
15
11
  if (typeof callback === 'undefined') {
16
12
  callback = _utils.noop;
17
13
  }
18
-
19
14
  var eventCounts = {
20
15
  errorCount: 0,
21
16
  resourceCount: 0,
@@ -24,18 +19,15 @@ function trackEventCounts(lifeCycle, callback) {
24
19
  };
25
20
  var subscription = lifeCycle.subscribe(_lifeCycle.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, function (data) {
26
21
  var rawRumEvent = data.rawRumEvent;
27
-
28
22
  switch (rawRumEvent.type) {
29
23
  case _enums.RumEventType.ERROR:
30
24
  eventCounts.errorCount += 1;
31
25
  callback(eventCounts);
32
26
  break;
33
-
34
27
  case _enums.RumEventType.RESOURCE:
35
28
  eventCounts.resourceCount += 1;
36
29
  callback(eventCounts);
37
30
  break;
38
-
39
31
  case _enums.RumEventType.ACTION:
40
32
  eventCounts.userActionCount += 1;
41
33
  callback(eventCounts);
@@ -3,46 +3,35 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.waitIdlePageActivity = waitIdlePageActivity;
6
+ exports.PAGE_ACTIVITY_VALIDATION_DELAY = exports.PAGE_ACTIVITY_MAX_DURATION = exports.PAGE_ACTIVITY_END_DELAY = void 0;
7
7
  exports.trackPageActivities = trackPageActivities;
8
+ exports.waitIdlePageActivity = waitIdlePageActivity;
8
9
  exports.waitPageActivitiesCompletion = waitPageActivitiesCompletion;
9
- exports.PAGE_ACTIVITY_MAX_DURATION = exports.PAGE_ACTIVITY_END_DELAY = exports.PAGE_ACTIVITY_VALIDATION_DELAY = void 0;
10
-
11
10
  var _utils = require("../helper/utils");
12
-
13
11
  var _lifeCycle = require("../core/lifeCycle");
14
-
15
12
  var _observable = require("../core/observable");
16
-
17
13
  // Delay to wait for a page activity to validate the tracking process
18
- var PAGE_ACTIVITY_VALIDATION_DELAY = 100; // Delay to wait after a page activity to end the tracking process
19
-
20
- exports.PAGE_ACTIVITY_VALIDATION_DELAY = PAGE_ACTIVITY_VALIDATION_DELAY;
21
- var PAGE_ACTIVITY_END_DELAY = 100; // Maximum duration of the tracking process
22
-
23
- exports.PAGE_ACTIVITY_END_DELAY = PAGE_ACTIVITY_END_DELAY;
24
- var PAGE_ACTIVITY_MAX_DURATION = 10000;
25
- exports.PAGE_ACTIVITY_MAX_DURATION = PAGE_ACTIVITY_MAX_DURATION;
26
-
14
+ var PAGE_ACTIVITY_VALIDATION_DELAY = exports.PAGE_ACTIVITY_VALIDATION_DELAY = 100;
15
+ // Delay to wait after a page activity to end the tracking process
16
+ var PAGE_ACTIVITY_END_DELAY = exports.PAGE_ACTIVITY_END_DELAY = 100;
17
+ // Maximum duration of the tracking process
18
+ var PAGE_ACTIVITY_MAX_DURATION = exports.PAGE_ACTIVITY_MAX_DURATION = 10000;
27
19
  function waitIdlePageActivity(lifeCycle, completionCallback) {
28
20
  var _trackPageActivities = trackPageActivities(lifeCycle);
29
-
30
21
  var pageActivitiesObservable = _trackPageActivities.observable;
31
22
  var stopPageActivitiesTracking = _trackPageActivities.stop;
32
-
33
23
  var _waitPageActivitiesCompletion = waitPageActivitiesCompletion(pageActivitiesObservable, stopPageActivitiesTracking, completionCallback);
34
-
35
24
  var stopWaitPageActivitiesCompletion = _waitPageActivitiesCompletion.stop;
36
-
37
25
  function stop() {
38
26
  stopWaitPageActivitiesCompletion();
39
27
  stopPageActivitiesTracking();
40
28
  }
41
-
42
29
  return {
43
30
  stop: stop
44
31
  };
45
- } // Automatic action collection lifecycle overview:
32
+ }
33
+
34
+ // Automatic action collection lifecycle overview:
46
35
  // (Start new trackPageActivities)
47
36
  // .-------------------'--------------------.
48
37
  // v v
@@ -66,8 +55,6 @@ function waitIdlePageActivity(lifeCycle, completionCallback) {
66
55
  //
67
56
  // Note: because MAX_DURATION > VALIDATION_DELAY, we are sure that if the process is still alive
68
57
  // after MAX_DURATION, it has been validated.
69
-
70
-
71
58
  function trackPageActivities(lifeCycle) {
72
59
  var observable = new _observable.Observable();
73
60
  var subscriptions = [];
@@ -82,7 +69,6 @@ function trackPageActivities(lifeCycle) {
82
69
  if (firstRequestIndex === undefined) {
83
70
  firstRequestIndex = startEvent.requestIndex;
84
71
  }
85
-
86
72
  pendingRequestsCount += 1;
87
73
  notifyPageActivity();
88
74
  }));
@@ -91,17 +77,14 @@ function trackPageActivities(lifeCycle) {
91
77
  if (firstRequestIndex === undefined || request.requestIndex < firstRequestIndex) {
92
78
  return;
93
79
  }
94
-
95
80
  pendingRequestsCount -= 1;
96
81
  notifyPageActivity();
97
82
  }));
98
-
99
83
  function notifyPageActivity() {
100
84
  observable.notify({
101
85
  isBusy: pendingRequestsCount > 0
102
86
  });
103
87
  }
104
-
105
88
  return {
106
89
  observable: observable,
107
90
  stop: function stop() {
@@ -111,7 +94,6 @@ function trackPageActivities(lifeCycle) {
111
94
  }
112
95
  };
113
96
  }
114
-
115
97
  function waitPageActivitiesCompletion(pageActivitiesObservable, stopPageActivitiesTracking, completionCallback) {
116
98
  var idleTimeoutId;
117
99
  var hasCompleted = false;
@@ -131,7 +113,6 @@ function waitPageActivitiesCompletion(pageActivitiesObservable, stopPageActiviti
131
113
  clearTimeout(validationTimeoutId);
132
114
  clearTimeout(idleTimeoutId);
133
115
  var lastChangeTime = (0, _utils.now)();
134
-
135
116
  if (!isBusy) {
136
117
  idleTimeoutId = setTimeout(function () {
137
118
  complete({
@@ -141,7 +122,6 @@ function waitPageActivitiesCompletion(pageActivitiesObservable, stopPageActiviti
141
122
  }, PAGE_ACTIVITY_END_DELAY);
142
123
  }
143
124
  });
144
-
145
125
  function stop() {
146
126
  hasCompleted = true;
147
127
  clearTimeout(validationTimeoutId);
@@ -149,16 +129,13 @@ function waitPageActivitiesCompletion(pageActivitiesObservable, stopPageActiviti
149
129
  clearTimeout(maxDurationTimeoutId);
150
130
  stopPageActivitiesTracking();
151
131
  }
152
-
153
132
  function complete(params) {
154
133
  if (hasCompleted) {
155
134
  return;
156
135
  }
157
-
158
136
  stop();
159
137
  completionCallback(params);
160
138
  }
161
-
162
139
  return {
163
140
  stop: stop
164
141
  };
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.startRumBatch = startRumBatch;
7
-
8
7
  var _lifeCycle = require("../../core/lifeCycle");
9
-
10
8
  var _transport = require("../../core/transport");
11
-
12
9
  var _enums = require("../../helper/enums");
13
-
14
10
  function startRumBatch(configuration, lifeCycle) {
15
11
  var batch = makeRumBatch(configuration, lifeCycle);
16
12
  lifeCycle.subscribe(_lifeCycle.LifeCycleEventType.RUM_EVENT_COLLECTED, function (serverRumEvent) {
@@ -26,21 +22,17 @@ function startRumBatch(configuration, lifeCycle) {
26
22
  }
27
23
  };
28
24
  }
29
-
30
25
  function makeRumBatch(configuration, lifeCycle) {
31
26
  var primaryBatch = createRumBatch(configuration.datakitUrl, lifeCycle);
32
-
33
27
  function createRumBatch(endpointUrl, lifeCycle) {
34
28
  return new _transport.Batch(new _transport.HttpRequest(endpointUrl, configuration.batchBytesLimit), configuration.maxBatchSize, configuration.batchBytesLimit, configuration.maxMessageSize, configuration.flushTimeout, lifeCycle);
35
29
  }
36
-
37
30
  var stopped = false;
38
31
  return {
39
32
  add: function add(message) {
40
33
  if (stopped) {
41
34
  return;
42
35
  }
43
-
44
36
  primaryBatch.add(message);
45
37
  },
46
38
  stop: function stop() {
@@ -50,7 +42,6 @@ function makeRumBatch(configuration, lifeCycle) {
50
42
  if (stopped) {
51
43
  return;
52
44
  }
53
-
54
45
  primaryBatch.upsert(message, key);
55
46
  }
56
47
  };
@@ -1,4 +1,4 @@
1
1
  export var buildEnv = {
2
- sdkVersion: '2.1.18',
2
+ sdkVersion: '2.1.20',
3
3
  sdkName: 'df_uniapp_rum_sdk'
4
4
  };
@@ -10,50 +10,40 @@ import { sdk } from '../core/sdk';
10
10
  export var makeRum = function makeRum(startRumImpl) {
11
11
  var isAlreadyInitialized = false;
12
12
  var globalContextManager = createContextManager(CustomerDataType.GlobalContext);
13
- var userContextManager = createContextManager(CustomerDataType.User); // var user = {}
14
-
13
+ var userContextManager = createContextManager(CustomerDataType.User);
14
+ // var user = {}
15
15
  var getInternalContextStrategy = function getInternalContextStrategy() {
16
16
  return undefined;
17
17
  };
18
-
19
18
  var bufferApiCalls = new BoundedBuffer();
20
-
21
19
  var _addActionStrategy = function addActionStrategy(action, commonContext) {
22
20
  if (typeof commonContext == 'undefined') {
23
21
  commonContext = buildCommonContext(globalContextManager, userContextManager);
24
22
  }
25
-
26
23
  bufferApiCalls.add(function () {
27
24
  return _addActionStrategy(action, commonContext);
28
25
  });
29
26
  };
30
-
31
27
  var _addErrorStrategy = function addErrorStrategy(providedError, commonContext) {
32
28
  if (typeof commonContext == 'undefined') {
33
29
  commonContext = buildCommonContext(globalContextManager, userContextManager);
34
30
  }
35
-
36
31
  bufferApiCalls.add(function () {
37
32
  return _addErrorStrategy(providedError, commonContext);
38
33
  });
39
34
  };
40
-
41
35
  var rumGlobal = {
42
36
  init: function init(Vue, userConfiguration) {
43
37
  if (typeof userConfiguration === 'undefined') {
44
38
  userConfiguration = {};
45
39
  }
46
-
47
40
  if (!Vue) return;
48
-
49
41
  if (!canInitRum(userConfiguration)) {
50
42
  return;
51
43
  }
52
-
53
44
  var _startRumImpl = startRumImpl(Vue, userConfiguration, function () {
54
45
  return buildCommonContext(globalContextManager, userContextManager);
55
46
  });
56
-
57
47
  getInternalContextStrategy = _startRumImpl.getInternalContext;
58
48
  _addActionStrategy = _startRumImpl.addAction;
59
49
  _addErrorStrategy = _startRumImpl.addError;
@@ -104,33 +94,31 @@ export var makeRum = function makeRum(startRumImpl) {
104
94
  removeUser: userContextManager.clearContext
105
95
  };
106
96
  return rumGlobal;
107
-
108
97
  function canInitRum(userConfiguration) {
109
98
  if (!sdk) {
110
99
  console.error('DATAFLUX_RUM unsupport platform, Fail to start.');
111
100
  return false;
112
101
  }
113
-
114
102
  if (isAlreadyInitialized) {
115
103
  console.error('DATAFLUX_RUM is already initialized.');
116
104
  return false;
117
105
  }
118
-
119
106
  if (!userConfiguration.applicationId) {
120
107
  console.error('Application ID is not configured, no RUM data will be collected.');
121
108
  return false;
122
109
  }
123
-
124
- if (!userConfiguration.datakitOrigin) {
125
- console.error('datakitOrigin is not configured, no RUM data will be collected.');
110
+ if (!userConfiguration.site && !userConfiguration.datakitOrigin && !userConfiguration.datakitUrl) {
111
+ console.error('datakitOrigin or site is not configured, no RUM data will be collected.');
112
+ return false;
113
+ }
114
+ if (userConfiguration.site && !userConfiguration.clientToken) {
115
+ console.error('clientToken is not configured, no RUM data will be collected.');
126
116
  return false;
127
117
  }
128
-
129
118
  if (userConfiguration.sampleRate !== undefined && !isPercentage(userConfiguration.sampleRate)) {
130
119
  console.error('Sample Rate should be a number between 0 and 100');
131
120
  return false;
132
121
  }
133
-
134
122
  return true;
135
123
  }
136
124
  };
package/esm/boot/rum.js CHANGED
@@ -24,15 +24,11 @@ export var startRum = function startRum(Vue, userConfiguration, getCommonContext
24
24
  startAppCollection(lifeCycle, configuration);
25
25
  startResourceCollection(lifeCycle, configuration);
26
26
  startViewCollection(lifeCycle, configuration, Vue);
27
-
28
27
  var _startErrorCollection = startErrorCollection(lifeCycle, configuration);
29
-
30
28
  startRequestCollection(lifeCycle, configuration);
31
29
  startPagePerformanceObservable(lifeCycle, configuration);
32
30
  startSetDataColloction(lifeCycle, Vue);
33
-
34
31
  var _startActionCollection = startActionCollection(lifeCycle, configuration, Vue);
35
-
36
32
  var internalContext = startInternalContext(userConfiguration.applicationId, session, parentContexts);
37
33
  return {
38
34
  addAction: _startActionCollection.addAction,
@@ -1,25 +1,21 @@
1
1
  import { sdk } from '../core/sdk';
2
2
  import { UUID } from '../helper/utils';
3
3
  import { CLIENT_ID_TOKEN } from '../helper/enums';
4
-
5
4
  class BaseInfo {
6
5
  constructor() {
7
6
  this.getDeviceInfo();
8
7
  this.getNetWork();
9
8
  }
10
-
11
9
  getDeviceInfo() {
12
10
  try {
13
11
  var deviceInfo = sdk.getSystemInfoSync();
14
12
  var osInfo = deviceInfo.system.split(' ');
15
13
  var osVersion = '';
16
-
17
14
  if (osInfo.length > 1) {
18
15
  osVersion = osInfo[1];
19
16
  } else {
20
17
  osVersion = osInfo[0] || '';
21
18
  }
22
-
23
19
  var osVersionMajor = osVersion && osVersion.split('.').length && osVersion.split('.')[0];
24
20
  this.deviceInfo = {
25
21
  screenSize: "".concat(deviceInfo.screenWidth, "*").concat(deviceInfo.screenHeight, " "),
@@ -39,18 +35,14 @@ class BaseInfo {
39
35
  this.deviceInfo = {};
40
36
  }
41
37
  }
42
-
43
38
  getClientID() {
44
39
  var clienetId = sdk.getStorageSync(CLIENT_ID_TOKEN);
45
-
46
40
  if (!clienetId) {
47
41
  clienetId = UUID();
48
42
  sdk.setStorageSync(CLIENT_ID_TOKEN, clienetId);
49
43
  }
50
-
51
44
  return clienetId;
52
45
  }
53
-
54
46
  getNetWork() {
55
47
  sdk.getNetworkType({
56
48
  success: e => {
@@ -61,7 +53,6 @@ class BaseInfo {
61
53
  this.deviceInfo.network = e.networkType ? e.networkType : 'unknown';
62
54
  });
63
55
  }
64
-
65
56
  getLaunchOptions() {
66
57
  if (sdk.getLaunchOptionsSync) {
67
58
  var res = sdk.getLaunchOptionsSync();
@@ -73,7 +64,5 @@ class BaseInfo {
73
64
  return {};
74
65
  }
75
66
  }
76
-
77
67
  }
78
-
79
68
  export default new BaseInfo();
@@ -1,14 +1,11 @@
1
1
  import { each } from '../helper/utils';
2
2
  var BUFFER_LIMIT = 500;
3
-
4
3
  var _BoundedBuffer = function _BoundedBuffer() {
5
4
  this.buffer = [];
6
5
  };
7
-
8
6
  _BoundedBuffer.prototype = {
9
7
  add: function add(callback) {
10
8
  var length = this.buffer.push(callback);
11
-
12
9
  if (length > BUFFER_LIMIT) {
13
10
  this.buffer.splice(0, 1);
14
11
  }