@cloudcare/browser-rum 3.1.19 → 3.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.
- package/bundle/dataflux-rum.js +1 -1
- package/cjs/boot/buildEnv.js +1 -1
- package/cjs/boot/rum.js +11 -10
- package/cjs/boot/rum.js.map +1 -1
- package/cjs/domain/assembly.js.map +1 -1
- package/cjs/domain/contexts/pageStateHistory.js +4 -1
- package/cjs/domain/contexts/pageStateHistory.js.map +1 -1
- package/cjs/domain/contexts/urlContexts.js +3 -1
- package/cjs/domain/contexts/urlContexts.js.map +1 -1
- package/cjs/domain/contexts/viewContexts.js +9 -1
- package/cjs/domain/contexts/viewContexts.js.map +1 -1
- package/cjs/domain/locationChangeObservable.js +6 -4
- package/cjs/domain/locationChangeObservable.js.map +1 -1
- package/cjs/domain/performanceCollection.js +40 -90
- package/cjs/domain/performanceCollection.js.map +1 -1
- package/cjs/domain/performanceObservable.js +113 -0
- package/cjs/domain/performanceObservable.js.map +1 -0
- package/cjs/domain/performanceUtils.js +20 -0
- package/cjs/domain/performanceUtils.js.map +1 -0
- package/cjs/domain/replay/deflate/deflateWorker.js +1 -1
- package/cjs/domain/replay/record/observers.js +58 -54
- package/cjs/domain/replay/record/observers.js.map +1 -1
- package/cjs/domain/requestCollection.js +6 -2
- package/cjs/domain/requestCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/trackClickActions.js +3 -1
- package/cjs/domain/rumEventsCollection/actions/trackClickActions.js.map +1 -1
- package/cjs/domain/rumEventsCollection/longTask/longTaskCollection.js +5 -7
- package/cjs/domain/rumEventsCollection/longTask/longTaskCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/{matchRequestTiming.js → matchRequestResourceEntry.js} +4 -4
- package/cjs/domain/rumEventsCollection/resource/matchRequestResourceEntry.js.map +1 -0
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js +64 -66
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/resourceUtils.js +18 -14
- package/cjs/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js +41 -0
- package/cjs/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js.map +1 -0
- package/cjs/domain/rumEventsCollection/view/trackCommonViewMetrics.js +1 -1
- package/cjs/domain/rumEventsCollection/view/trackCommonViewMetrics.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +8 -5
- package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackFirstContentfulPaint.js +2 -1
- package/cjs/domain/rumEventsCollection/view/trackFirstContentfulPaint.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackFirstInput.js +2 -1
- package/cjs/domain/rumEventsCollection/view/trackFirstInput.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackInitialViewTimings.js +1 -1
- package/cjs/domain/rumEventsCollection/view/trackInitialViewTimings.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackInteractionToNextPaint.js +3 -19
- package/cjs/domain/rumEventsCollection/view/trackInteractionToNextPaint.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackLargestContentfulPaint.js +2 -1
- package/cjs/domain/rumEventsCollection/view/trackLargestContentfulPaint.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackNavigationTimings.js +49 -25
- package/cjs/domain/rumEventsCollection/view/trackNavigationTimings.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackViewEventCounts.js +1 -22
- package/cjs/domain/rumEventsCollection/view/trackViewEventCounts.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackViews.js +1 -1
- package/cjs/domain/rumEventsCollection/view/trackViews.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/viewCollection.js +1 -0
- package/cjs/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
- package/cjs/domain/waitPageActivityEnd.js +6 -5
- package/cjs/domain/waitPageActivityEnd.js.map +1 -1
- package/esm/boot/buildEnv.js +1 -1
- package/esm/boot/rum.js +11 -10
- package/esm/boot/rum.js.map +1 -1
- package/esm/domain/assembly.js.map +1 -1
- package/esm/domain/contexts/pageStateHistory.js +5 -2
- package/esm/domain/contexts/pageStateHistory.js.map +1 -1
- package/esm/domain/contexts/urlContexts.js +4 -2
- package/esm/domain/contexts/urlContexts.js.map +1 -1
- package/esm/domain/contexts/viewContexts.js +10 -2
- package/esm/domain/contexts/viewContexts.js.map +1 -1
- package/esm/domain/locationChangeObservable.js +7 -5
- package/esm/domain/locationChangeObservable.js.map +1 -1
- package/esm/domain/performanceCollection.js +41 -89
- package/esm/domain/performanceCollection.js.map +1 -1
- package/esm/domain/performanceObservable.js +105 -0
- package/esm/domain/performanceObservable.js.map +1 -0
- package/esm/domain/performanceUtils.js +14 -0
- package/esm/domain/performanceUtils.js.map +1 -0
- package/esm/domain/replay/deflate/deflateWorker.js +1 -1
- package/esm/domain/replay/record/observers.js +59 -55
- package/esm/domain/replay/record/observers.js.map +1 -1
- package/esm/domain/requestCollection.js +6 -2
- package/esm/domain/requestCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/trackClickActions.js +4 -2
- package/esm/domain/rumEventsCollection/actions/trackClickActions.js.map +1 -1
- package/esm/domain/rumEventsCollection/longTask/longTaskCollection.js +6 -8
- package/esm/domain/rumEventsCollection/longTask/longTaskCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/{matchRequestTiming.js → matchRequestResourceEntry.js} +5 -5
- package/esm/domain/rumEventsCollection/resource/matchRequestResourceEntry.js.map +1 -0
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js +66 -68
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceUtils.js +12 -9
- package/esm/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js +35 -0
- package/esm/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js.map +1 -0
- package/esm/domain/rumEventsCollection/view/trackCommonViewMetrics.js +1 -1
- package/esm/domain/rumEventsCollection/view/trackCommonViewMetrics.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +9 -7
- package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackFirstContentfulPaint.js +2 -1
- package/esm/domain/rumEventsCollection/view/trackFirstContentfulPaint.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackFirstInput.js +2 -2
- package/esm/domain/rumEventsCollection/view/trackFirstInput.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackInitialViewTimings.js +1 -1
- package/esm/domain/rumEventsCollection/view/trackInitialViewTimings.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackInteractionToNextPaint.js +2 -19
- package/esm/domain/rumEventsCollection/view/trackInteractionToNextPaint.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackLargestContentfulPaint.js +2 -2
- package/esm/domain/rumEventsCollection/view/trackLargestContentfulPaint.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackNavigationTimings.js +50 -26
- package/esm/domain/rumEventsCollection/view/trackNavigationTimings.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackViewEventCounts.js +1 -21
- package/esm/domain/rumEventsCollection/view/trackViewEventCounts.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackViews.js +1 -1
- package/esm/domain/rumEventsCollection/view/trackViews.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/viewCollection.js +1 -0
- package/esm/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
- package/esm/domain/waitPageActivityEnd.js +7 -7
- package/esm/domain/waitPageActivityEnd.js.map +1 -1
- package/package.json +4 -4
- package/src/boot/rum.js +18 -9
- package/src/domain/assembly.js +0 -1
- package/src/domain/contexts/pageStateHistory.js +5 -5
- package/src/domain/contexts/urlContexts.js +4 -2
- package/src/domain/contexts/viewContexts.js +10 -3
- package/src/domain/locationChangeObservable.js +17 -7
- package/src/domain/performanceCollection.js +55 -138
- package/src/domain/performanceObservable.js +148 -0
- package/src/domain/performanceUtils.js +16 -0
- package/src/domain/replay/record/observers.js +39 -35
- package/src/domain/requestCollection.js +6 -2
- package/src/domain/rumEventsCollection/actions/trackClickActions.js +4 -2
- package/src/domain/rumEventsCollection/longTask/longTaskCollection.js +7 -8
- package/src/domain/rumEventsCollection/resource/{matchRequestTiming.js → matchRequestResourceEntry.js} +10 -4
- package/src/domain/rumEventsCollection/resource/resourceCollection.js +74 -117
- package/src/domain/rumEventsCollection/resource/resourceUtils.js +13 -11
- package/src/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js +45 -0
- package/src/domain/rumEventsCollection/view/trackCommonViewMetrics.js +2 -1
- package/src/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +24 -7
- package/src/domain/rumEventsCollection/view/trackFirstContentfulPaint.js +2 -1
- package/src/domain/rumEventsCollection/view/trackFirstInput.js +2 -2
- package/src/domain/rumEventsCollection/view/trackInitialViewTimings.js +1 -1
- package/src/domain/rumEventsCollection/view/trackInteractionToNextPaint.js +7 -19
- package/src/domain/rumEventsCollection/view/trackLargestContentfulPaint.js +3 -2
- package/src/domain/rumEventsCollection/view/trackNavigationTimings.js +65 -32
- package/src/domain/rumEventsCollection/view/trackViewEventCounts.js +1 -24
- package/src/domain/rumEventsCollection/view/trackViews.js +1 -1
- package/src/domain/rumEventsCollection/view/viewCollection.js +4 -0
- package/src/domain/waitPageActivityEnd.js +16 -17
- package/cjs/domain/rumEventsCollection/resource/matchRequestTiming.js.map +0 -1
- package/esm/domain/rumEventsCollection/resource/matchRequestTiming.js.map +0 -1
|
@@ -1,35 +1,68 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
loadEventStart: entry.loadEventStart,
|
|
18
|
-
domContentLoadedEventEnd: entry.domContentLoadedEventEnd,
|
|
19
|
-
domContentLoadedEventStart: entry.domContentLoadedEventStart,
|
|
20
|
-
// In some cases the value reported is negative or is larger
|
|
21
|
-
// than the current page time. Ignore these cases:
|
|
22
|
-
// https://github.com/GoogleChrome/web-vitals/issues/137
|
|
23
|
-
// https://github.com/GoogleChrome/web-vitals/issues/162
|
|
24
|
-
firstByte:
|
|
25
|
-
entry.responseStart >= 0 && entry.responseStart <= relativeNow()
|
|
26
|
-
? entry.responseStart
|
|
27
|
-
: undefined
|
|
28
|
-
})
|
|
29
|
-
}
|
|
30
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
relativeNow,
|
|
3
|
+
each,
|
|
4
|
+
setTimeout,
|
|
5
|
+
noop,
|
|
6
|
+
runOnReadyState
|
|
7
|
+
} from '@cloudcare/browser-core'
|
|
8
|
+
import {
|
|
9
|
+
createPerformanceObservable,
|
|
10
|
+
RumPerformanceEntryType,
|
|
11
|
+
supportPerformanceTimingEvent
|
|
12
|
+
} from '../../performanceObservable'
|
|
13
|
+
export function trackNavigationTimings(configuration, callback) {
|
|
14
|
+
var processEntry = function (entry) {
|
|
15
|
+
if (!isIncompleteNavigation(entry)) {
|
|
16
|
+
callback(processNavigationEntry(entry))
|
|
31
17
|
}
|
|
32
|
-
|
|
18
|
+
}
|
|
19
|
+
var stop = noop
|
|
20
|
+
if (supportPerformanceTimingEvent(RumPerformanceEntryType.NAVIGATION)) {
|
|
21
|
+
var subscribe = createPerformanceObservable(configuration, {
|
|
22
|
+
type: RumPerformanceEntryType.NAVIGATION,
|
|
23
|
+
buffered: true
|
|
24
|
+
}).subscribe(function (entries) {
|
|
25
|
+
return each(entries, processEntry)
|
|
26
|
+
})
|
|
27
|
+
stop = subscribe.unsubscribe
|
|
28
|
+
} else {
|
|
29
|
+
retrieveNavigationTiming(configuration, processEntry)
|
|
30
|
+
}
|
|
33
31
|
|
|
34
|
-
return { stop:
|
|
32
|
+
return { stop: stop }
|
|
33
|
+
}
|
|
34
|
+
function processNavigationEntry(entry) {
|
|
35
|
+
return {
|
|
36
|
+
fetchStart: entry.fetchStart,
|
|
37
|
+
responseEnd: entry.responseEnd,
|
|
38
|
+
domComplete: entry.domComplete,
|
|
39
|
+
domContentLoaded: entry.domContentLoadedEventEnd,
|
|
40
|
+
domInteractive: entry.domInteractive,
|
|
41
|
+
loadEvent: entry.loadEventEnd,
|
|
42
|
+
loadEventEnd: entry.loadEventEnd,
|
|
43
|
+
loadEventStart: entry.loadEventStart,
|
|
44
|
+
domContentLoadedEventEnd: entry.domContentLoadedEventEnd,
|
|
45
|
+
domContentLoadedEventStart: entry.domContentLoadedEventStart,
|
|
46
|
+
// In some cases the value reported is negative or is larger
|
|
47
|
+
// than the current page time. Ignore these cases:
|
|
48
|
+
// https://github.com/GoogleChrome/web-vitals/issues/137
|
|
49
|
+
// https://github.com/GoogleChrome/web-vitals/issues/162
|
|
50
|
+
firstByte:
|
|
51
|
+
entry.responseStart >= 0 && entry.responseStart <= relativeNow()
|
|
52
|
+
? entry.responseStart
|
|
53
|
+
: undefined
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function isIncompleteNavigation(entry) {
|
|
58
|
+
return entry.loadEventEnd <= 0
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function retrieveNavigationTiming(configuration, callback) {
|
|
62
|
+
runOnReadyState('complete', function () {
|
|
63
|
+
// Send it a bit after the actual load event, so the "loadEventEnd" timing is accurate
|
|
64
|
+
setTimeout(function () {
|
|
65
|
+
callback(computeRelativePerformanceTiming())
|
|
66
|
+
})
|
|
67
|
+
})
|
|
35
68
|
}
|
|
@@ -1,23 +1,5 @@
|
|
|
1
|
-
import { ONE_MINUTE, setTimeout } from '@cloudcare/browser-core'
|
|
2
1
|
import { trackEventCounts } from '../../trackEventCounts'
|
|
3
2
|
|
|
4
|
-
// Some events are not being counted as they transcend views. To reduce the occurrence;
|
|
5
|
-
// an arbitrary delay is added for stopping event counting after the view ends.
|
|
6
|
-
//
|
|
7
|
-
// Ideally, we would not stop and keep counting events until the end of the session.
|
|
8
|
-
// But this might have a small performance impact if there are many many views:
|
|
9
|
-
// we would need to go through each event to see if the related view matches.
|
|
10
|
-
// So let's have a fairly short delay to avoid impacting performances too much.
|
|
11
|
-
//
|
|
12
|
-
// In the future, we could have views stored in a data structure similar to ContextHistory. Whenever
|
|
13
|
-
// a child event is collected, we could look into this history to find the matching view and
|
|
14
|
-
// increase the associated and increase its counter. Having a centralized data structure for it
|
|
15
|
-
// would allow us to look for views more efficiently.
|
|
16
|
-
//
|
|
17
|
-
// For now, having a small cleanup delay will already improve the situation in most cases.
|
|
18
|
-
|
|
19
|
-
export var KEEP_TRACKING_EVENT_COUNTS_AFTER_VIEW_DELAY = 5 * ONE_MINUTE
|
|
20
|
-
|
|
21
3
|
export function trackViewEventCounts(lifeCycle, viewId, onChange) {
|
|
22
4
|
var _trackEventCounts = trackEventCounts({
|
|
23
5
|
lifeCycle: lifeCycle,
|
|
@@ -27,12 +9,7 @@ export function trackViewEventCounts(lifeCycle, viewId, onChange) {
|
|
|
27
9
|
onChange: onChange
|
|
28
10
|
})
|
|
29
11
|
return {
|
|
30
|
-
|
|
31
|
-
setTimeout(
|
|
32
|
-
_trackEventCounts.stop,
|
|
33
|
-
KEEP_TRACKING_EVENT_COUNTS_AFTER_VIEW_DELAY
|
|
34
|
-
)
|
|
35
|
-
},
|
|
12
|
+
stop: _trackEventCounts.stop,
|
|
36
13
|
eventCounts: _trackEventCounts.eventCounts
|
|
37
14
|
}
|
|
38
15
|
}
|
|
@@ -209,7 +209,7 @@ function newView(
|
|
|
209
209
|
id,
|
|
210
210
|
scheduleViewUpdate
|
|
211
211
|
)
|
|
212
|
-
var stopEventCountsTracking = _trackViewEventCounts.
|
|
212
|
+
var stopEventCountsTracking = _trackViewEventCounts.stop
|
|
213
213
|
var eventCounts = _trackViewEventCounts.eventCounts
|
|
214
214
|
|
|
215
215
|
// Session keep alive
|
|
@@ -125,6 +125,10 @@ function processViewUpdate(view, configuration, recorderApi, pageStateHistory) {
|
|
|
125
125
|
view.commonViewMetrics,
|
|
126
126
|
'cumulativeLayoutShift.value'
|
|
127
127
|
),
|
|
128
|
+
cumulative_layout_shift_time: findByPath(
|
|
129
|
+
view.commonViewMetrics,
|
|
130
|
+
'cumulativeLayoutShift.time'
|
|
131
|
+
),
|
|
128
132
|
cumulative_layout_shift_target_selector: findByPath(
|
|
129
133
|
view.commonViewMetrics,
|
|
130
134
|
'cumulativeLayoutShift.targetSelector'
|
|
@@ -5,11 +5,14 @@ import {
|
|
|
5
5
|
LifeCycleEventType,
|
|
6
6
|
some,
|
|
7
7
|
matchList,
|
|
8
|
-
|
|
8
|
+
instrumentMethod,
|
|
9
9
|
setTimeout,
|
|
10
10
|
clearTimeout
|
|
11
11
|
} from '@cloudcare/browser-core'
|
|
12
|
-
|
|
12
|
+
import {
|
|
13
|
+
createPerformanceObservable,
|
|
14
|
+
RumPerformanceEntryType
|
|
15
|
+
} from '../domain/performanceObservable'
|
|
13
16
|
// Delay to wait for a page activity to validate the tracking process
|
|
14
17
|
export var PAGE_ACTIVITY_VALIDATION_DELAY = 100
|
|
15
18
|
// Delay to wait after a page activity to end the tracking process
|
|
@@ -127,21 +130,17 @@ export function createPageActivityObservable(
|
|
|
127
130
|
|
|
128
131
|
subscriptions.push(
|
|
129
132
|
domMutationObservable.subscribe(notifyPageActivity),
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
})
|
|
140
|
-
) {
|
|
141
|
-
notifyPageActivity()
|
|
142
|
-
}
|
|
133
|
+
createPerformanceObservable(configuration, {
|
|
134
|
+
type: RumPerformanceEntryType.RESOURCE
|
|
135
|
+
}).subscribe(function (entries) {
|
|
136
|
+
if (
|
|
137
|
+
some(entries, function (entry) {
|
|
138
|
+
return !isExcludedUrl(configuration, entry.name)
|
|
139
|
+
})
|
|
140
|
+
) {
|
|
141
|
+
notifyPageActivity()
|
|
143
142
|
}
|
|
144
|
-
),
|
|
143
|
+
}),
|
|
145
144
|
lifeCycle.subscribe(
|
|
146
145
|
LifeCycleEventType.REQUEST_STARTED,
|
|
147
146
|
function (startEvent) {
|
|
@@ -193,5 +192,5 @@ function isExcludedUrl(configuration, requestUrl) {
|
|
|
193
192
|
}
|
|
194
193
|
|
|
195
194
|
function trackWindowOpen(callback) {
|
|
196
|
-
return
|
|
195
|
+
return instrumentMethod(window, 'open', callback)
|
|
197
196
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"matchRequestTiming.js","names":["_resourceUtils","require","_browserCore","alreadyMatchedEntries","WeakSet","matchRequestTiming","request","performance","sameNameEntries","getEntriesByName","url","length","candidates","filter","entry","has","isValidEntry","isBetween","startClocks","relative","endTime","startTime","duration","add","toJSON","timing","addDuration","start","end","errorMargin"],"sources":["../../../../src/domain/rumEventsCollection/resource/matchRequestTiming.js"],"sourcesContent":["import { isValidEntry } from './resourceUtils'\nimport { map, filter, addDuration, WeakSet } from '@cloudcare/browser-core'\n\nvar alreadyMatchedEntries = new WeakSet()\n/**\n * Look for corresponding timing in resource timing buffer\n *\n * Observations:\n * - Timing (start, end) are nested inside the request (start, end)\n * - Browsers generate a timing entry for OPTIONS request\n *\n * Strategy:\n * - from valid nested entries\n * - if a single timing match, return the timing\n * - if two following timings match (OPTIONS request), return the timing for the actual request\n * - otherwise we can't decide, return undefined\n */\nexport function matchRequestTiming(request) {\n if (!performance || !('getEntriesByName' in performance)) {\n return\n }\n var sameNameEntries = performance.getEntriesByName(request.url, 'resource')\n\n if (!sameNameEntries.length || !('toJSON' in sameNameEntries[0])) {\n return\n }\n var candidates = filter(sameNameEntries, function (entry) {\n return !alreadyMatchedEntries.has(entry)\n })\n\n candidates = filter(candidates, function (entry) {\n return isValidEntry(entry)\n })\n candidates = filter(candidates, function (entry) {\n return isBetween(\n entry,\n request.startClocks.relative,\n endTime({\n startTime: request.startClocks.relative,\n duration: request.duration\n })\n )\n })\n\n if (candidates.length === 1) {\n alreadyMatchedEntries.add(candidates[0])\n return candidates[0].toJSON()\n }\n return\n}\n\nfunction endTime(timing) {\n return addDuration(timing.startTime, timing.duration)\n}\n\nfunction isBetween(timing, start, end) {\n // eslint-disable-next-line @typescript-eslint/restrict-plus-operands\n var errorMargin = 1\n return (\n timing.startTime >= start - errorMargin &&\n endTime(timing) <= addDuration(end, errorMargin)\n )\n}\n"],"mappings":";;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAIE,qBAAqB,GAAG,IAAIC,oBAAO,CAAC,CAAC;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,kBAAkBA,CAACC,OAAO,EAAE;EAC1C,IAAI,CAACC,WAAW,IAAI,EAAE,kBAAkB,IAAIA,WAAW,CAAC,EAAE;IACxD;EACF;EACA,IAAIC,eAAe,GAAGD,WAAW,CAACE,gBAAgB,CAACH,OAAO,CAACI,GAAG,EAAE,UAAU,CAAC;EAE3E,IAAI,CAACF,eAAe,CAACG,MAAM,IAAI,EAAE,QAAQ,IAAIH,eAAe,CAAC,CAAC,CAAC,CAAC,EAAE;IAChE;EACF;EACA,IAAII,UAAU,GAAG,IAAAC,mBAAM,EAACL,eAAe,EAAE,UAAUM,KAAK,EAAE;IACxD,OAAO,CAACX,qBAAqB,CAACY,GAAG,CAACD,KAAK,CAAC;EAC1C,CAAC,CAAC;EAEFF,UAAU,GAAG,IAAAC,mBAAM,EAACD,UAAU,EAAE,UAAUE,KAAK,EAAE;IAC/C,OAAO,IAAAE,2BAAY,EAACF,KAAK,CAAC;EAC5B,CAAC,CAAC;EACFF,UAAU,GAAG,IAAAC,mBAAM,EAACD,UAAU,EAAE,UAAUE,KAAK,EAAE;IAC/C,OAAOG,SAAS,CACdH,KAAK,EACLR,OAAO,CAACY,WAAW,CAACC,QAAQ,EAC5BC,OAAO,CAAC;MACNC,SAAS,EAAEf,OAAO,CAACY,WAAW,CAACC,QAAQ;MACvCG,QAAQ,EAAEhB,OAAO,CAACgB;IACpB,CAAC,CACH,CAAC;EACH,CAAC,CAAC;EAEF,IAAIV,UAAU,CAACD,MAAM,KAAK,CAAC,EAAE;IAC3BR,qBAAqB,CAACoB,GAAG,CAACX,UAAU,CAAC,CAAC,CAAC,CAAC;IACxC,OAAOA,UAAU,CAAC,CAAC,CAAC,CAACY,MAAM,CAAC,CAAC;EAC/B;EACA;AACF;AAEA,SAASJ,OAAOA,CAACK,MAAM,EAAE;EACvB,OAAO,IAAAC,wBAAW,EAACD,MAAM,CAACJ,SAAS,EAAEI,MAAM,CAACH,QAAQ,CAAC;AACvD;AAEA,SAASL,SAASA,CAACQ,MAAM,EAAEE,KAAK,EAAEC,GAAG,EAAE;EACrC;EACA,IAAIC,WAAW,GAAG,CAAC;EACnB,OACEJ,MAAM,CAACJ,SAAS,IAAIM,KAAK,GAAGE,WAAW,IACvCT,OAAO,CAACK,MAAM,CAAC,IAAI,IAAAC,wBAAW,EAACE,GAAG,EAAEC,WAAW,CAAC;AAEpD","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"matchRequestTiming.js","names":["isValidEntry","map","filter","addDuration","WeakSet","alreadyMatchedEntries","matchRequestTiming","request","performance","sameNameEntries","getEntriesByName","url","length","candidates","entry","has","isBetween","startClocks","relative","endTime","startTime","duration","add","toJSON","timing","start","end","errorMargin"],"sources":["../../../../src/domain/rumEventsCollection/resource/matchRequestTiming.js"],"sourcesContent":["import { isValidEntry } from './resourceUtils'\nimport { map, filter, addDuration, WeakSet } from '@cloudcare/browser-core'\n\nvar alreadyMatchedEntries = new WeakSet()\n/**\n * Look for corresponding timing in resource timing buffer\n *\n * Observations:\n * - Timing (start, end) are nested inside the request (start, end)\n * - Browsers generate a timing entry for OPTIONS request\n *\n * Strategy:\n * - from valid nested entries\n * - if a single timing match, return the timing\n * - if two following timings match (OPTIONS request), return the timing for the actual request\n * - otherwise we can't decide, return undefined\n */\nexport function matchRequestTiming(request) {\n if (!performance || !('getEntriesByName' in performance)) {\n return\n }\n var sameNameEntries = performance.getEntriesByName(request.url, 'resource')\n\n if (!sameNameEntries.length || !('toJSON' in sameNameEntries[0])) {\n return\n }\n var candidates = filter(sameNameEntries, function (entry) {\n return !alreadyMatchedEntries.has(entry)\n })\n\n candidates = filter(candidates, function (entry) {\n return isValidEntry(entry)\n })\n candidates = filter(candidates, function (entry) {\n return isBetween(\n entry,\n request.startClocks.relative,\n endTime({\n startTime: request.startClocks.relative,\n duration: request.duration\n })\n )\n })\n\n if (candidates.length === 1) {\n alreadyMatchedEntries.add(candidates[0])\n return candidates[0].toJSON()\n }\n return\n}\n\nfunction endTime(timing) {\n return addDuration(timing.startTime, timing.duration)\n}\n\nfunction isBetween(timing, start, end) {\n // eslint-disable-next-line @typescript-eslint/restrict-plus-operands\n var errorMargin = 1\n return (\n timing.startTime >= start - errorMargin &&\n endTime(timing) <= addDuration(end, errorMargin)\n )\n}\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,GAAG,EAAEC,MAAM,EAAEC,WAAW,EAAEC,OAAO,QAAQ,yBAAyB;AAE3E,IAAIC,qBAAqB,GAAG,IAAID,OAAO,CAAC,CAAC;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,kBAAkBA,CAACC,OAAO,EAAE;EAC1C,IAAI,CAACC,WAAW,IAAI,EAAE,kBAAkB,IAAIA,WAAW,CAAC,EAAE;IACxD;EACF;EACA,IAAIC,eAAe,GAAGD,WAAW,CAACE,gBAAgB,CAACH,OAAO,CAACI,GAAG,EAAE,UAAU,CAAC;EAE3E,IAAI,CAACF,eAAe,CAACG,MAAM,IAAI,EAAE,QAAQ,IAAIH,eAAe,CAAC,CAAC,CAAC,CAAC,EAAE;IAChE;EACF;EACA,IAAII,UAAU,GAAGX,MAAM,CAACO,eAAe,EAAE,UAAUK,KAAK,EAAE;IACxD,OAAO,CAACT,qBAAqB,CAACU,GAAG,CAACD,KAAK,CAAC;EAC1C,CAAC,CAAC;EAEFD,UAAU,GAAGX,MAAM,CAACW,UAAU,EAAE,UAAUC,KAAK,EAAE;IAC/C,OAAOd,YAAY,CAACc,KAAK,CAAC;EAC5B,CAAC,CAAC;EACFD,UAAU,GAAGX,MAAM,CAACW,UAAU,EAAE,UAAUC,KAAK,EAAE;IAC/C,OAAOE,SAAS,CACdF,KAAK,EACLP,OAAO,CAACU,WAAW,CAACC,QAAQ,EAC5BC,OAAO,CAAC;MACNC,SAAS,EAAEb,OAAO,CAACU,WAAW,CAACC,QAAQ;MACvCG,QAAQ,EAAEd,OAAO,CAACc;IACpB,CAAC,CACH,CAAC;EACH,CAAC,CAAC;EAEF,IAAIR,UAAU,CAACD,MAAM,KAAK,CAAC,EAAE;IAC3BP,qBAAqB,CAACiB,GAAG,CAACT,UAAU,CAAC,CAAC,CAAC,CAAC;IACxC,OAAOA,UAAU,CAAC,CAAC,CAAC,CAACU,MAAM,CAAC,CAAC;EAC/B;EACA;AACF;AAEA,SAASJ,OAAOA,CAACK,MAAM,EAAE;EACvB,OAAOrB,WAAW,CAACqB,MAAM,CAACJ,SAAS,EAAEI,MAAM,CAACH,QAAQ,CAAC;AACvD;AAEA,SAASL,SAASA,CAACQ,MAAM,EAAEC,KAAK,EAAEC,GAAG,EAAE;EACrC;EACA,IAAIC,WAAW,GAAG,CAAC;EACnB,OACEH,MAAM,CAACJ,SAAS,IAAIK,KAAK,GAAGE,WAAW,IACvCR,OAAO,CAACK,MAAM,CAAC,IAAIrB,WAAW,CAACuB,GAAG,EAAEC,WAAW,CAAC;AAEpD","ignoreList":[]}
|