@@ -58,7 +58,11 @@ describe('resourceCollection', () => {
58
58
beforeEach ( ( ) => {
59
59
; ( { notifyPerformanceEntries } = mockPerformanceObserver ( ) )
60
60
globalPerformanceObjectMock = mockGlobalPerformanceBuffer ( )
61
- globalPerformanceObjectMock . addPerformanceEntry ( createPerformanceEntry ( RumPerformanceEntryType . RESOURCE ) )
61
+ globalPerformanceObjectMock . addPerformanceEntry (
62
+ createPerformanceEntry ( RumPerformanceEntryType . RESOURCE , {
63
+ responseStart : 250 as RelativeTime ,
64
+ } )
65
+ )
62
66
wasInPageStateDuringPeriodSpy = spyOn ( pageStateHistory , 'wasInPageStateDuringPeriod' )
63
67
} )
64
68
@@ -110,29 +114,30 @@ describe('resourceCollection', () => {
110
114
lifeCycle . notify (
111
115
LifeCycleEventType . REQUEST_COMPLETED ,
112
116
createCompletedRequest ( {
113
- duration : 100 as Duration ,
114
- method : 'GET' ,
115
- startClocks : { relative : 1234 as RelativeTime , timeStamp : 123456789 as TimeStamp } ,
116
- status : 200 ,
117
- type : RequestType . XHR ,
118
- url : 'https://resource.com/valid' ,
119
117
xhr,
120
118
isAborted : false ,
121
119
} )
122
120
)
123
121
124
- expect ( rawRumEvents [ 0 ] . startTime ) . toBe ( 1234 as RelativeTime )
122
+ expect ( rawRumEvents [ 0 ] . startTime ) . toBe ( 200 as RelativeTime )
125
123
expect ( rawRumEvents [ 0 ] . rawRumEvent ) . toEqual ( {
126
124
date : jasmine . any ( Number ) ,
127
125
resource : {
128
126
id : jasmine . any ( String ) ,
129
127
duration : ( 100 * 1e6 ) as ServerDuration ,
130
128
method : 'GET' ,
131
129
status_code : 200 ,
132
- delivery_type : undefined ,
133
- protocol : undefined ,
130
+ delivery_type : 'cache' ,
131
+ protocol : 'HTTP/1.0' ,
134
132
type : ResourceType . XHR ,
135
133
url : 'https://resource.com/valid' ,
134
+ render_blocking_status : 'non-blocking' ,
135
+ size : 1000 ,
136
+ encoded_body_size : 500 ,
137
+ decoded_body_size : 1000 ,
138
+ transfer_size : 500 ,
139
+ download : Object ( { duration : 50_000_000 , start : 50_000_000 } ) ,
140
+ first_byte : Object ( { duration : 50_000_000 , start : 0 } ) ,
136
141
} ,
137
142
type : RumEventType . RESOURCE ,
138
143
_dd : {
@@ -141,7 +146,7 @@ describe('resourceCollection', () => {
141
146
} )
142
147
expect ( rawRumEvents [ 0 ] . domainContext ) . toEqual ( {
143
148
xhr,
144
- performanceEntry : undefined ,
149
+ performanceEntry : jasmine . any ( Object ) ,
145
150
response : undefined ,
146
151
requestInput : undefined ,
147
152
requestInit : undefined ,
@@ -202,16 +207,36 @@ describe('resourceCollection', () => {
202
207
} )
203
208
} )
204
209
205
- it ( 'should not have a duration if a frozen state happens during the request and no performance entry matches' , ( ) => {
210
+ it ( 'should not have any duration properties if a frozen state happens during the request and no performance entry matches' , ( ) => {
206
211
setupResourceCollection ( )
207
212
const mockXHR = createCompletedRequest ( )
208
213
209
214
wasInPageStateDuringPeriodSpy . and . returnValue ( true )
210
215
211
216
lifeCycle . notify ( LifeCycleEventType . REQUEST_COMPLETED , mockXHR )
212
217
213
- const rawRumResourceEventFetch = rawRumEvents [ 0 ] . rawRumEvent as RawRumResourceEvent
214
- expect ( rawRumResourceEventFetch . resource . duration ) . toBeUndefined ( )
218
+ expect ( rawRumEvents [ 0 ] . rawRumEvent ) . toEqual ( {
219
+ date : jasmine . any ( Number ) ,
220
+ resource : {
221
+ id : jasmine . any ( String ) ,
222
+ duration : undefined ,
223
+ method : 'GET' ,
224
+ status_code : 200 ,
225
+ delivery_type : 'cache' ,
226
+ protocol : 'HTTP/1.0' ,
227
+ type : ResourceType . XHR ,
228
+ url : 'https://resource.com/valid' ,
229
+ render_blocking_status : 'non-blocking' ,
230
+ size : 1000 ,
231
+ encoded_body_size : 500 ,
232
+ decoded_body_size : 1000 ,
233
+ transfer_size : 500 ,
234
+ } ,
235
+ type : RumEventType . RESOURCE ,
236
+ _dd : {
237
+ discarded : false ,
238
+ } ,
239
+ } )
215
240
} )
216
241
217
242
it ( 'should create resource from completed fetch request' , ( ) => {
@@ -220,10 +245,6 @@ describe('resourceCollection', () => {
220
245
lifeCycle . notify (
221
246
LifeCycleEventType . REQUEST_COMPLETED ,
222
247
createCompletedRequest ( {
223
- duration : 100 as Duration ,
224
- method : 'GET' ,
225
- startClocks : { relative : 1234 as RelativeTime , timeStamp : 123456789 as TimeStamp } ,
226
- status : 200 ,
227
248
type : RequestType . FETCH ,
228
249
url : 'https://resource.com/valid' ,
229
250
response,
@@ -233,26 +254,33 @@ describe('resourceCollection', () => {
233
254
} )
234
255
)
235
256
236
- expect ( rawRumEvents [ 0 ] . startTime ) . toBe ( 1234 as RelativeTime )
257
+ expect ( rawRumEvents [ 0 ] . startTime ) . toBe ( 200 as RelativeTime )
237
258
expect ( rawRumEvents [ 0 ] . rawRumEvent ) . toEqual ( {
238
259
date : jasmine . any ( Number ) ,
239
260
resource : {
240
261
id : jasmine . any ( String ) ,
241
262
duration : ( 100 * 1e6 ) as ServerDuration ,
242
263
method : 'GET' ,
243
264
status_code : 200 ,
244
- delivery_type : undefined ,
245
- protocol : undefined ,
265
+ delivery_type : 'cache' ,
266
+ protocol : 'HTTP/1.0' ,
246
267
type : ResourceType . FETCH ,
247
268
url : 'https://resource.com/valid' ,
269
+ render_blocking_status : 'non-blocking' ,
270
+ size : 1000 ,
271
+ encoded_body_size : 500 ,
272
+ decoded_body_size : 1000 ,
273
+ transfer_size : 500 ,
274
+ download : Object ( { duration : 50_000_000 , start : 50_000_000 } ) ,
275
+ first_byte : Object ( { duration : 50_000_000 , start : 0 } ) ,
248
276
} ,
249
277
type : RumEventType . RESOURCE ,
250
278
_dd : {
251
279
discarded : false ,
252
280
} ,
253
281
} )
254
282
expect ( rawRumEvents [ 0 ] . domainContext ) . toEqual ( {
255
- performanceEntry : undefined ,
283
+ performanceEntry : jasmine . any ( Object ) ,
256
284
xhr : undefined ,
257
285
response,
258
286
requestInput : 'https://resource.com/valid' ,
0 commit comments