@cloudcare/browser-rum 3.1.13 → 3.1.15
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/configuration.js +1 -0
- package/cjs/domain/configuration.js.map +1 -1
- package/cjs/domain/contexts/pageStateHistory.js +14 -9
- package/cjs/domain/contexts/pageStateHistory.js.map +1 -1
- package/cjs/domain/contexts/urlContexts.js +6 -3
- package/cjs/domain/contexts/urlContexts.js.map +1 -1
- package/cjs/domain/replay/deflate/deflateWorker.js +1 -1
- package/cjs/domain/rumEventsCollection/actions/actionCollection.js +3 -2
- package/cjs/domain/rumEventsCollection/actions/actionCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/getSelectorsFromElement.js +17 -0
- package/cjs/domain/rumEventsCollection/actions/getSelectorsFromElement.js.map +1 -1
- package/cjs/domain/rumEventsCollection/error/errorCollection.js +2 -1
- package/cjs/domain/rumEventsCollection/error/errorCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/matchRequestTiming.js +8 -4
- package/cjs/domain/rumEventsCollection/resource/matchRequestTiming.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/resourceUtils.js +42 -40
- package/cjs/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +40 -17
- package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackInteractionToNextPaint.js +18 -19
- package/cjs/domain/rumEventsCollection/view/trackInteractionToNextPaint.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/viewCollection.js +1 -4
- package/cjs/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
- package/cjs/domain/tracing/tracer.js +16 -1
- package/cjs/domain/tracing/tracer.js.map +1 -1
- package/esm/boot/buildEnv.js +1 -1
- package/esm/domain/configuration.js +2 -1
- package/esm/domain/configuration.js.map +1 -1
- package/esm/domain/contexts/pageStateHistory.js +14 -9
- package/esm/domain/contexts/pageStateHistory.js.map +1 -1
- package/esm/domain/contexts/urlContexts.js +6 -3
- package/esm/domain/contexts/urlContexts.js.map +1 -1
- package/esm/domain/replay/deflate/deflateWorker.js +1 -1
- package/esm/domain/rumEventsCollection/actions/actionCollection.js +4 -3
- package/esm/domain/rumEventsCollection/actions/actionCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/getSelectorsFromElement.js +17 -0
- package/esm/domain/rumEventsCollection/actions/getSelectorsFromElement.js.map +1 -1
- package/esm/domain/rumEventsCollection/error/errorCollection.js +2 -1
- package/esm/domain/rumEventsCollection/error/errorCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/matchRequestTiming.js +10 -7
- package/esm/domain/rumEventsCollection/resource/matchRequestTiming.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceUtils.js +41 -39
- package/esm/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +40 -17
- package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackInteractionToNextPaint.js +18 -19
- package/esm/domain/rumEventsCollection/view/trackInteractionToNextPaint.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/viewCollection.js +1 -4
- package/esm/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
- package/esm/domain/tracing/tracer.js +16 -1
- package/esm/domain/tracing/tracer.js.map +1 -1
- package/package.json +4 -4
- package/src/domain/configuration.js +7 -1
- package/src/domain/contexts/pageStateHistory.js +22 -12
- package/src/domain/contexts/urlContexts.js +13 -7
- package/src/domain/rumEventsCollection/actions/actionCollection.js +8 -3
- package/src/domain/rumEventsCollection/actions/getSelectorsFromElement.js +18 -0
- package/src/domain/rumEventsCollection/error/errorCollection.js +3 -1
- package/src/domain/rumEventsCollection/resource/matchRequestTiming.js +10 -6
- package/src/domain/rumEventsCollection/resource/resourceUtils.js +59 -57
- package/src/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +37 -22
- package/src/domain/rumEventsCollection/view/trackInteractionToNextPaint.js +18 -18
- package/src/domain/rumEventsCollection/view/viewCollection.js +2 -5
- package/src/domain/tracing/tracer.js +17 -1
- package/types/index.d.ts +8 -3
|
@@ -221,24 +221,22 @@ export function isCacheHit(entry) {
|
|
|
221
221
|
|
|
222
222
|
// · loadEventEnd:返回当前网页load事件的回调函数运行结束时的Unix毫秒时间戳。如果该事件还没有发生,返回0
|
|
223
223
|
export function computePerformanceResourceDetails(entry) {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
if (!validEntry) {
|
|
224
|
+
if (!isValidEntry(entry)) {
|
|
227
225
|
return undefined
|
|
228
226
|
}
|
|
229
227
|
|
|
230
|
-
var startTime =
|
|
231
|
-
fetchStart =
|
|
232
|
-
redirectStart =
|
|
233
|
-
redirectEnd =
|
|
234
|
-
domainLookupStart =
|
|
235
|
-
domainLookupEnd =
|
|
236
|
-
connectStart =
|
|
237
|
-
secureConnectionStart =
|
|
238
|
-
connectEnd =
|
|
239
|
-
requestStart =
|
|
240
|
-
responseStart =
|
|
241
|
-
responseEnd =
|
|
228
|
+
var startTime = entry.startTime,
|
|
229
|
+
fetchStart = entry.fetchStart,
|
|
230
|
+
redirectStart = entry.redirectStart,
|
|
231
|
+
redirectEnd = entry.redirectEnd,
|
|
232
|
+
domainLookupStart = entry.domainLookupStart,
|
|
233
|
+
domainLookupEnd = entry.domainLookupEnd,
|
|
234
|
+
connectStart = entry.connectStart,
|
|
235
|
+
secureConnectionStart = entry.secureConnectionStart,
|
|
236
|
+
connectEnd = entry.connectEnd,
|
|
237
|
+
requestStart = entry.requestStart,
|
|
238
|
+
responseStart = entry.responseStart,
|
|
239
|
+
responseEnd = entry.responseEnd
|
|
242
240
|
var details = {
|
|
243
241
|
firstbyte: msToNs(responseStart - domainLookupStart),
|
|
244
242
|
trans: msToNs(responseEnd - responseStart),
|
|
@@ -284,7 +282,7 @@ export function computePerformanceResourceDetails(entry) {
|
|
|
284
282
|
return details
|
|
285
283
|
}
|
|
286
284
|
|
|
287
|
-
export function
|
|
285
|
+
export function isValidEntry(entry) {
|
|
288
286
|
// Ensure timings are in the right order. On top of filtering out potential invalid
|
|
289
287
|
// RumPerformanceResourceTiming, it will ignore entries from requests where timings cannot be
|
|
290
288
|
// collected, for example cross origin requests without a "Timing-Allow-Origin" header allowing
|
|
@@ -302,47 +300,51 @@ export function toValidEntry(entry) {
|
|
|
302
300
|
// page_trans float 内容传输时间 responseEnd - responseStart
|
|
303
301
|
// page_dom float DOM解析耗时 domInteractive - responseEnd
|
|
304
302
|
// page_resource_load_time float 资源加载时间 loadEventStart - domContentLoadedEventEnd
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
//
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
//
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
}
|
|
303
|
+
var areCommonTimingsInOrder = areInOrder(
|
|
304
|
+
entry.startTime,
|
|
305
|
+
entry.fetchStart,
|
|
306
|
+
entry.domainLookupStart,
|
|
307
|
+
entry.domainLookupEnd,
|
|
308
|
+
entry.connectStart,
|
|
309
|
+
entry.connectEnd,
|
|
310
|
+
entry.requestStart,
|
|
311
|
+
entry.responseStart,
|
|
312
|
+
entry.responseEnd
|
|
313
|
+
)
|
|
314
|
+
var areRedirectionTimingsInOrder = hasRedirection(entry)
|
|
315
|
+
? areInOrder(
|
|
316
|
+
entry.startTime,
|
|
317
|
+
entry.redirectStart,
|
|
318
|
+
entry.redirectEnd,
|
|
319
|
+
entry.fetchStart
|
|
320
|
+
)
|
|
321
|
+
: true
|
|
322
|
+
return areCommonTimingsInOrder && areRedirectionTimingsInOrder
|
|
323
|
+
// if (!hasRedirection(entry)) {
|
|
324
|
+
// return entry
|
|
325
|
+
// }
|
|
326
|
+
|
|
327
|
+
// var redirectStart = entry.redirectStart
|
|
328
|
+
// var redirectEnd = entry.redirectEnd
|
|
329
|
+
// // Firefox doesn't provide redirect timings on cross origin requests.
|
|
330
|
+
// // Provide a default for those.
|
|
331
|
+
// if (redirectStart < entry.startTime) {
|
|
332
|
+
// redirectStart = entry.startTime
|
|
333
|
+
// }
|
|
334
|
+
// if (redirectEnd < entry.startTime) {
|
|
335
|
+
// redirectEnd = entry.fetchStart
|
|
336
|
+
// }
|
|
337
|
+
|
|
338
|
+
// // Make sure redirect timings are in order
|
|
339
|
+
// if (
|
|
340
|
+
// !areInOrder(entry.startTime, redirectStart, redirectEnd, entry.fetchStart)
|
|
341
|
+
// ) {
|
|
342
|
+
// return undefined
|
|
343
|
+
// }
|
|
344
|
+
// return extend({}, entry, {
|
|
345
|
+
// redirectEnd: redirectEnd,
|
|
346
|
+
// redirectStart: redirectStart
|
|
347
|
+
// })
|
|
346
348
|
// return {
|
|
347
349
|
// ...entry,
|
|
348
350
|
// redirectEnd,
|
|
@@ -32,48 +32,63 @@ export function trackCumulativeLayoutShift(lifeCycle, configuration, callback) {
|
|
|
32
32
|
stop: noop
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
+
|
|
35
36
|
var maxClsValue = 0
|
|
37
|
+
// WeakRef is not supported in IE11 and Safari mobile, but so is the layout shift API, so this code won't be executed in these browsers
|
|
38
|
+
var maxClsTarget
|
|
39
|
+
|
|
40
|
+
// if no layout shift happen the value should be reported as 0
|
|
36
41
|
callback({
|
|
37
42
|
value: 0
|
|
38
43
|
})
|
|
44
|
+
|
|
39
45
|
var window = slidingSessionWindow()
|
|
40
46
|
var _subscribe = lifeCycle.subscribe(
|
|
41
47
|
LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED,
|
|
42
|
-
|
|
43
|
-
for (var
|
|
44
|
-
var entry = entries[i]
|
|
48
|
+
(entries) => {
|
|
49
|
+
for (var entry of entries) {
|
|
45
50
|
if (entry.entryType === 'layout-shift' && !entry.hadRecentInput) {
|
|
46
|
-
window.update(entry)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
var
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
clsTarget,
|
|
59
|
-
configuration.actionNameAttribute
|
|
60
|
-
)
|
|
61
|
-
}
|
|
51
|
+
var _update = window.update(entry)
|
|
52
|
+
var cumulatedValue = _update.cumulatedValue
|
|
53
|
+
var isMaxValue = _update.isMaxValue
|
|
54
|
+
if (isMaxValue) {
|
|
55
|
+
var target = getTargetFromSource(entry.sources)
|
|
56
|
+
maxClsTarget = target ? new WeakRef(target) : undefined
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (cumulatedValue > maxClsValue) {
|
|
60
|
+
maxClsValue = cumulatedValue
|
|
61
|
+
var target = maxClsTarget && maxClsTarget.deref()
|
|
62
|
+
|
|
62
63
|
callback({
|
|
63
|
-
value:
|
|
64
|
-
targetSelector:
|
|
64
|
+
value: round(maxClsValue, 4),
|
|
65
|
+
targetSelector:
|
|
66
|
+
target &&
|
|
67
|
+
getSelectorFromElement(
|
|
68
|
+
target,
|
|
69
|
+
configuration.actionNameAttribute
|
|
70
|
+
)
|
|
65
71
|
})
|
|
66
72
|
}
|
|
67
73
|
}
|
|
68
74
|
}
|
|
69
75
|
}
|
|
70
76
|
)
|
|
77
|
+
|
|
71
78
|
var stop = _subscribe.unsubscribe
|
|
72
79
|
return {
|
|
73
80
|
stop: stop
|
|
74
81
|
}
|
|
75
82
|
}
|
|
76
|
-
|
|
83
|
+
function getTargetFromSource(sources) {
|
|
84
|
+
if (!sources) {
|
|
85
|
+
return
|
|
86
|
+
}
|
|
87
|
+
var source = find(sources, function (source) {
|
|
88
|
+
return !!source.node && isElementNode(source.node)
|
|
89
|
+
})
|
|
90
|
+
return source && source.node
|
|
91
|
+
}
|
|
77
92
|
function slidingSessionWindow() {
|
|
78
93
|
var value = 0
|
|
79
94
|
var startTime
|
|
@@ -66,28 +66,28 @@ export function trackInteractionToNextPaint(
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
var newInteraction = longestInteractions.
|
|
69
|
+
var newInteraction = longestInteractions.estimateP98Interaction()
|
|
70
70
|
if (
|
|
71
71
|
newInteraction &&
|
|
72
72
|
newInteraction.duration !== interactionToNextPaint
|
|
73
73
|
) {
|
|
74
74
|
interactionToNextPaint = newInteraction.duration
|
|
75
|
-
if (interactionToNextPaint > 10 * ONE_MINUTE && !telemetryCollected) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
75
|
+
// if (interactionToNextPaint > 10 * ONE_MINUTE && !telemetryCollected) {
|
|
76
|
+
// telemetryCollected = true
|
|
77
|
+
// addTelemetryDebug('INP outlier', {
|
|
78
|
+
// inp: interactionToNextPaint,
|
|
79
|
+
// interaction: {
|
|
80
|
+
// timeFromViewStart: elapsed(viewStart, newInteraction.startTime),
|
|
81
|
+
// duration: newInteraction.duration,
|
|
82
|
+
// startTime: newInteraction.startTime,
|
|
83
|
+
// processingStart: newInteraction.processingStart,
|
|
84
|
+
// processingEnd: newInteraction.processingEnd,
|
|
85
|
+
// interactionId: newInteraction.interactionId,
|
|
86
|
+
// name: newInteraction.name,
|
|
87
|
+
// targetNodeName: newInteraction.target?.nodeName
|
|
88
|
+
// }
|
|
89
|
+
// })
|
|
90
|
+
// }
|
|
91
91
|
if (newInteraction.target && isElementNode(newInteraction.target)) {
|
|
92
92
|
interactionToNextPaintTargetSelector = getSelectorFromElement(
|
|
93
93
|
newInteraction.target,
|
|
@@ -167,7 +167,7 @@ function trackLongestInteractions(getViewInteractionCount) {
|
|
|
167
167
|
* Compute the p98 longest interaction.
|
|
168
168
|
* For better performance the computation is based on 10 longest interactions and the interaction count of the current view.
|
|
169
169
|
*/
|
|
170
|
-
|
|
170
|
+
estimateP98Interaction: function () {
|
|
171
171
|
var interactionIndex = Math.min(
|
|
172
172
|
longestInteractions.length - 1,
|
|
173
173
|
Math.floor(getViewInteractionCount() / 50)
|
|
@@ -6,7 +6,8 @@ import {
|
|
|
6
6
|
RumEventType,
|
|
7
7
|
LifeCycleEventType,
|
|
8
8
|
extend2Lev,
|
|
9
|
-
findByPath
|
|
9
|
+
findByPath,
|
|
10
|
+
discardNegativeDuration
|
|
10
11
|
} from '@cloudcare/browser-core'
|
|
11
12
|
import { trackViews } from './trackViews'
|
|
12
13
|
export function startViewCollection(
|
|
@@ -230,7 +231,3 @@ function processViewUpdate(view, configuration, recorderApi, pageStateHistory) {
|
|
|
230
231
|
}
|
|
231
232
|
}
|
|
232
233
|
}
|
|
233
|
-
|
|
234
|
-
function discardNegativeDuration(duration) {
|
|
235
|
-
return isNumber(duration) && duration < 0 ? undefined : duration
|
|
236
|
-
}
|
|
@@ -152,5 +152,21 @@ export function injectHeadersIfTracingAllowed(
|
|
|
152
152
|
context.traceId = tracer.getTraceId()
|
|
153
153
|
context.spanId = tracer.getSpanId()
|
|
154
154
|
context.traceSampled = traceSampled
|
|
155
|
-
|
|
155
|
+
|
|
156
|
+
var headers = tracer.makeTracingHeaders()
|
|
157
|
+
if (configuration.injectTraceHeader) {
|
|
158
|
+
var result = configuration.injectTraceHeader({
|
|
159
|
+
traceId: context.traceId,
|
|
160
|
+
spanId: context.spanId,
|
|
161
|
+
traceSampled: traceSampled
|
|
162
|
+
})
|
|
163
|
+
if (getType(result) === 'object') {
|
|
164
|
+
each(result, function (value, key) {
|
|
165
|
+
if (getType(value) === 'string') {
|
|
166
|
+
headers[key] = value
|
|
167
|
+
}
|
|
168
|
+
})
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
inject(headers)
|
|
156
172
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
RumInitConfiguration,
|
|
3
|
-
|
|
3
|
+
RumSiteInitConfiguration,
|
|
4
4
|
Context,
|
|
5
5
|
User
|
|
6
6
|
} from '@cloudcare/browser-core'
|
|
@@ -27,7 +27,9 @@ export interface InternalContext {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
export declare const datafluxRum: {
|
|
30
|
-
init: (
|
|
30
|
+
init: (
|
|
31
|
+
initConfiguration: RumInitConfiguration | RumSiteInitConfiguration
|
|
32
|
+
) => void
|
|
31
33
|
setGlobalContextProperty: (key: any, value: any) => void
|
|
32
34
|
addRumGlobalContext: (key: any, value: any) => void
|
|
33
35
|
removeGlobalContextProperty: (key: any) => void
|
|
@@ -38,7 +40,10 @@ export declare const datafluxRum: {
|
|
|
38
40
|
getInternalContext: (
|
|
39
41
|
startTime?: number | undefined
|
|
40
42
|
) => InternalContext | undefined
|
|
41
|
-
getInitConfiguration: () =>
|
|
43
|
+
getInitConfiguration: () =>
|
|
44
|
+
| RumInitConfiguration
|
|
45
|
+
| RumSiteInitConfiguration
|
|
46
|
+
| undefined
|
|
42
47
|
addAction: (name: string, context?: object | undefined) => void
|
|
43
48
|
addError: (error: unknown, context?: object | undefined) => void
|
|
44
49
|
addTiming: (name: string, time?: number | undefined) => void
|