@cloudcare/browser-rum 3.2.10 → 3.2.12

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.
@@ -22,7 +22,9 @@ import {
22
22
  isResourceEntryRequestType,
23
23
  isResourceUrlLimit,
24
24
  isLongDataUrl,
25
- sanitizeDataUrl
25
+ sanitizeDataUrl,
26
+ computeResourceEntryDeliveryType,
27
+ computeResourceEntryProtocol
26
28
  } from './resourceUtils'
27
29
  import { PageState } from '../../contexts/pageStateHistory'
28
30
  import {
@@ -48,10 +50,6 @@ export function startResourceCollection(
48
50
  handleResource(function () {
49
51
  return processRequest(request, pageStateHistory)
50
52
  })
51
- // var rawEvent = processRequest(request, pageStateHistory)
52
- // if (rawEvent) {
53
- // lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, rawEvent)
54
- // }
55
53
  })
56
54
  var performanceResourceSubscription = createPerformanceObservable(
57
55
  configuration,
@@ -60,8 +58,7 @@ export function startResourceCollection(
60
58
  buffered: true
61
59
  }
62
60
  ).subscribe(function (entries) {
63
- for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
64
- var entry = entries_1[_i]
61
+ var loop = function (entry) {
65
62
  if (
66
63
  !isResourceEntryRequestType(entry) &&
67
64
  !isResourceUrlLimit(entry.name, configuration.resourceUrlLimit)
@@ -71,6 +68,10 @@ export function startResourceCollection(
71
68
  })
72
69
  }
73
70
  }
71
+ for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
72
+ var entry = entries_1[_i]
73
+ loop(entry)
74
+ }
74
75
  })
75
76
 
76
77
  retrieveInitialDocumentResourceTimingImpl(configuration, function (timing) {
@@ -129,7 +130,10 @@ function processRequest(request, pageStateHistory) {
129
130
  urlHost: urlObj.Host,
130
131
  urlPath: urlObj.Path,
131
132
  urlPathGroup: replaceNumberCharByPath(urlObj.Path),
132
- urlQuery: getQueryParamsFromUrl(request.url)
133
+ urlQuery: getQueryParamsFromUrl(request.url),
134
+ deliveryType:
135
+ matchingTiming && computeResourceEntryDeliveryType(matchingTiming),
136
+ protocol: matchingTiming && computeResourceEntryProtocol(matchingTiming)
133
137
  },
134
138
  type: RumEventType.RESOURCE
135
139
  },
@@ -171,7 +175,9 @@ function processResourceEntry(entry, configuration) {
171
175
  urlQuery: getQueryParamsFromUrl(entry.name),
172
176
  method: 'GET',
173
177
  status: discardZeroStatus(entry.responseStatus),
174
- statusGroup: getStatusGroup(entry.responseStatus)
178
+ statusGroup: getStatusGroup(entry.responseStatus),
179
+ deliveryType: computeResourceEntryDeliveryType(entry),
180
+ protocol: computeResourceEntryProtocol(entry)
175
181
  },
176
182
  type: RumEventType.RESOURCE
177
183
  },
@@ -101,6 +101,22 @@ function areInOrder() {
101
101
  }
102
102
  return true
103
103
  }
104
+ /**
105
+ * Handles the 'deliveryType' property to distinguish between supported values ('cache', 'navigational-prefetch'),
106
+ * undefined (unsupported in some browsers), and other cases ('other' for unknown or unrecognized values).
107
+ * see: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/deliveryType
108
+ */
109
+ export function computeResourceEntryDeliveryType(entry) {
110
+ return entry.deliveryType === '' ? 'other' : entry.deliveryType
111
+ }
112
+ /**
113
+ * The 'nextHopProtocol' is an empty string for cross-origin resources without CORS headers,
114
+ * meaning the protocol is unknown, and we shouldn't report it.
115
+ * https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/nextHopProtocol#cross-origin_resources
116
+ */
117
+ export function computeResourceEntryProtocol(entry) {
118
+ return entry.nextHopProtocol === '' ? undefined : entry.nextHopProtocol
119
+ }
104
120
 
105
121
  export function isResourceEntryRequestType(entry) {
106
122
  return (