@cloudcare/browser-rum 3.3.24 → 3.3.26

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 (209) hide show
  1. package/README.md +33 -0
  2. package/README.zh.md +30 -0
  3. package/bundle/dataflux-rum.js +1 -1
  4. package/cjs/boot/buildEnv.js +1 -1
  5. package/cjs/boot/disabledRumPublicApi.js +5 -0
  6. package/cjs/boot/disabledRumPublicApi.js.map +1 -1
  7. package/cjs/boot/initCallbacks.js +25 -0
  8. package/cjs/boot/initCallbacks.js.map +1 -0
  9. package/cjs/boot/perStartRum.js +99 -50
  10. package/cjs/boot/perStartRum.js.map +1 -1
  11. package/cjs/boot/recorderApi.js +36 -1
  12. package/cjs/boot/recorderApi.js.map +1 -1
  13. package/cjs/boot/rum.js +8 -9
  14. package/cjs/boot/rum.js.map +1 -1
  15. package/cjs/boot/rumPublicApi.js +6 -7
  16. package/cjs/boot/rumPublicApi.js.map +1 -1
  17. package/cjs/boot/startRecording.js +2 -0
  18. package/cjs/boot/startRecording.js.map +1 -1
  19. package/cjs/domain/configuration.js +15 -2
  20. package/cjs/domain/configuration.js.map +1 -1
  21. package/cjs/domain/contexts/urlContexts.js +32 -21
  22. package/cjs/domain/contexts/urlContexts.js.map +1 -1
  23. package/cjs/domain/contexts/viewContexts.js +1 -1
  24. package/cjs/domain/contexts/viewContexts.js.map +1 -1
  25. package/cjs/domain/deflate/deflateWorker.js +39 -27
  26. package/cjs/domain/deflate/deflateWorker.js.map +1 -1
  27. package/cjs/domain/privacy.js +79 -107
  28. package/cjs/domain/privacy.js.map +1 -1
  29. package/cjs/domain/replay/record/canvasCommandCapture.js +87 -179
  30. package/cjs/domain/replay/record/canvasCommandCapture.js.map +1 -1
  31. package/cjs/domain/replay/record/canvasCommandObserver.js +10 -6
  32. package/cjs/domain/replay/record/canvasCommandObserver.js.map +1 -1
  33. package/cjs/domain/replay/record/canvasCommandObserverStub.js +24 -0
  34. package/cjs/domain/replay/record/canvasCommandObserverStub.js.map +1 -0
  35. package/cjs/domain/replay/record/canvasCommandSerializeArgs.js +3 -2
  36. package/cjs/domain/replay/record/canvasCommandSerializeArgs.js.map +1 -1
  37. package/cjs/domain/replay/record/canvasContext.js +15 -0
  38. package/cjs/domain/replay/record/canvasContext.js.map +1 -1
  39. package/cjs/domain/replay/record/canvasEncodeWorker.js +1 -1
  40. package/cjs/domain/replay/record/canvasObserver.js +3 -0
  41. package/cjs/domain/replay/record/canvasObserver.js.map +1 -1
  42. package/cjs/domain/replay/record/canvasWebGLPluginHost.js +5 -1
  43. package/cjs/domain/replay/record/canvasWebGLPluginHost.js.map +1 -1
  44. package/cjs/domain/replay/record/mutationObserver.js +3 -12
  45. package/cjs/domain/replay/record/mutationObserver.js.map +1 -1
  46. package/cjs/domain/replay/record/observers.js +3 -7
  47. package/cjs/domain/replay/record/observers.js.map +1 -1
  48. package/cjs/domain/replay/record/record.js +15 -2
  49. package/cjs/domain/replay/record/record.js.map +1 -1
  50. package/cjs/domain/replay/record/serializationUtils.js +8 -23
  51. package/cjs/domain/replay/record/serializationUtils.js.map +1 -1
  52. package/cjs/domain/replay/record/serialize.js +19 -33
  53. package/cjs/domain/replay/record/serialize.js.map +1 -1
  54. package/cjs/domain/replay/segmentCollection/buildReplayPayload.js +21 -6
  55. package/cjs/domain/replay/segmentCollection/buildReplayPayload.js.map +1 -1
  56. package/cjs/domain/replay/segmentCollection/segmentCollection.js +91 -143
  57. package/cjs/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
  58. package/cjs/domain/replayCanvasSupported.js +8 -0
  59. package/cjs/domain/replayCanvasSupported.js.map +1 -0
  60. package/cjs/domain/requestCollection.js +38 -39
  61. package/cjs/domain/requestCollection.js.map +1 -1
  62. package/cjs/domain/rumEventsCollection/actions/listenActionEvents.js +1 -1
  63. package/cjs/domain/rumEventsCollection/actions/listenActionEvents.js.map +1 -1
  64. package/cjs/domain/rumEventsCollection/resource/fetchTimingRegistry.js +143 -0
  65. package/cjs/domain/rumEventsCollection/resource/fetchTimingRegistry.js.map +1 -0
  66. package/cjs/domain/rumEventsCollection/resource/matchRequestResourceEntry.js +2 -2
  67. package/cjs/domain/rumEventsCollection/resource/matchRequestResourceEntry.js.map +1 -1
  68. package/cjs/domain/rumEventsCollection/resource/resourceCollection.js +91 -66
  69. package/cjs/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
  70. package/cjs/domain/rumEventsCollection/resource/resourceTrackerManager.js +11 -9
  71. package/cjs/domain/rumEventsCollection/resource/resourceTrackerManager.js.map +1 -1
  72. package/cjs/domain/rumEventsCollection/resource/resourceUtils.js +35 -50
  73. package/cjs/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
  74. package/cjs/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js +7 -1
  75. package/cjs/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js.map +1 -1
  76. package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +1 -1
  77. package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
  78. package/cjs/domain/rumEventsCollection/view/trackViews.js +3 -0
  79. package/cjs/domain/rumEventsCollection/view/trackViews.js.map +1 -1
  80. package/cjs/domain/rumEventsCollection/view/viewCollection.js +1 -1
  81. package/cjs/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
  82. package/cjs/domain/tracing/skywalkingTracer.js +4 -50
  83. package/cjs/domain/tracing/skywalkingTracer.js.map +1 -1
  84. package/cjs/domain/tracing/tracer.js +26 -3
  85. package/cjs/domain/tracing/tracer.js.map +1 -1
  86. package/esm/boot/buildEnv.js +1 -1
  87. package/esm/boot/disabledRumPublicApi.js +1 -1
  88. package/esm/boot/disabledRumPublicApi.js.map +1 -1
  89. package/esm/boot/initCallbacks.js +2 -0
  90. package/esm/boot/initCallbacks.js.map +1 -0
  91. package/esm/boot/perStartRum.js +1 -1
  92. package/esm/boot/perStartRum.js.map +1 -1
  93. package/esm/boot/recorderApi.js +1 -1
  94. package/esm/boot/recorderApi.js.map +1 -1
  95. package/esm/boot/rum.js +1 -1
  96. package/esm/boot/rum.js.map +1 -1
  97. package/esm/boot/rumPublicApi.js +1 -1
  98. package/esm/boot/rumPublicApi.js.map +1 -1
  99. package/esm/boot/startRecording.js +1 -1
  100. package/esm/boot/startRecording.js.map +1 -1
  101. package/esm/domain/configuration.js +1 -1
  102. package/esm/domain/configuration.js.map +1 -1
  103. package/esm/domain/contexts/urlContexts.js +1 -1
  104. package/esm/domain/contexts/urlContexts.js.map +1 -1
  105. package/esm/domain/contexts/viewContexts.js +1 -1
  106. package/esm/domain/contexts/viewContexts.js.map +1 -1
  107. package/esm/domain/deflate/deflateWorker.js +1 -1
  108. package/esm/domain/deflate/deflateWorker.js.map +1 -1
  109. package/esm/domain/privacy.js +1 -1
  110. package/esm/domain/privacy.js.map +1 -1
  111. package/esm/domain/replay/record/canvasCommandCapture.js +1 -1
  112. package/esm/domain/replay/record/canvasCommandCapture.js.map +1 -1
  113. package/esm/domain/replay/record/canvasCommandObserver.js +1 -1
  114. package/esm/domain/replay/record/canvasCommandObserver.js.map +1 -1
  115. package/esm/domain/replay/record/canvasCommandObserverStub.js +2 -0
  116. package/esm/domain/replay/record/canvasCommandObserverStub.js.map +1 -0
  117. package/esm/domain/replay/record/canvasCommandSerializeArgs.js +1 -1
  118. package/esm/domain/replay/record/canvasCommandSerializeArgs.js.map +1 -1
  119. package/esm/domain/replay/record/canvasContext.js +1 -1
  120. package/esm/domain/replay/record/canvasContext.js.map +1 -1
  121. package/esm/domain/replay/record/canvasEncodeWorker.js +1 -1
  122. package/esm/domain/replay/record/canvasObserver.js +1 -1
  123. package/esm/domain/replay/record/canvasObserver.js.map +1 -1
  124. package/esm/domain/replay/record/canvasWebGLPluginHost.js +1 -1
  125. package/esm/domain/replay/record/canvasWebGLPluginHost.js.map +1 -1
  126. package/esm/domain/replay/record/mutationObserver.js +1 -1
  127. package/esm/domain/replay/record/mutationObserver.js.map +1 -1
  128. package/esm/domain/replay/record/observers.js +1 -1
  129. package/esm/domain/replay/record/observers.js.map +1 -1
  130. package/esm/domain/replay/record/record.js +1 -1
  131. package/esm/domain/replay/record/record.js.map +1 -1
  132. package/esm/domain/replay/record/serializationUtils.js +1 -1
  133. package/esm/domain/replay/record/serializationUtils.js.map +1 -1
  134. package/esm/domain/replay/record/serialize.js +1 -1
  135. package/esm/domain/replay/record/serialize.js.map +1 -1
  136. package/esm/domain/replay/segmentCollection/buildReplayPayload.js +1 -1
  137. package/esm/domain/replay/segmentCollection/buildReplayPayload.js.map +1 -1
  138. package/esm/domain/replay/segmentCollection/segmentCollection.js +1 -1
  139. package/esm/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
  140. package/esm/domain/replayCanvasSupported.js +2 -0
  141. package/esm/domain/replayCanvasSupported.js.map +1 -0
  142. package/esm/domain/requestCollection.js +1 -1
  143. package/esm/domain/requestCollection.js.map +1 -1
  144. package/esm/domain/rumEventsCollection/actions/listenActionEvents.js +1 -1
  145. package/esm/domain/rumEventsCollection/actions/listenActionEvents.js.map +1 -1
  146. package/esm/domain/rumEventsCollection/resource/fetchTimingRegistry.js +2 -0
  147. package/esm/domain/rumEventsCollection/resource/fetchTimingRegistry.js.map +1 -0
  148. package/esm/domain/rumEventsCollection/resource/matchRequestResourceEntry.js +1 -1
  149. package/esm/domain/rumEventsCollection/resource/matchRequestResourceEntry.js.map +1 -1
  150. package/esm/domain/rumEventsCollection/resource/resourceCollection.js +1 -1
  151. package/esm/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
  152. package/esm/domain/rumEventsCollection/resource/resourceTrackerManager.js +1 -1
  153. package/esm/domain/rumEventsCollection/resource/resourceTrackerManager.js.map +1 -1
  154. package/esm/domain/rumEventsCollection/resource/resourceUtils.js +1 -1
  155. package/esm/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
  156. package/esm/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js +1 -1
  157. package/esm/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js.map +1 -1
  158. package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +1 -1
  159. package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
  160. package/esm/domain/rumEventsCollection/view/trackViews.js +1 -1
  161. package/esm/domain/rumEventsCollection/view/trackViews.js.map +1 -1
  162. package/esm/domain/rumEventsCollection/view/viewCollection.js +1 -1
  163. package/esm/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
  164. package/esm/domain/tracing/skywalkingTracer.js +1 -1
  165. package/esm/domain/tracing/skywalkingTracer.js.map +1 -1
  166. package/esm/domain/tracing/tracer.js +1 -1
  167. package/esm/domain/tracing/tracer.js.map +1 -1
  168. package/package.json +7 -7
  169. package/src/boot/disabledRumPublicApi.js +5 -0
  170. package/src/boot/initCallbacks.js +16 -0
  171. package/src/boot/perStartRum.js +102 -59
  172. package/src/boot/recorderApi.js +51 -2
  173. package/src/boot/rum.js +12 -18
  174. package/src/boot/rumPublicApi.js +6 -8
  175. package/src/boot/startRecording.js +2 -0
  176. package/src/domain/configuration.js +13 -2
  177. package/src/domain/contexts/urlContexts.js +34 -27
  178. package/src/domain/contexts/viewContexts.js +2 -2
  179. package/src/domain/deflate/deflateWorker.js +35 -21
  180. package/src/domain/privacy.js +93 -157
  181. package/src/domain/replay/record/canvasCommandCapture.js +102 -239
  182. package/src/domain/replay/record/canvasCommandObserver.js +11 -18
  183. package/src/domain/replay/record/canvasCommandObserverStub.js +11 -0
  184. package/src/domain/replay/record/canvasCommandSerializeArgs.js +2 -2
  185. package/src/domain/replay/record/canvasContext.js +18 -0
  186. package/src/domain/replay/record/canvasObserver.js +5 -1
  187. package/src/domain/replay/record/canvasWebGLPluginHost.js +4 -1
  188. package/src/domain/replay/record/mutationObserver.js +6 -22
  189. package/src/domain/replay/record/observers.js +4 -8
  190. package/src/domain/replay/record/record.js +20 -5
  191. package/src/domain/replay/record/serializationUtils.js +10 -33
  192. package/src/domain/replay/record/serialize.js +30 -38
  193. package/src/domain/replay/segmentCollection/buildReplayPayload.js +24 -14
  194. package/src/domain/replay/segmentCollection/segmentCollection.js +97 -227
  195. package/src/domain/replayCanvasSupported.js +1 -0
  196. package/src/domain/requestCollection.js +39 -51
  197. package/src/domain/rumEventsCollection/actions/listenActionEvents.js +8 -2
  198. package/src/domain/rumEventsCollection/resource/fetchTimingRegistry.js +138 -0
  199. package/src/domain/rumEventsCollection/resource/matchRequestResourceEntry.js +2 -2
  200. package/src/domain/rumEventsCollection/resource/resourceCollection.js +103 -88
  201. package/src/domain/rumEventsCollection/resource/resourceTrackerManager.js +10 -10
  202. package/src/domain/rumEventsCollection/resource/resourceUtils.js +41 -69
  203. package/src/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js +8 -2
  204. package/src/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +1 -1
  205. package/src/domain/rumEventsCollection/view/trackViews.js +3 -0
  206. package/src/domain/rumEventsCollection/view/viewCollection.js +2 -3
  207. package/src/domain/tracing/skywalkingTracer.js +14 -91
  208. package/src/domain/tracing/tracer.js +28 -4
  209. package/types/index.d.ts +9 -0
