@cloudcare/browser-rum 3.1.22 → 3.1.24

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 (81) hide show
  1. package/bundle/dataflux-rum.js +1 -1
  2. package/cjs/boot/buildEnv.js +1 -1
  3. package/cjs/boot/rum.js +1 -1
  4. package/cjs/boot/rum.js.map +1 -1
  5. package/cjs/domain/firstInputPolyfill.js +83 -0
  6. package/cjs/domain/firstInputPolyfill.js.map +1 -0
  7. package/cjs/domain/performanceCollection.js +4 -90
  8. package/cjs/domain/performanceCollection.js.map +1 -1
  9. package/cjs/domain/performanceObservable.js +11 -0
  10. package/cjs/domain/performanceObservable.js.map +1 -1
  11. package/cjs/domain/performanceUtils.js +30 -2
  12. package/cjs/domain/performanceUtils.js.map +1 -1
  13. package/cjs/domain/replay/deflate/deflateWorker.js +1 -1
  14. package/cjs/domain/rumEventsCollection/longTask/longTaskCollection.js +10 -2
  15. package/cjs/domain/rumEventsCollection/longTask/longTaskCollection.js.map +1 -1
  16. package/cjs/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js +4 -20
  17. package/cjs/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js.map +1 -1
  18. package/cjs/domain/rumEventsCollection/view/trackCommonViewMetrics.js +1 -1
  19. package/cjs/domain/rumEventsCollection/view/trackCommonViewMetrics.js.map +1 -1
  20. package/cjs/domain/rumEventsCollection/view/trackFirstContentfulPaint.js +6 -3
  21. package/cjs/domain/rumEventsCollection/view/trackFirstContentfulPaint.js.map +1 -1
  22. package/cjs/domain/rumEventsCollection/view/trackFirstInput.js +8 -3
  23. package/cjs/domain/rumEventsCollection/view/trackFirstInput.js.map +1 -1
  24. package/cjs/domain/rumEventsCollection/view/trackInitialViewTimings.js +4 -4
  25. package/cjs/domain/rumEventsCollection/view/trackInitialViewTimings.js.map +1 -1
  26. package/cjs/domain/rumEventsCollection/view/trackInteractionToNextPaint.js +21 -6
  27. package/cjs/domain/rumEventsCollection/view/trackInteractionToNextPaint.js.map +1 -1
  28. package/cjs/domain/rumEventsCollection/view/trackLargestContentfulPaint.js +6 -4
  29. package/cjs/domain/rumEventsCollection/view/trackLargestContentfulPaint.js.map +1 -1
  30. package/cjs/domain/rumEventsCollection/view/trackNavigationTimings.js +19 -24
  31. package/cjs/domain/rumEventsCollection/view/trackNavigationTimings.js.map +1 -1
  32. package/cjs/domain/rumEventsCollection/view/trackViews.js +1 -1
  33. package/cjs/domain/rumEventsCollection/view/trackViews.js.map +1 -1
  34. package/esm/boot/buildEnv.js +1 -1
  35. package/esm/boot/rum.js +1 -1
  36. package/esm/boot/rum.js.map +1 -1
  37. package/esm/domain/firstInputPolyfill.js +77 -0
  38. package/esm/domain/firstInputPolyfill.js.map +1 -0
  39. package/esm/domain/performanceCollection.js +4 -90
  40. package/esm/domain/performanceCollection.js.map +1 -1
  41. package/esm/domain/performanceObservable.js +11 -1
  42. package/esm/domain/performanceObservable.js.map +1 -1
  43. package/esm/domain/performanceUtils.js +29 -2
  44. package/esm/domain/performanceUtils.js.map +1 -1
  45. package/esm/domain/replay/deflate/deflateWorker.js +1 -1
  46. package/esm/domain/rumEventsCollection/longTask/longTaskCollection.js +11 -3
  47. package/esm/domain/rumEventsCollection/longTask/longTaskCollection.js.map +1 -1
  48. package/esm/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js +6 -22
  49. package/esm/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js.map +1 -1
  50. package/esm/domain/rumEventsCollection/view/trackCommonViewMetrics.js +1 -1
  51. package/esm/domain/rumEventsCollection/view/trackCommonViewMetrics.js.map +1 -1
  52. package/esm/domain/rumEventsCollection/view/trackFirstContentfulPaint.js +8 -5
  53. package/esm/domain/rumEventsCollection/view/trackFirstContentfulPaint.js.map +1 -1
  54. package/esm/domain/rumEventsCollection/view/trackFirstInput.js +10 -5
  55. package/esm/domain/rumEventsCollection/view/trackFirstInput.js.map +1 -1
  56. package/esm/domain/rumEventsCollection/view/trackInitialViewTimings.js +4 -4
  57. package/esm/domain/rumEventsCollection/view/trackInitialViewTimings.js.map +1 -1
  58. package/esm/domain/rumEventsCollection/view/trackInteractionToNextPaint.js +23 -8
  59. package/esm/domain/rumEventsCollection/view/trackInteractionToNextPaint.js.map +1 -1
  60. package/esm/domain/rumEventsCollection/view/trackLargestContentfulPaint.js +7 -5
  61. package/esm/domain/rumEventsCollection/view/trackLargestContentfulPaint.js.map +1 -1
  62. package/esm/domain/rumEventsCollection/view/trackNavigationTimings.js +21 -26
  63. package/esm/domain/rumEventsCollection/view/trackNavigationTimings.js.map +1 -1
  64. package/esm/domain/rumEventsCollection/view/trackViews.js +1 -1
  65. package/esm/domain/rumEventsCollection/view/trackViews.js.map +1 -1
  66. package/package.json +4 -4
  67. package/src/boot/rum.js +1 -1
  68. package/src/domain/firstInputPolyfill.js +92 -0
  69. package/src/domain/performanceCollection.js +5 -112
  70. package/src/domain/performanceObservable.js +19 -3
  71. package/src/domain/performanceUtils.js +37 -2
  72. package/src/domain/rumEventsCollection/longTask/longTaskCollection.js +37 -26
  73. package/src/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js +6 -35
  74. package/src/domain/rumEventsCollection/view/trackCommonViewMetrics.js +1 -2
  75. package/src/domain/rumEventsCollection/view/trackFirstContentfulPaint.js +26 -19
  76. package/src/domain/rumEventsCollection/view/trackFirstInput.js +40 -42
  77. package/src/domain/rumEventsCollection/view/trackInitialViewTimings.js +1 -4
  78. package/src/domain/rumEventsCollection/view/trackInteractionToNextPaint.js +43 -35
  79. package/src/domain/rumEventsCollection/view/trackLargestContentfulPaint.js +32 -32
  80. package/src/domain/rumEventsCollection/view/trackNavigationTimings.js +29 -31
  81. package/src/domain/rumEventsCollection/view/trackViews.js +1 -6
