@cloudcare/browser-rum 3.0.20 → 3.0.23
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/replay/record/mutationBatch.js +1 -1
- package/cjs/domain/replay/record/mutationObserver.js +1 -1
- package/cjs/domain/replay/segmentCollection/segment.js +34 -22
- package/cjs/domain/replay/segmentCollection/startDeflateWorker.js +28 -9
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js +2 -3
- package/cjs/domain/rumEventsCollection/resource/resourceUtils.js +9 -1
- package/cjs/domain/rumEventsCollection/view/trackInitialViewTimings.js +15 -4
- package/cjs/domain/rumEventsCollection/view/trackViews.js +2 -0
- package/cjs/domain/rumEventsCollection/view/viewCollection.js +1 -0
- package/esm/boot/buildEnv.js +1 -1
- package/esm/boot/rumPublicApi.js +3 -1
- package/esm/domain/replay/record/mutationBatch.js +16 -1
- package/esm/domain/replay/record/mutationObserver.js +102 -64
- package/esm/domain/replay/record/observers.js +5 -19
- package/esm/domain/replay/record/record.js +2 -2
- package/esm/domain/replay/record/serialize.js +10 -8
- package/esm/domain/replay/record/shadowRootsController.js +1 -1
- package/esm/domain/replay/replayStats.js +2 -2
- package/esm/domain/replay/segmentCollection/buildReplayPayload.js +3 -1
- package/esm/domain/replay/segmentCollection/segment.js +34 -22
- package/esm/domain/replay/segmentCollection/startDeflateWorker.js +22 -7
- package/esm/domain/rumEventsCollection/actions/getSelectorsFromElement.js +1 -1
- package/esm/domain/rumEventsCollection/error/errorCollection.js +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js +2 -3
- package/esm/domain/rumEventsCollection/resource/resourceUtils.js +9 -1
- package/esm/domain/rumEventsCollection/view/trackInitialViewTimings.js +15 -5
- package/esm/domain/rumEventsCollection/view/trackViews.js +2 -0
- package/esm/domain/rumEventsCollection/view/viewCollection.js +1 -0
- package/esm/domain/tracing/traceIdentifier.js +1 -2
- package/package.json +8 -7
- package/src/boot/buildEnv.js +1 -1
- package/src/boot/recorderApi.js +0 -1
- package/src/domain/replay/segmentCollection/segment.js +41 -22
- package/src/domain/replay/segmentCollection/startDeflateWorker.js +26 -8
- package/src/domain/rumEventsCollection/actions/getSelectorsFromElement.js +1 -6
- package/src/domain/rumEventsCollection/resource/resourceCollection.js +2 -2
- package/src/domain/rumEventsCollection/resource/resourceUtils.js +8 -1
- package/src/domain/rumEventsCollection/view/trackInitialViewTimings.js +19 -4
- package/src/domain/rumEventsCollection/view/trackViews.js +2 -1
- package/src/domain/rumEventsCollection/view/viewCollection.js +2 -0
- package/cjs/domain/replay/segmentCollection/deflateWorker.js +0 -4398
- package/esm/domain/replay/segmentCollection/deflateWorker.js +0 -4391
- package/src/domain/replay/segmentCollection/deflateWorker.js +0 -4583
|
@@ -4,8 +4,16 @@ import {
|
|
|
4
4
|
each,
|
|
5
5
|
addEventListener
|
|
6
6
|
} from '@cloudcare/browser-core'
|
|
7
|
-
import {
|
|
7
|
+
import { workerString } from '@cloudcare/browser-worker/string'
|
|
8
|
+
var workerURL
|
|
8
9
|
|
|
10
|
+
export function createDeflateWorker() {
|
|
11
|
+
// Lazily compute the worker URL to allow importing the SDK in NodeJS
|
|
12
|
+
if (!workerURL) {
|
|
13
|
+
workerURL = URL.createObjectURL(new Blob([workerString]))
|
|
14
|
+
}
|
|
15
|
+
return new Worker(workerURL)
|
|
16
|
+
}
|
|
9
17
|
/**
|
|
10
18
|
* In order to be sure that the worker is correctly working, we need a round trip of
|
|
11
19
|
* initialization messages, making the creation asynchronous.
|
|
@@ -64,9 +72,9 @@ export function doStartDeflateWorker(createDeflateWorkerImpl) {
|
|
|
64
72
|
addEventListener(worker, 'message', function (event) {
|
|
65
73
|
var data = event.data
|
|
66
74
|
if (data.type === 'errored') {
|
|
67
|
-
onError(data.error)
|
|
75
|
+
onError(data.error, data.streamId)
|
|
68
76
|
} else if (data.type === 'initialized') {
|
|
69
|
-
onInitialized(worker)
|
|
77
|
+
onInitialized(worker, data.version)
|
|
70
78
|
}
|
|
71
79
|
})
|
|
72
80
|
worker.postMessage({ action: 'init' })
|
|
@@ -76,16 +84,20 @@ export function doStartDeflateWorker(createDeflateWorkerImpl) {
|
|
|
76
84
|
}
|
|
77
85
|
}
|
|
78
86
|
|
|
79
|
-
function onInitialized(worker) {
|
|
87
|
+
function onInitialized(worker, version) {
|
|
80
88
|
if (state.status === DeflateWorkerStatus.Loading) {
|
|
81
89
|
each(state.callbacks, function (callback) {
|
|
82
90
|
callback(worker)
|
|
83
91
|
})
|
|
84
|
-
state = {
|
|
92
|
+
state = {
|
|
93
|
+
status: DeflateWorkerStatus.Initialized,
|
|
94
|
+
worker: worker,
|
|
95
|
+
version: version
|
|
96
|
+
}
|
|
85
97
|
}
|
|
86
98
|
}
|
|
87
99
|
|
|
88
|
-
function onError(error) {
|
|
100
|
+
function onError(error, streamId) {
|
|
89
101
|
if (state.status === DeflateWorkerStatus.Loading) {
|
|
90
102
|
display.error(
|
|
91
103
|
'Session Replay recording failed to start: an error occurred while creating the Worker:',
|
|
@@ -93,8 +105,7 @@ function onError(error) {
|
|
|
93
105
|
)
|
|
94
106
|
if (
|
|
95
107
|
error instanceof Event ||
|
|
96
|
-
(error instanceof Error &&
|
|
97
|
-
includes(error.message, 'Content Security Policy'))
|
|
108
|
+
(error instanceof Error && isMessageCspRelated(error.message))
|
|
98
109
|
) {
|
|
99
110
|
display.error('Please make sure CSP is correctly configured !!!')
|
|
100
111
|
}
|
|
@@ -104,3 +115,10 @@ function onError(error) {
|
|
|
104
115
|
state = { status: DeflateWorkerStatus.Error }
|
|
105
116
|
}
|
|
106
117
|
}
|
|
118
|
+
function isMessageCspRelated(message) {
|
|
119
|
+
return (
|
|
120
|
+
includes(message, 'Content Security Policy') ||
|
|
121
|
+
// Related to `require-trusted-types-for` CSP: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/require-trusted-types-for
|
|
122
|
+
includes(message, "requires 'TrustedScriptURL'")
|
|
123
|
+
)
|
|
124
|
+
}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
arrayFrom,
|
|
3
|
-
cssEscape,
|
|
4
|
-
elementMatches,
|
|
5
|
-
map
|
|
6
|
-
} from '@cloudcare/browser-core'
|
|
1
|
+
import { cssEscape } from '@cloudcare/browser-core'
|
|
7
2
|
import { DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE } from './getActionNameFromElement'
|
|
8
3
|
/**
|
|
9
4
|
* Stable attributes are attributes that are commonly used to identify parts of a UI (ex:
|
|
@@ -147,9 +147,9 @@ function computePerformanceEntryMetrics(timing) {
|
|
|
147
147
|
resource: extend2Lev(
|
|
148
148
|
{},
|
|
149
149
|
{
|
|
150
|
-
duration: computePerformanceResourceDuration(timing)
|
|
151
|
-
size: computeSize(timing)
|
|
150
|
+
duration: computePerformanceResourceDuration(timing)
|
|
152
151
|
},
|
|
152
|
+
computeSize(timing),
|
|
153
153
|
computePerformanceResourceDetails(timing)
|
|
154
154
|
)
|
|
155
155
|
}
|
|
@@ -277,6 +277,10 @@ export function computePerformanceResourceDetails(entry) {
|
|
|
277
277
|
details.redirect = msToNs(redirectEnd - redirectStart)
|
|
278
278
|
details.redirectTime = formatTiming(startTime, redirectStart, redirectEnd)
|
|
279
279
|
}
|
|
280
|
+
// renderBlockstatus
|
|
281
|
+
if (entry.renderBlockingStatus) {
|
|
282
|
+
details.renderBlockingStatus = entry.renderBlockingStatus
|
|
283
|
+
}
|
|
280
284
|
return details
|
|
281
285
|
}
|
|
282
286
|
|
|
@@ -361,7 +365,10 @@ function formatTiming(origin, start, end) {
|
|
|
361
365
|
export function computeSize(entry) {
|
|
362
366
|
// Make sure a request actually occurred
|
|
363
367
|
if (entry.startTime < entry.responseStart) {
|
|
364
|
-
return
|
|
368
|
+
return {
|
|
369
|
+
size: entry.decodedBodySize,
|
|
370
|
+
encodeSize: entry.encodedBodySize
|
|
371
|
+
}
|
|
365
372
|
}
|
|
366
373
|
return undefined
|
|
367
374
|
}
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
relativeNow
|
|
12
12
|
} from '@cloudcare/browser-core'
|
|
13
13
|
import { trackFirstHidden } from './trackFirstHidden'
|
|
14
|
+
import { getSelectorFromElement } from '../actions/getSelectorsFromElement'
|
|
14
15
|
// Discard LCP and FCP timings above a certain delay to avoid incorrect data
|
|
15
16
|
// It happens in some cases like sleep mode or some browser implementations
|
|
16
17
|
export var TIMING_MAXIMUM_DELAY = 10 * ONE_MINUTE
|
|
@@ -27,8 +28,12 @@ export function trackInitialViewTimings(
|
|
|
27
28
|
scheduleViewUpdate
|
|
28
29
|
) {
|
|
29
30
|
var timings = {}
|
|
30
|
-
|
|
31
|
+
var timingsElementSelector = {}
|
|
32
|
+
function setTimings(newTimings, timingSelectors) {
|
|
31
33
|
timings = extend(timings, newTimings)
|
|
34
|
+
if (timingSelectors) {
|
|
35
|
+
timingsElementSelector = extend(timingsElementSelector, timingSelectors)
|
|
36
|
+
}
|
|
32
37
|
scheduleViewUpdate()
|
|
33
38
|
}
|
|
34
39
|
var _trackNavigationTimings = trackNavigationTimings(
|
|
@@ -50,8 +55,17 @@ export function trackInitialViewTimings(
|
|
|
50
55
|
var _trackLargestContentfulPaintTiming = trackLargestContentfulPaintTiming(
|
|
51
56
|
lifeCycle,
|
|
52
57
|
window,
|
|
53
|
-
function (largestContentfulPaint) {
|
|
54
|
-
setTimings(
|
|
58
|
+
function (largestContentfulPaint, largestContentfulPaintElement) {
|
|
59
|
+
setTimings(
|
|
60
|
+
{ largestContentfulPaint: largestContentfulPaint },
|
|
61
|
+
largestContentfulPaintElement
|
|
62
|
+
? {
|
|
63
|
+
largestContentfulPaint: getSelectorFromElement(
|
|
64
|
+
largestContentfulPaintElement
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
: undefined
|
|
68
|
+
)
|
|
55
69
|
}
|
|
56
70
|
)
|
|
57
71
|
var stopLCPTracking = _trackLargestContentfulPaintTiming.stop
|
|
@@ -74,6 +88,7 @@ export function trackInitialViewTimings(
|
|
|
74
88
|
return {
|
|
75
89
|
stop: stop,
|
|
76
90
|
timings: timings,
|
|
91
|
+
timingsElementSelector: timingsElementSelector,
|
|
77
92
|
scheduleStop: function () {
|
|
78
93
|
setTimeout(stop, KEEP_TRACKING_TIMINGS_AFTER_VIEW_DELAY)
|
|
79
94
|
}
|
|
@@ -174,7 +189,7 @@ export function trackLargestContentfulPaintTiming(
|
|
|
174
189
|
)
|
|
175
190
|
})
|
|
176
191
|
if (lcpEntry) {
|
|
177
|
-
callback(lcpEntry.startTime)
|
|
192
|
+
callback(lcpEntry.startTime, lcpEntry.element)
|
|
178
193
|
}
|
|
179
194
|
}
|
|
180
195
|
)
|
|
@@ -187,7 +187,7 @@ function newView(
|
|
|
187
187
|
var scheduleStopInitialViewTimingsTracking =
|
|
188
188
|
_trackInitialViewTimings.scheduleStop
|
|
189
189
|
var timings = _trackInitialViewTimings.timings
|
|
190
|
-
|
|
190
|
+
var timingsElementSelector = _trackInitialViewTimings.timingsElementSelector
|
|
191
191
|
var _trackViewEventCounts = trackViewEventCounts(
|
|
192
192
|
lifeCycle,
|
|
193
193
|
id,
|
|
@@ -224,6 +224,7 @@ function newView(
|
|
|
224
224
|
location: location,
|
|
225
225
|
startClocks: startClocks,
|
|
226
226
|
timings: timings,
|
|
227
|
+
timingsElementSelector: timingsElementSelector,
|
|
227
228
|
duration: elapsed(startClocks.timeStamp, currentEnd),
|
|
228
229
|
isActive: endClocks === undefined,
|
|
229
230
|
sessionIsActive: sessionIsActive,
|
|
@@ -109,6 +109,8 @@ function processViewUpdate(view, foregroundContexts, recorderApi) {
|
|
|
109
109
|
largest_contentful_paint: toServerDuration(
|
|
110
110
|
view.timings.largestContentfulPaint
|
|
111
111
|
),
|
|
112
|
+
largest_contentful_paint_element_selector:
|
|
113
|
+
view.timingsElementSelector.largestContentfulPaint,
|
|
112
114
|
load_event: toServerDuration(view.timings.loadEvent),
|
|
113
115
|
loading_time: discardNegativeDuration(toServerDuration(view.loadingTime)),
|
|
114
116
|
loading_type: view.loadingType,
|