@cloudcare/browser-rum 3.2.12 → 3.2.14
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.
- package/bundle/dataflux-rum.js +1 -1
- package/cjs/boot/buildEnv.js +1 -1
- package/cjs/domain/deflate/deflateWorker.js +1 -1
- package/cjs/domain/replay/segmentCollection/segmentCollection.js +1 -1
- package/cjs/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/getSelectorsFromElement.js +61 -14
- package/cjs/domain/rumEventsCollection/actions/getSelectorsFromElement.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/matchRequestResourceEntry.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/resourceUtils.js +1 -33
- package/cjs/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
- package/esm/boot/buildEnv.js +1 -1
- package/esm/domain/deflate/deflateWorker.js +1 -1
- package/esm/domain/replay/segmentCollection/segmentCollection.js +1 -1
- package/esm/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/getSelectorsFromElement.js +61 -14
- package/esm/domain/rumEventsCollection/actions/getSelectorsFromElement.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/matchRequestResourceEntry.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceUtils.js +1 -33
- package/esm/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
- package/package.json +4 -4
- package/src/domain/replay/segmentCollection/segmentCollection.js +1 -1
- package/src/domain/rumEventsCollection/actions/getSelectorsFromElement.js +75 -22
- package/src/domain/rumEventsCollection/resource/matchRequestResourceEntry.js +0 -1
- package/src/domain/rumEventsCollection/resource/resourceUtils.js +1 -32
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcare/browser-rum",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.14",
|
|
4
4
|
"main": "cjs/index.js",
|
|
5
5
|
"module": "esm/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@cloudcare/browser-core": "3.2.
|
|
9
|
-
"@cloudcare/browser-worker": "3.2.
|
|
8
|
+
"@cloudcare/browser-core": "3.2.13",
|
|
9
|
+
"@cloudcare/browser-worker": "3.2.13"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
12
|
"dev": "webpack serve --open --mode=development",
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"homepage": "https://github.com/CloudCare/dataflux-rum-sdk-javascript/blob/master/packages/rum/README.md",
|
|
35
35
|
"description": "DataFlux RUM Web 端数据指标监控",
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "f47cf2e5f94f461005e4f840b4fa59713ff7c516"
|
|
37
37
|
}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
import { buildReplayPayload } from './buildReplayPayload'
|
|
9
9
|
import { createSegment } from './segment'
|
|
10
10
|
|
|
11
|
-
export var SEGMENT_DURATION_LIMIT =
|
|
11
|
+
export var SEGMENT_DURATION_LIMIT = 5 * ONE_SECOND
|
|
12
12
|
/**
|
|
13
13
|
* beacon payload max queue size implementation is 64kb
|
|
14
14
|
* ensure that we leave room for logs, rum and potential other users
|
|
@@ -43,12 +43,11 @@ export function getSelectorFromElement(targetElement, actionNameAttribute) {
|
|
|
43
43
|
// parents, and we cannot determine if it's unique in the document.
|
|
44
44
|
return
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
element,
|
|
46
|
+
let targetElementSelector
|
|
47
|
+
let currentElement = targetElement
|
|
48
|
+
while (currentElement && currentElement.nodeName !== 'HTML') {
|
|
49
|
+
const globallyUniqueSelector = findSelector(
|
|
50
|
+
currentElement,
|
|
52
51
|
GLOBALLY_UNIQUE_SELECTOR_GETTERS,
|
|
53
52
|
isSelectorUniqueGlobally,
|
|
54
53
|
actionNameAttribute,
|
|
@@ -57,9 +56,8 @@ export function getSelectorFromElement(targetElement, actionNameAttribute) {
|
|
|
57
56
|
if (globallyUniqueSelector) {
|
|
58
57
|
return globallyUniqueSelector
|
|
59
58
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
element,
|
|
59
|
+
const uniqueSelectorAmongChildren = findSelector(
|
|
60
|
+
currentElement,
|
|
63
61
|
UNIQUE_AMONG_CHILDREN_SELECTOR_GETTERS,
|
|
64
62
|
isSelectorUniqueAmongSiblings,
|
|
65
63
|
actionNameAttribute,
|
|
@@ -67,10 +65,38 @@ export function getSelectorFromElement(targetElement, actionNameAttribute) {
|
|
|
67
65
|
)
|
|
68
66
|
targetElementSelector =
|
|
69
67
|
uniqueSelectorAmongChildren ||
|
|
70
|
-
combineSelector(
|
|
68
|
+
combineSelector(
|
|
69
|
+
getPositionSelector(currentElement),
|
|
70
|
+
targetElementSelector
|
|
71
|
+
)
|
|
71
72
|
|
|
72
|
-
|
|
73
|
+
currentElement = currentElement.parentElement
|
|
73
74
|
}
|
|
75
|
+
// while (element && element.nodeName !== 'HTML') {
|
|
76
|
+
// var globallyUniqueSelector = findSelector(
|
|
77
|
+
// element,
|
|
78
|
+
// GLOBALLY_UNIQUE_SELECTOR_GETTERS,
|
|
79
|
+
// isSelectorUniqueGlobally,
|
|
80
|
+
// actionNameAttribute,
|
|
81
|
+
// targetElementSelector
|
|
82
|
+
// )
|
|
83
|
+
// if (globallyUniqueSelector) {
|
|
84
|
+
// return globallyUniqueSelector
|
|
85
|
+
// }
|
|
86
|
+
|
|
87
|
+
// var uniqueSelectorAmongChildren = findSelector(
|
|
88
|
+
// element,
|
|
89
|
+
// UNIQUE_AMONG_CHILDREN_SELECTOR_GETTERS,
|
|
90
|
+
// isSelectorUniqueAmongSiblings,
|
|
91
|
+
// actionNameAttribute,
|
|
92
|
+
// targetElementSelector
|
|
93
|
+
// )
|
|
94
|
+
// targetElementSelector =
|
|
95
|
+
// uniqueSelectorAmongChildren ||
|
|
96
|
+
// combineSelector(getPositionSelector(element), targetElementSelector)
|
|
97
|
+
|
|
98
|
+
// element = element.parentElement
|
|
99
|
+
// }
|
|
74
100
|
|
|
75
101
|
return targetElementSelector
|
|
76
102
|
}
|
|
@@ -170,15 +196,18 @@ function findSelector(
|
|
|
170
196
|
if (!elementSelector) {
|
|
171
197
|
continue
|
|
172
198
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
return fullSelector
|
|
199
|
+
if (predicate(element, elementSelector, childSelector)) {
|
|
200
|
+
return combineSelector(elementSelector, childSelector)
|
|
176
201
|
}
|
|
177
202
|
}
|
|
178
203
|
}
|
|
179
204
|
|
|
180
|
-
function isSelectorUniqueGlobally(element,
|
|
181
|
-
return
|
|
205
|
+
function isSelectorUniqueGlobally(element, elementSelector, childSelector) {
|
|
206
|
+
return (
|
|
207
|
+
element.ownerDocument.querySelectorAll(
|
|
208
|
+
combineSelector(elementSelector, childSelector)
|
|
209
|
+
).length === 1
|
|
210
|
+
)
|
|
182
211
|
}
|
|
183
212
|
/**
|
|
184
213
|
* Check whether the selector is unique among the element siblings. In other words, it returns true
|
|
@@ -190,12 +219,36 @@ function isSelectorUniqueGlobally(element, selector) {
|
|
|
190
219
|
* direct descendent of the element parent. This should not impact results too much: if it
|
|
191
220
|
* inaccurately returns false, we'll just fall back to another strategy.
|
|
192
221
|
*/
|
|
193
|
-
function isSelectorUniqueAmongSiblings(
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
222
|
+
function isSelectorUniqueAmongSiblings(
|
|
223
|
+
currentElement,
|
|
224
|
+
currentElementSelector,
|
|
225
|
+
childSelector
|
|
226
|
+
) {
|
|
227
|
+
let isSiblingMatching
|
|
228
|
+
|
|
229
|
+
if (childSelector === undefined) {
|
|
230
|
+
// If the child selector is undefined (meaning `currentElement` is the target element, not one
|
|
231
|
+
// of its ancestor), we need to use `matches` to check if the sibling is matching the selector,
|
|
232
|
+
// as `querySelector` only returns a descendant of the element.
|
|
233
|
+
isSiblingMatching = (sibling) => sibling.matches(currentElementSelector)
|
|
234
|
+
} else {
|
|
235
|
+
const scopedSelector = supportScopeSelector()
|
|
236
|
+
? combineSelector(`${currentElementSelector}:scope`, childSelector)
|
|
237
|
+
: combineSelector(currentElementSelector, childSelector)
|
|
238
|
+
isSiblingMatching = (sibling) =>
|
|
239
|
+
sibling.querySelector(scopedSelector) !== null
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const parent = currentElement.parentElement
|
|
243
|
+
let sibling = parent.firstElementChild
|
|
244
|
+
while (sibling) {
|
|
245
|
+
if (sibling !== currentElement && isSiblingMatching(sibling)) {
|
|
246
|
+
return false
|
|
247
|
+
}
|
|
248
|
+
sibling = sibling.nextElementSibling
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return true
|
|
199
252
|
}
|
|
200
253
|
function combineSelector(parent, child) {
|
|
201
254
|
return child ? parent + '>' + child : parent
|
|
@@ -30,7 +30,6 @@ export function matchRequestResourceEntry(request) {
|
|
|
30
30
|
var candidates = filter(sameNameEntries, function (entry) {
|
|
31
31
|
return !alreadyMatchedEntries.has(entry)
|
|
32
32
|
})
|
|
33
|
-
|
|
34
33
|
candidates = filter(candidates, function (entry) {
|
|
35
34
|
return (
|
|
36
35
|
hasValidResourceEntryDuration(entry) &&
|
|
@@ -337,41 +337,10 @@ export function hasValidResourceEntryTimings(entry) {
|
|
|
337
337
|
)
|
|
338
338
|
: true
|
|
339
339
|
return areCommonTimingsInOrder && areRedirectionTimingsInOrder
|
|
340
|
-
// if (!hasRedirection(entry)) {
|
|
341
|
-
// return entry
|
|
342
|
-
// }
|
|
343
|
-
|
|
344
|
-
// var redirectStart = entry.redirectStart
|
|
345
|
-
// var redirectEnd = entry.redirectEnd
|
|
346
|
-
// // Firefox doesn't provide redirect timings on cross origin requests.
|
|
347
|
-
// // Provide a default for those.
|
|
348
|
-
// if (redirectStart < entry.startTime) {
|
|
349
|
-
// redirectStart = entry.startTime
|
|
350
|
-
// }
|
|
351
|
-
// if (redirectEnd < entry.startTime) {
|
|
352
|
-
// redirectEnd = entry.fetchStart
|
|
353
|
-
// }
|
|
354
|
-
|
|
355
|
-
// // Make sure redirect timings are in order
|
|
356
|
-
// if (
|
|
357
|
-
// !areInOrder(entry.startTime, redirectStart, redirectEnd, entry.fetchStart)
|
|
358
|
-
// ) {
|
|
359
|
-
// return undefined
|
|
360
|
-
// }
|
|
361
|
-
// return extend({}, entry, {
|
|
362
|
-
// redirectEnd: redirectEnd,
|
|
363
|
-
// redirectStart: redirectStart
|
|
364
|
-
// })
|
|
365
|
-
// return {
|
|
366
|
-
// ...entry,
|
|
367
|
-
// redirectEnd,
|
|
368
|
-
// redirectStart
|
|
369
|
-
// }
|
|
370
340
|
}
|
|
371
341
|
|
|
372
342
|
function hasRedirection(entry) {
|
|
373
|
-
|
|
374
|
-
return entry.fetchStart !== entry.startTime
|
|
343
|
+
return entry.redirectEnd > entry.startTime
|
|
375
344
|
}
|
|
376
345
|
|
|
377
346
|
function formatTiming(origin, start, end) {
|