@@ -6,7 +6,10 @@ import {
6
6
  ONE_MINUTE
7
7
  } from '@cloudcare/browser-core'
8
8
  import { getSelectorFromElement } from '../actions/getSelectorsFromElement'
9
- import { RumPerformanceEntryType } from '../../performanceObservable'
9
+ import {
10
+ RumPerformanceEntryType,
11
+ createPerformanceObservable
12
+ } from '../../performanceObservable'
10
13
  /**
11
14
  * Track the largest contentful paint (LCP) occurring during the initial View. This can yield
12
15
  * multiple values, only the most recent one should be used.
@@ -16,7 +19,6 @@ import { RumPerformanceEntryType } from '../../performanceObservable'
16
19
  // It happens in some cases like sleep mode or some browser implementations
17
20
  export var LCP_MAXIMUM_DELAY = 10 * ONE_MINUTE
18
21
  export function trackLargestContentfulPaint(
19
- lifeCycle,
20
22
  configuration,
21
23
  firstHidden,
22
24
  eventTarget,
@@ -36,43 +38,41 @@ export function trackLargestContentfulPaint(
36
38
  )
37
39
  var stopEventListener = _addEventListeners.stop
38
40
  var biggestLcpSize = 0
39
- var subscribe = lifeCycle.subscribe(
40
- LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED,
41
- function (entries) {
42
- var lcpEntry = findLast(entries, function (entry) {
43
- return (
44
- entry.entryType ===
45
- RumPerformanceEntryType.LARGEST_CONTENTFUL_PAINT &&
46
- entry.startTime < firstInteractionTimestamp &&
47
- entry.startTime < firstHidden.getTimeStamp() &&
48
- entry.startTime < LCP_MAXIMUM_DELAY &&
49
- // Ensure to get the LCP entry with the biggest size, see
50
- // https://bugs.chromium.org/p/chromium/issues/detail?id=1516655
51
- entry.size > biggestLcpSize
41
+ var performanceLcpSubscription = createPerformanceObservable(configuration, {
42
+ type: RumPerformanceEntryType.LARGEST_CONTENTFUL_PAINT,
43
+ buffered: true
44
+ }).subscribe(function (entries) {
45
+ var lcpEntry = findLast(entries, function (entry) {
46
+ return (
47
+ entry.entryType === RumPerformanceEntryType.LARGEST_CONTENTFUL_PAINT &&
48
+ entry.startTime < firstInteractionTimestamp &&
49
+ entry.startTime < firstHidden.getTimeStamp() &&
50
+ entry.startTime < LCP_MAXIMUM_DELAY &&
51
+ // Ensure to get the LCP entry with the biggest size, see
52
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=1516655
53
+ entry.size > biggestLcpSize
54
+ )
55
+ })
56
+ if (lcpEntry) {
57
+ var lcpTargetSelector
58
+ if (lcpEntry.element) {
59
+ lcpTargetSelector = getSelectorFromElement(
60
+ lcpEntry.element,
61
+ configuration.actionNameAttribute
52
62
  )
53
- })
54
- if (lcpEntry) {
55
- var lcpTargetSelector
56
- if (lcpEntry.element) {
57
- lcpTargetSelector = getSelectorFromElement(
58
- lcpEntry.element,
59
- configuration.actionNameAttribute
60
- )
61
- }
62
- callback({
63
- value: lcpEntry.startTime,
64
- targetSelector: lcpTargetSelector
65
- })
66
- biggestLcpSize = lcpEntry.size
67
63
  }
64
+ callback({
65
+ value: lcpEntry.startTime,
66
+ targetSelector: lcpTargetSelector
67
+ })
68
+ biggestLcpSize = lcpEntry.size
68
69
  }
69
- )
70
- var unsubscribeLifeCycle = subscribe.unsubscribe
70
+ })
71
71
 
72
72
  return {
73
73
  stop: function () {
74
74
  stopEventListener()
75
- unsubscribeLifeCycle()
75
+ performanceLcpSubscription.unsubscribe()
76
76
  }
77
77
  }
78
78
  }
@@ -1,37 +1,28 @@
1
1
  import {
2
2
  relativeNow,
3
- each,
4
3
  setTimeout,
5
- noop,
6
- runOnReadyState
4
+ runOnReadyState,
5
+ clearTimeout
7
6
  } from '@cloudcare/browser-core'
8
- import {
9
- createPerformanceObservable,
10
- RumPerformanceEntryType,
11
- supportPerformanceTimingEvent
12
- } from '../../performanceObservable'
13
- import { computeRelativePerformanceTiming } from '../../performanceUtils'
14
- export function trackNavigationTimings(configuration, callback) {
15
- var processEntry = function (entry) {
7
+
8
+ import { getNavigationEntry } from '../../performanceUtils'
9
+ export function trackNavigationTimings(
10
+ configuration,
11
+ callback,
12
+ getNavigationEntryImpl
13
+ ) {
14
+ if (getNavigationEntryImpl === undefined) {
15
+ getNavigationEntryImpl = getNavigationEntry
16
+ }
17
+ return waitAfterLoadEvent(function () {
18
+ var entry = getNavigationEntryImpl()
19
+
16
20
  if (!isIncompleteNavigation(entry)) {
17
21
  callback(processNavigationEntry(entry))
18
22
  }
19
- }
20
- var stop = noop
21
- if (supportPerformanceTimingEvent(RumPerformanceEntryType.NAVIGATION)) {
22
- var subscribe = createPerformanceObservable(configuration, {
23
- type: RumPerformanceEntryType.NAVIGATION,
24
- buffered: true
25
- }).subscribe(function (entries) {
26
- return each(entries, processEntry)
27
- })
28
- stop = subscribe.unsubscribe
29
- } else {
30
- retrieveNavigationTiming(configuration, processEntry)
31
- }
32
-
33
- return { stop: stop }
23
+ })
34
24
  }
25
+
35
26
  function processNavigationEntry(entry) {
36
27
  return {
37
28
  fetchStart: entry.fetchStart,
@@ -59,11 +50,18 @@ function isIncompleteNavigation(entry) {
59
50
  return entry.loadEventEnd <= 0
60
51
  }
61
52
 
62
- function retrieveNavigationTiming(configuration, callback) {
63
- runOnReadyState('complete', function () {
64
- // Send it a bit after the actual load event, so the "loadEventEnd" timing is accurate
65
- setTimeout(function () {
66
- callback(computeRelativePerformanceTiming())
53
+ function waitAfterLoadEvent(callback) {
54
+ var timeoutId
55
+ var _runOnReadyState = runOnReadyState('complete', function () {
56
+ // Invoke the callback a bit after the actual load event, so the "loadEventEnd" timing is accurate
57
+ timeoutId = setTimeout(function () {
58
+ callback()
67
59
  })
68
60
  })
61
+ return {
62
+ stop: function () {
63
+ _runOnReadyState.stop()
64
+ clearTimeout(timeoutId)
65
+ }
66
+ }
69
67
  }
@@ -192,12 +192,7 @@ function newView(
192
192
  var setViewEnd = _trackCommonViewMetrics.setViewEnd
193
193
  var _trackInitialViewTimings =
194
194
  loadingType === ViewLoadingType.INITIAL_LOAD
195
- ? trackInitialViewMetrics(
196
- lifeCycle,
197
- configuration,
198
- setLoadEvent,
199
- scheduleViewUpdate
200
- )
195
+ ? trackInitialViewMetrics(configuration, setLoadEvent, scheduleViewUpdate)
201
196
  : {
202
197
  stop: noop,
203
198
  initialViewMetrics: {}