@@ -173,69 +173,51 @@ export function isCacheHit(entry) {
173
173
  }
174
174
 
175
175
  export function computePerformanceResourceDetails(entry) {
176
- if (!hasValidResourceEntryTimings(entry)) {
177
- return undefined
176
+ const {
177
+ startTime, fetchStart, domainLookupStart, domainLookupEnd,
178
+ connectStart, connectEnd, secureConnectionStart,
179
+ requestStart, responseStart, responseEnd, redirectStart, redirectEnd
180
+ } = entry
181
+ const details = {}
182
+ // The browser exposes each phase independently. A zero or unavailable
183
+ // timestamp must not erase valid measurements from a different phase.
184
+ if (validPhase(startTime, requestStart, responseStart)) {
185
+ details.firstByteTime = formatTiming(startTime, requestStart, responseStart)
186
+ details.firstbyte = details.firstByteTime.duration
187
+ if (responseStart <= preferredNow()) details.ttfb = details.firstbyte
178
188
  }
179
-
180
- var startTime = entry.startTime,
181
- fetchStart = entry.fetchStart,
182
- redirectStart = entry.redirectStart,
183
- redirectEnd = entry.redirectEnd,
184
- domainLookupStart = entry.domainLookupStart,
185
- domainLookupEnd = entry.domainLookupEnd,
186
- connectStart = entry.connectStart,
187
- secureConnectionStart = entry.secureConnectionStart,
188
- connectEnd = entry.connectEnd,
189
- requestStart = entry.requestStart,
190
- responseStart = entry.responseStart,
191
- responseEnd = entry.responseEnd
192
- var details = {
193
- firstbyte: msToNs(responseStart - requestStart),
194
- trans: msToNs(responseEnd - responseStart),
195
- downloadTime: formatTiming(startTime, responseStart, responseEnd),
196
- firstByteTime: formatTiming(startTime, requestStart, responseStart)
197
- }
198
- if (responseStart > 0 && responseStart <= preferredNow()) {
199
- details.ttfb = msToNs(responseStart - requestStart)
189
+ if (validPhase(startTime, responseStart, responseEnd)) {
190
+ details.downloadTime = formatTiming(startTime, responseStart, responseEnd)
191
+ details.trans = details.downloadTime.duration
200
192
  }
201
- // Make sure a connection occurred
202
- if (connectEnd !== fetchStart) {
203
- details.tcp = msToNs(connectEnd - connectStart)
193
+ if (connectEnd !== fetchStart && validPhase(startTime, connectStart, connectEnd)) {
204
194
  details.connectTime = formatTiming(startTime, connectStart, connectEnd)
205
- // Make sure a secure connection occurred
206
- if (areInOrder(connectStart, secureConnectionStart, connectEnd)) {
207
- details.ssl = msToNs(connectEnd - secureConnectionStart)
208
- details.sslTime = formatTiming(
209
- startTime,
210
- secureConnectionStart,
211
- connectEnd
212
- )
195
+ details.tcp = details.connectTime.duration
196
+ if (validPhase(connectStart, secureConnectionStart, connectEnd)) {
197
+ details.sslTime = formatTiming(startTime, secureConnectionStart, connectEnd)
198
+ details.ssl = details.sslTime.duration
213
199
  }
214
200
  }
215
-
216
- // Make sure a domain lookup occurred
217
- if (domainLookupEnd !== fetchStart) {
218
- details.dns = msToNs(domainLookupEnd - domainLookupStart)
219
- details.dnsTime = formatTiming(
220
- startTime,
221
- domainLookupStart,
222
- domainLookupEnd
223
- )
201
+ if (domainLookupEnd !== fetchStart && validPhase(startTime, domainLookupStart, domainLookupEnd)) {
202
+ details.dnsTime = formatTiming(startTime, domainLookupStart, domainLookupEnd)
203
+ details.dns = details.dnsTime.duration
224
204
  }
225
-
226
- if (hasRedirection(entry)) {
227
- details.redirect = msToNs(redirectEnd - redirectStart)
205
+ if (hasRedirection(entry) && startTime <= redirectStart && redirectStart <= redirectEnd) {
228
206
  details.redirectTime = formatTiming(startTime, redirectStart, redirectEnd)
207
+ details.redirect = details.redirectTime.duration
229
208
  }
230
- // renderBlockstatus
231
- if (entry.renderBlockingStatus) {
232
- details.renderBlockingStatus = entry.renderBlockingStatus
233
- }
209
+ if (entry.renderBlockingStatus) details.renderBlockingStatus = entry.renderBlockingStatus
234
210
  return details
235
211
  }
212
+
213
+ function validPhase(origin, start, end) {
214
+ return start > 0 && origin <= start && start <= end && end < Infinity
215
+ }
216
+
236
217
  export function hasValidResourceEntryDuration(entry) {
237
218
  return entry.duration >= 0
238
219
  }
220
+
239
221
  export function hasValidResourceEntryTimings(entry) {
240
222
  var areCommonTimingsInOrder = areInOrder(
241
223
  entry.startTime,
@@ -271,21 +253,16 @@ function formatTiming(origin, start, end) {
271
253
  }
272
254
 
273
255
  export function computeResourceEntrySize(entry) {
274
- // Make sure a request actually occurred
275
- if (entry.startTime < entry.responseStart) {
256
+ // A cached response may have identical timestamps. Positive byte counts
257
+ // are independently exposed even when detailed timings are restricted.
258
+ if ((entry.responseStart > 0 && entry.startTime <= entry.responseStart) ||
259
+ entry.transferSize > 0 || entry.encodedBodySize > 0 || entry.decodedBodySize > 0) {
276
260
  return {
277
261
  size: entry.decodedBodySize,
278
262
  encodedBodySize: entry.encodedBodySize,
279
263
  decodedBodySize: entry.decodedBodySize,
280
264
  transferSize: entry.transferSize
281
265
  }
282
- // return {
283
- // size: entry.decodedBodySize,
284
- // encodeSize:
285
- // Number.MAX_SAFE_INTEGER < entry.encodedBodySize
286
- // ? 0
287
- // : entry.encodedBodySize // max safe interger
288
- // }
289
266
  }
290
267
  return {
291
268
  size: undefined,
@@ -299,19 +276,14 @@ export function isAllowedRequestUrl(configuration, url) {
299
276
  return url && !isIntakeRequest(url, configuration)
300
277
  }
301
278
 
302
- var DATA_URL_REGEX = /data:(.+)?(;base64)?,/g
279
+ var MAX_DATA_URL_HEADER_LENGTH = 256
303
280
  export var MAX_ATTRIBUTE_VALUE_CHAR_LENGTH = 24_000
304
281
  export function isLongDataUrl(url) {
305
- if (url.length <= MAX_ATTRIBUTE_VALUE_CHAR_LENGTH) {
306
- return false
307
- } else if (url.substring(0, 5) === 'data:') {
308
- // Avoid String.match RangeError: Maximum call stack size exceeded
309
- url = url.substring(0, MAX_ATTRIBUTE_VALUE_CHAR_LENGTH)
310
- return true
311
- }
312
- return false
282
+ return typeof url === 'string' && url.length > MAX_ATTRIBUTE_VALUE_CHAR_LENGTH && /^[\x00-\x20]*data:/i.test(url)
313
283
  }
314
284
 
315
285
  export function sanitizeDataUrl(url) {
316
- return url.match(DATA_URL_REGEX)[0] + '[...]'
286
+ if (!isLongDataUrl(url)) return url
287
+ var header = /data:[^,]*,/i.exec(url.slice(0, MAX_DATA_URL_HEADER_LENGTH + 1))
288
+ return (header ? header[0] : 'data:') + '[...]'
317
289
  }
@@ -1,8 +1,8 @@
1
- import { runOnReadyState, assign } from '@cloudcare/browser-core'
1
+ import { runOnReadyState, assign, buildUrl } from '@cloudcare/browser-core'
2
2
  import { RumPerformanceEntryType } from '../../performanceObservable'
3
3
  import { FAKE_INITIAL_DOCUMENT } from './resourceUtils'
4
4
  import { getNavigationEntry } from '../../performanceUtils'
5
- export function retrieveInitialDocumentResourceTiming(configuration, callback) {
5
+ export function retrieveInitialDocumentResourceTiming(configuration, callback, excludeDocumentQuery) {
6
6
  runOnReadyState('interactive', function () {
7
7
  var entry = assign(getNavigationEntry().toJSON(), {
8
8
  entryType: RumPerformanceEntryType.RESOURCE,
@@ -11,6 +11,12 @@ export function retrieveInitialDocumentResourceTiming(configuration, callback) {
11
11
  return assign({}, entry, { toJSON: undefined })
12
12
  }
13
13
  })
14
+ if (excludeDocumentQuery) {
15
+ var url = buildUrl(entry.name)
16
+ url.search = ''
17
+ url.hash = ''
18
+ entry.name = url.href
19
+ }
14
20
  callback(entry)
15
21
  })
16
22
  }
@@ -106,7 +106,7 @@ function slidingSessionWindow() {
106
106
  var shouldCreateNewWindow =
107
107
  startTime === undefined ||
108
108
  entry.startTime - endTime >= MAX_UPDATE_GAP ||
109
- entry.startTime - startTime >= 5 * MAX_WINDOW_DURATION
109
+ entry.startTime - startTime >= MAX_WINDOW_DURATION
110
110
  var isMaxValue
111
111
 
112
112
  if (shouldCreateNewWindow) {
@@ -124,6 +124,7 @@ export function trackViews(
124
124
  name: currentView.name,
125
125
  service: currentView.service,
126
126
  version: currentView.version,
127
+ excludeHashRouteOuterQuery: currentView.excludeHashRouteOuterQuery,
127
128
  context: currentView.contextManager.getContext()
128
129
  })
129
130
  }
@@ -270,6 +271,7 @@ function newView(
270
271
  startClocks: startClocks,
271
272
  service: service,
272
273
  version: version,
274
+ excludeHashRouteOuterQuery: viewOptions && viewOptions.excludeHashRouteOuterQuery,
273
275
  url: viewOptions && viewOptions.url
274
276
  }
275
277
  lifeCycle.notify(LifeCycleEventType.BEFORE_VIEW_CREATED, viewCreatedEvent)
@@ -484,6 +486,7 @@ function newView(
484
486
  service: service,
485
487
  version: version,
486
488
  contextManager: contextManager,
489
+ excludeHashRouteOuterQuery: viewCreatedEvent.excludeHashRouteOuterQuery,
487
490
  startClocks: startClocks,
488
491
  stopObservable: stopObservable,
489
492
  end: function (options) {
@@ -134,9 +134,8 @@ function processViewUpdate(view, configuration, recorderApi, pageStateHistory) {
134
134
  view.commonViewMetrics,
135
135
  'cumulativeLayoutShift.value'
136
136
  ),
137
- cumulative_layout_shift_time: findByPath(
138
- view.commonViewMetrics,
139
- 'cumulativeLayoutShift.time'
137
+ cumulative_layout_shift_time: toServerDuration(
138
+ findByPath(view.commonViewMetrics, 'cumulativeLayoutShift.time')
140
139
  ),
141
140
  cumulative_layout_shift_target_selector: findByPath(
142
141
  view.commonViewMetrics,
@@ -1,72 +1,12 @@
1
- import { base64Encode, urlParse, getType } from '@cloudcare/browser-core'
2
- // start SkyWalking
3
- function uuid() {
4
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
5
- /* tslint:disable */
6
- var r = (Math.random() * 16) | 0
7
- /* tslint:disable */
8
- var v = c === 'x' ? r : (r & 0x3) | 0x8
1
+ import { base64Encode, getUrlParts, getType, UUID } from '@cloudcare/browser-core'
9
2
 
10
- return v.toString(16)
11
- })
12
- }
13
- /**
14
- *
15
- * @param {*} traceId
16
- * @param {*} traceSegmentId
17
- * @param {*} applicationId
18
- * @param {*} version
19
- * @param {*} requestUrlHost
20
- */
21
- function getSkyWalkingSw8(
22
- traceId,
23
- traceSegmentId,
24
- applicationId,
25
- env,
26
- version,
27
- requestUrlHost
28
- ) {
29
- try {
30
- var traceIdStr = String(base64Encode(traceId))
31
- var segmentId = String(base64Encode(traceSegmentId))
32
- var service = String(base64Encode(applicationId + '_rum_' + env))
33
- var instance = String(base64Encode(version))
34
- var endpoint = String(base64Encode(window.location.href))
35
- var peer = String(base64Encode(requestUrlHost))
36
- var index = '0'
37
- // var values = `${1}-${traceIdStr}-${segmentId}-${index}-${service}-${instance}-${endpoint}-${peer}`;
38
- return (
39
- '1-' +
40
- traceIdStr +
41
- '-' +
42
- segmentId +
43
- '-' +
44
- index +
45
- '-' +
46
- service +
47
- '-' +
48
- instance +
49
- '-' +
50
- endpoint +
51
- '-' +
52
- peer
53
- )
54
- } catch (err) {
55
- return ''
56
- }
57
- }
58
- /**
59
- *
60
- * @param {*} configuration
61
- * @param {*} requestUrl
62
- */
63
3
  export function SkyWalkingTracer(configuration, requestUrl, traceSampled) {
64
- this._spanId = uuid()
65
- this._traceId = uuid()
4
+ this._spanId = UUID()
5
+ this._traceId = UUID()
66
6
  this._applicationId = configuration.applicationId
67
7
  this._env = configuration.env
68
8
  this._version = configuration.version
69
- this._urlParse = urlParse(requestUrl).getParse()
9
+ this._urlParse = getUrlParts(requestUrl)
70
10
  this._traceSampled = traceSampled
71
11
  if (
72
12
  configuration.generateTraceId &&
@@ -94,33 +34,16 @@ SkyWalkingTracer.prototype = {
94
34
  },
95
35
  getSkyWalkingSw8: function () {
96
36
  try {
97
- var traceIdStr = String(base64Encode(this.getTraceId()))
98
- var segmentId = String(base64Encode(this.getSpanId()))
99
- var service = String(
100
- base64Encode(this._applicationId + '_rum_' + this._env)
101
- )
102
- var instance = String(base64Encode(this._version))
103
- var endpoint = String(base64Encode(window.location.href))
104
- var peer = String(base64Encode(this._urlParse.Host))
105
- var index = '0'
106
- // var values = `${1}-${traceIdStr}-${segmentId}-${index}-${service}-${instance}-${endpoint}-${peer}`;
107
- return (
108
- (this._traceSampled ? '1' : '0') +
109
- '-' +
110
- traceIdStr +
111
- '-' +
112
- segmentId +
113
- '-' +
114
- index +
115
- '-' +
116
- service +
117
- '-' +
118
- instance +
119
- '-' +
120
- endpoint +
121
- '-' +
122
- peer
123
- )
37
+ return [
38
+ this._traceSampled ? '1' : '0',
39
+ base64Encode(this.getTraceId()),
40
+ base64Encode(this.getSpanId()),
41
+ '0',
42
+ base64Encode(this._applicationId + '_rum_' + this._env),
43
+ base64Encode(this._version),
44
+ base64Encode(window.location.pathname),
45
+ base64Encode(this._urlParse.Host)
46
+ ].join('-')
124
47
  } catch (err) {
125
48
  return ''
126
49
  }
@@ -7,6 +7,7 @@ import {
7
7
  performDraw,
8
8
  isNumber,
9
9
  getType,
10
+ buildUrl,
10
11
  find,
11
12
  isMatchOption,
12
13
  matchList,
@@ -37,7 +38,27 @@ export function clearTracingIfNeeded(context) {
37
38
  }
38
39
  }
39
40
 
41
+ function buildTracingOptions(options) {
42
+ return (options || []).reduce(function (result, option) {
43
+ if (typeof option.match !== 'string') {
44
+ result.push(option)
45
+ } else {
46
+ try {
47
+ // The serialized authority ends with a slash even for bare origins.
48
+ var url = buildUrl(option.match)
49
+ if (/^https?:$/.test(url.protocol) && !url.username && !url.password) {
50
+ result.push({ match: url.href, traceType: option.traceType })
51
+ }
52
+ } catch (_) {
53
+ // An invalid URL grants no tracing access.
54
+ }
55
+ }
56
+ return result
57
+ }, [])
58
+ }
59
+
40
60
  export function startTracer(configuration, sessionManager) {
61
+ var tracingOptions = buildTracingOptions(configuration.allowedTracingUrls)
41
62
  return {
42
63
  clearTracingIfNeeded: clearTracingIfNeeded,
43
64
  traceFetch: function (context) {
@@ -80,7 +101,8 @@ export function startTracer(configuration, sessionManager) {
80
101
  )
81
102
  context.init.headers = headersMap
82
103
  }
83
- }
104
+ },
105
+ tracingOptions
84
106
  )
85
107
  },
86
108
  traceXhr: function (context, xhr) {
@@ -92,7 +114,8 @@ export function startTracer(configuration, sessionManager) {
92
114
  each(tracingHeaders, function (value, name) {
93
115
  xhr.setRequestHeader(name, value)
94
116
  })
95
- }
117
+ },
118
+ tracingOptions
96
119
  )
97
120
  }
98
121
  }
@@ -102,14 +125,15 @@ export function injectHeadersIfTracingAllowed(
102
125
  configuration,
103
126
  context,
104
127
  sessionManager,
105
- inject
128
+ inject,
129
+ tracingOptions = buildTracingOptions(configuration.allowedTracingUrls)
106
130
  ) {
107
131
  const session = sessionManager.findTrackedSession()
108
132
  if (!session && !configuration.allowTraceHeaderWithoutSession) {
109
133
  return
110
134
  }
111
135
  var tracingOption = find(
112
- configuration.allowedTracingUrls,
136
+ tracingOptions,
113
137
  function (tracingOption) {
114
138
  return matchList([tracingOption.match], context.url, true)
115
139
  }
package/types/index.d.ts CHANGED
@@ -10,7 +10,11 @@ export type {
10
10
  Context,
11
11
  User,
12
12
  RumEvent,
13
+ RumFetchResourceEvent,
13
14
  RumSyntheticsContext,
15
+ RumInitResult,
16
+ RumInitError,
17
+ RumRemoteConfigurationError,
14
18
  RumInitConfiguration,
15
19
  RumLegacyInitConfiguration,
16
20
  RumSiteInitConfiguration,
@@ -187,6 +191,8 @@ export interface ResourceTrackerSnapshot {
187
191
  }
188
192
 
189
193
  export interface ViewOptions {
194
+ /** @internal The Angular router plugin excludes the document query from hash routes. */
195
+ excludeHashRouteOuterQuery?: boolean
190
196
  name?: string | undefined
191
197
  service?: string | undefined
192
198
  version?: string | undefined
@@ -215,6 +221,8 @@ export interface RumPluginContext {
215
221
  addError: (error: RumPluginError) => void
216
222
  publicApi: RumPluginApi
217
223
  rum: RumPluginApi
224
+ /** Register during onInit to run after configuration validation and before the initial View. */
225
+ onConfigurationReady?: (callback: () => void) => void
218
226
  initConfiguration: RumPluginInitConfiguration
219
227
  }
220
228
 
@@ -273,6 +281,7 @@ export declare const datafluxRum: {
273
281
  getInternalContext: (
274
282
  startTime?: number | undefined
275
283
  ) => InternalContext | undefined
284
+ /** Returns a clone of the accepted configuration, including resolved overrides. Available before the first manual view; does not prove initialization succeeded. */
276
285
  getInitConfiguration: () =>
277
286
  | RumPluginInitConfiguration
278
287
  | undefined