@cloudcare/browser-rum 3.0.22 → 3.0.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.
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.buildEnv = void 0;
7
7
  var buildEnv = {
8
- sdkVersion: "3.0.22",
8
+ sdkVersion: "3.0.24",
9
9
  sdkName: 'df_web_rum_sdk'
10
10
  };
11
11
  exports.buildEnv = buildEnv;
@@ -108,9 +108,8 @@ function processResourceEntry(entry) {
108
108
  function computePerformanceEntryMetrics(timing) {
109
109
  return {
110
110
  resource: (0, _browserCore.extend2Lev)({}, {
111
- duration: (0, _resourceUtils.computePerformanceResourceDuration)(timing),
112
- size: (0, _resourceUtils.computeSize)(timing)
113
- }, (0, _resourceUtils.computePerformanceResourceDetails)(timing))
111
+ duration: (0, _resourceUtils.computePerformanceResourceDuration)(timing)
112
+ }, (0, _resourceUtils.computeSize)(timing), (0, _resourceUtils.computePerformanceResourceDetails)(timing))
114
113
  };
115
114
  }
116
115
 
@@ -218,6 +218,11 @@ function computePerformanceResourceDetails(entry) {
218
218
  if (hasRedirection(entry)) {
219
219
  details.redirect = (0, _browserCore.msToNs)(redirectEnd - redirectStart);
220
220
  details.redirectTime = formatTiming(startTime, redirectStart, redirectEnd);
221
+ } // renderBlockstatus
222
+
223
+
224
+ if (entry.renderBlockingStatus) {
225
+ details.renderBlockingStatus = entry.renderBlockingStatus;
221
226
  }
222
227
 
223
228
  return details;
@@ -291,7 +296,10 @@ function formatTiming(origin, start, end) {
291
296
  function computeSize(entry) {
292
297
  // Make sure a request actually occurred
293
298
  if (entry.startTime < entry.responseStart) {
294
- return entry.decodedBodySize;
299
+ return {
300
+ size: entry.decodedBodySize,
301
+ encodeSize: entry.encodedBodySize
302
+ };
295
303
  }
296
304
 
297
305
  return undefined;
@@ -14,6 +14,8 @@ var _browserCore = require("@cloudcare/browser-core");
14
14
 
15
15
  var _trackFirstHidden = require("./trackFirstHidden");
16
16
 
17
+ var _getSelectorsFromElement = require("../actions/getSelectorsFromElement");
18
+
17
19
  // Discard LCP and FCP timings above a certain delay to avoid incorrect data
18
20
  // It happens in some cases like sleep mode or some browser implementations
19
21
  var TIMING_MAXIMUM_DELAY = 10 * _browserCore.ONE_MINUTE;
@@ -30,9 +32,15 @@ exports.KEEP_TRACKING_TIMINGS_AFTER_VIEW_DELAY = KEEP_TRACKING_TIMINGS_AFTER_VIE
30
32
 
31
33
  function trackInitialViewTimings(lifeCycle, setLoadEvent, scheduleViewUpdate) {
32
34
  var timings = {};
35
+ var timingsElementSelector = {};
33
36
 
34
- function setTimings(newTimings) {
37
+ function setTimings(newTimings, timingSelectors) {
35
38
  timings = (0, _browserCore.extend)(timings, newTimings);
39
+
40
+ if (timingSelectors) {
41
+ timingsElementSelector = (0, _browserCore.extend)(timingsElementSelector, timingSelectors);
42
+ }
43
+
36
44
  scheduleViewUpdate();
37
45
  }
38
46
 
@@ -51,10 +59,12 @@ function trackInitialViewTimings(lifeCycle, setLoadEvent, scheduleViewUpdate) {
51
59
 
52
60
  var stopFCPTracking = _trackFirstContentfulPaintTiming.stop;
53
61
 
54
- var _trackLargestContentfulPaintTiming = trackLargestContentfulPaintTiming(lifeCycle, window, function (largestContentfulPaint) {
62
+ var _trackLargestContentfulPaintTiming = trackLargestContentfulPaintTiming(lifeCycle, window, function (largestContentfulPaint, largestContentfulPaintElement) {
55
63
  setTimings({
56
64
  largestContentfulPaint: largestContentfulPaint
57
- });
65
+ }, largestContentfulPaintElement ? {
66
+ largestContentfulPaint: (0, _getSelectorsFromElement.getSelectorFromElement)(largestContentfulPaintElement)
67
+ } : undefined);
58
68
  });
59
69
 
60
70
  var stopLCPTracking = _trackLargestContentfulPaintTiming.stop;
@@ -78,6 +88,7 @@ function trackInitialViewTimings(lifeCycle, setLoadEvent, scheduleViewUpdate) {
78
88
  return {
79
89
  stop: stop,
80
90
  timings: timings,
91
+ timingsElementSelector: timingsElementSelector,
81
92
  scheduleStop: function scheduleStop() {
82
93
  (0, _browserCore.setTimeout)(stop, KEEP_TRACKING_TIMINGS_AFTER_VIEW_DELAY);
83
94
  }
@@ -159,7 +170,7 @@ function trackLargestContentfulPaintTiming(lifeCycle, emitter, callback) {
159
170
  });
160
171
 
161
172
  if (lcpEntry) {
162
- callback(lcpEntry.startTime);
173
+ callback(lcpEntry.startTime, lcpEntry.element);
163
174
  }
164
175
  });
165
176
  var unsubscribeLifeCycle = subscribe.unsubscribe;
@@ -135,11 +135,13 @@ function newView(lifeCycle, domMutationObservable, configuration, initialLocatio
135
135
 
136
136
  var _trackInitialViewTimings = loadingType === _browserCore.ViewLoadingType.INITIAL_LOAD ? (0, _trackInitialViewTimings2.trackInitialViewTimings)(lifeCycle, setLoadEvent, scheduleViewUpdate) : {
137
137
  scheduleStop: _browserCore.noop,
138
- timings: {}
138
+ timings: {},
139
+ timingsElementSelector: {}
139
140
  };
140
141
 
141
142
  var scheduleStopInitialViewTimingsTracking = _trackInitialViewTimings.scheduleStop;
142
143
  var timings = _trackInitialViewTimings.timings;
144
+ var timingsElementSelector = _trackInitialViewTimings.timingsElementSelector;
143
145
 
144
146
  var _trackViewEventCounts = (0, _trackViewEventCounts2.trackViewEventCounts)(lifeCycle, id, scheduleViewUpdate);
145
147
 
@@ -165,6 +167,7 @@ function newView(lifeCycle, domMutationObservable, configuration, initialLocatio
165
167
  location: location,
166
168
  startClocks: startClocks,
167
169
  timings: timings,
170
+ timingsElementSelector: timingsElementSelector,
168
171
  duration: (0, _browserCore.elapsed)(startClocks.timeStamp, currentEnd),
169
172
  isActive: endClocks === undefined,
170
173
  sessionIsActive: sessionIsActive,
@@ -96,6 +96,7 @@ function processViewUpdate(view, foregroundContexts, recorderApi) {
96
96
  is_active: view.isActive,
97
97
  name: view.name,
98
98
  largest_contentful_paint: (0, _browserCore.toServerDuration)(view.timings.largestContentfulPaint),
99
+ largest_contentful_paint_element_selector: view.timingsElementSelector.largestContentfulPaint,
99
100
  load_event: (0, _browserCore.toServerDuration)(view.timings.loadEvent),
100
101
  loading_time: discardNegativeDuration((0, _browserCore.toServerDuration)(view.loadingTime)),
101
102
  loading_type: view.loadingType,
@@ -1,4 +1,4 @@
1
1
  export var buildEnv = {
2
- sdkVersion: "3.0.22",
2
+ sdkVersion: "3.0.24",
3
3
  sdkName: 'df_web_rum_sdk'
4
4
  };
@@ -1,4 +1,4 @@
1
- import { arrayFrom, cssEscape, elementMatches, map } from '@cloudcare/browser-core';
1
+ import { cssEscape } from '@cloudcare/browser-core';
2
2
  import { DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE } from './getActionNameFromElement';
3
3
  /**
4
4
  * Stable attributes are attributes that are commonly used to identify parts of a UI (ex:
@@ -97,9 +97,8 @@ function processResourceEntry(entry) {
97
97
  function computePerformanceEntryMetrics(timing) {
98
98
  return {
99
99
  resource: extend2Lev({}, {
100
- duration: computePerformanceResourceDuration(timing),
101
- size: computeSize(timing)
102
- }, computePerformanceResourceDetails(timing))
100
+ duration: computePerformanceResourceDuration(timing)
101
+ }, computeSize(timing), computePerformanceResourceDetails(timing))
103
102
  };
104
103
  }
105
104
 
@@ -190,6 +190,11 @@ export function computePerformanceResourceDetails(entry) {
190
190
  if (hasRedirection(entry)) {
191
191
  details.redirect = msToNs(redirectEnd - redirectStart);
192
192
  details.redirectTime = formatTiming(startTime, redirectStart, redirectEnd);
193
+ } // renderBlockstatus
194
+
195
+
196
+ if (entry.renderBlockingStatus) {
197
+ details.renderBlockingStatus = entry.renderBlockingStatus;
193
198
  }
194
199
 
195
200
  return details;
@@ -262,7 +267,10 @@ function formatTiming(origin, start, end) {
262
267
  export function computeSize(entry) {
263
268
  // Make sure a request actually occurred
264
269
  if (entry.startTime < entry.responseStart) {
265
- return entry.decodedBodySize;
270
+ return {
271
+ size: entry.decodedBodySize,
272
+ encodeSize: entry.encodedBodySize
273
+ };
266
274
  }
267
275
 
268
276
  return undefined;
@@ -1,5 +1,6 @@
1
1
  import { addEventListeners, elapsed, extend, DOM_EVENT, find, findLast, LifeCycleEventType, ONE_MINUTE, setTimeout, relativeNow } from '@cloudcare/browser-core';
2
- import { trackFirstHidden } from './trackFirstHidden'; // Discard LCP and FCP timings above a certain delay to avoid incorrect data
2
+ import { trackFirstHidden } from './trackFirstHidden';
3
+ import { getSelectorFromElement } from '../actions/getSelectorsFromElement'; // Discard LCP and FCP timings above a certain delay to avoid incorrect data
3
4
  // It happens in some cases like sleep mode or some browser implementations
4
5
 
5
6
  export var TIMING_MAXIMUM_DELAY = 10 * ONE_MINUTE;
@@ -13,9 +14,15 @@ export var TIMING_MAXIMUM_DELAY = 10 * ONE_MINUTE;
13
14
  export var KEEP_TRACKING_TIMINGS_AFTER_VIEW_DELAY = 5 * ONE_MINUTE;
14
15
  export function trackInitialViewTimings(lifeCycle, setLoadEvent, scheduleViewUpdate) {
15
16
  var timings = {};
17
+ var timingsElementSelector = {};
16
18
 
17
- function setTimings(newTimings) {
19
+ function setTimings(newTimings, timingSelectors) {
18
20
  timings = extend(timings, newTimings);
21
+
22
+ if (timingSelectors) {
23
+ timingsElementSelector = extend(timingsElementSelector, timingSelectors);
24
+ }
25
+
19
26
  scheduleViewUpdate();
20
27
  }
21
28
 
@@ -34,10 +41,12 @@ export function trackInitialViewTimings(lifeCycle, setLoadEvent, scheduleViewUpd
34
41
 
35
42
  var stopFCPTracking = _trackFirstContentfulPaintTiming.stop;
36
43
 
37
- var _trackLargestContentfulPaintTiming = trackLargestContentfulPaintTiming(lifeCycle, window, function (largestContentfulPaint) {
44
+ var _trackLargestContentfulPaintTiming = trackLargestContentfulPaintTiming(lifeCycle, window, function (largestContentfulPaint, largestContentfulPaintElement) {
38
45
  setTimings({
39
46
  largestContentfulPaint: largestContentfulPaint
40
- });
47
+ }, largestContentfulPaintElement ? {
48
+ largestContentfulPaint: getSelectorFromElement(largestContentfulPaintElement)
49
+ } : undefined);
41
50
  });
42
51
 
43
52
  var stopLCPTracking = _trackLargestContentfulPaintTiming.stop;
@@ -61,6 +70,7 @@ export function trackInitialViewTimings(lifeCycle, setLoadEvent, scheduleViewUpd
61
70
  return {
62
71
  stop: stop,
63
72
  timings: timings,
73
+ timingsElementSelector: timingsElementSelector,
64
74
  scheduleStop: function scheduleStop() {
65
75
  setTimeout(stop, KEEP_TRACKING_TIMINGS_AFTER_VIEW_DELAY);
66
76
  }
@@ -139,7 +149,7 @@ export function trackLargestContentfulPaintTiming(lifeCycle, emitter, callback)
139
149
  });
140
150
 
141
151
  if (lcpEntry) {
142
- callback(lcpEntry.startTime);
152
+ callback(lcpEntry.startTime, lcpEntry.element);
143
153
  }
144
154
  });
145
155
  var unsubscribeLifeCycle = subscribe.unsubscribe;
@@ -120,11 +120,13 @@ function newView(lifeCycle, domMutationObservable, configuration, initialLocatio
120
120
 
121
121
  var _trackInitialViewTimings = loadingType === ViewLoadingType.INITIAL_LOAD ? trackInitialViewTimings(lifeCycle, setLoadEvent, scheduleViewUpdate) : {
122
122
  scheduleStop: noop,
123
- timings: {}
123
+ timings: {},
124
+ timingsElementSelector: {}
124
125
  };
125
126
 
126
127
  var scheduleStopInitialViewTimingsTracking = _trackInitialViewTimings.scheduleStop;
127
128
  var timings = _trackInitialViewTimings.timings;
129
+ var timingsElementSelector = _trackInitialViewTimings.timingsElementSelector;
128
130
 
129
131
  var _trackViewEventCounts = trackViewEventCounts(lifeCycle, id, scheduleViewUpdate);
130
132
 
@@ -150,6 +152,7 @@ function newView(lifeCycle, domMutationObservable, configuration, initialLocatio
150
152
  location: location,
151
153
  startClocks: startClocks,
152
154
  timings: timings,
155
+ timingsElementSelector: timingsElementSelector,
153
156
  duration: elapsed(startClocks.timeStamp, currentEnd),
154
157
  isActive: endClocks === undefined,
155
158
  sessionIsActive: sessionIsActive,
@@ -86,6 +86,7 @@ function processViewUpdate(view, foregroundContexts, recorderApi) {
86
86
  is_active: view.isActive,
87
87
  name: view.name,
88
88
  largest_contentful_paint: toServerDuration(view.timings.largestContentfulPaint),
89
+ largest_contentful_paint_element_selector: view.timingsElementSelector.largestContentfulPaint,
89
90
  load_event: toServerDuration(view.timings.loadEvent),
90
91
  loading_time: discardNegativeDuration(toServerDuration(view.loadingTime)),
91
92
  loading_type: view.loadingType,
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@cloudcare/browser-rum",
3
- "version": "3.0.22",
3
+ "version": "3.0.24",
4
4
  "main": "cjs/index.js",
5
5
  "module": "esm/index.js",
6
6
  "dependencies": {
7
- "@cloudcare/browser-core": "^3.0.22",
8
- "@cloudcare/browser-worker": "^3.0.22"
7
+ "@cloudcare/browser-core": "^3.0.23",
8
+ "@cloudcare/browser-worker": "^3.0.23"
9
9
  },
10
10
  "scripts": {
11
11
  "dev": "webpack serve --open --mode=development",
@@ -30,5 +30,5 @@
30
30
  "license": "MIT",
31
31
  "homepage": "https://github.com/CloudCare/dataflux-rum-sdk-javascript/blob/master/packages/rum/README.md",
32
32
  "description": "DataFlux RUM Web 端数据指标监控",
33
- "gitHead": "8aedb21df0524848f219d75b79af3239cff88711"
33
+ "gitHead": "1f11d42a884feb36db7d1e6fd5a94ab4cd765391"
34
34
  }
@@ -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 entry.decodedBodySize
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
- function setTimings(newTimings) {
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({ largestContentfulPaint: largestContentfulPaint })
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
  )
@@ -183,11 +183,11 @@ function newView(
183
183
  var _trackInitialViewTimings =
184
184
  loadingType === ViewLoadingType.INITIAL_LOAD
185
185
  ? trackInitialViewTimings(lifeCycle, setLoadEvent, scheduleViewUpdate)
186
- : { scheduleStop: noop, timings: {} }
186
+ : { scheduleStop: noop, timings: {}, timingsElementSelector: {} }
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,