1
- import type { ClocksState , Duration } from '@datadog/browser-core'
2
1
import {
3
2
combine ,
4
3
generateUUID ,
@@ -95,15 +94,13 @@ function processRequest(
95
94
96
95
const correspondingTimingOverrides = matchingTiming ? computeResourceEntryMetrics ( matchingTiming ) : undefined
97
96
98
- const duration = computeRequestDuration ( pageStateHistory , startClocks , request . duration )
99
-
100
97
const resourceEvent = combine (
101
98
{
102
99
date : startClocks . timeStamp ,
103
100
resource : {
104
101
id : generateUUID ( ) ,
105
102
type,
106
- duration,
103
+ duration : toServerDuration ( request . duration ) ,
107
104
method : request . method ,
108
105
status_code : request . status ,
109
106
protocol : matchingTiming && computeResourceEntryProtocol ( matchingTiming ) ,
@@ -117,7 +114,11 @@ function processRequest(
117
114
} ,
118
115
tracingInfo ,
119
116
correspondingTimingOverrides
120
- )
117
+ ) as RawRumResourceEvent
118
+
119
+ if ( pageStateHistory . wasInPageStateDuringPeriod ( PageState . FROZEN , startClocks . relative , request . duration ) ) {
120
+ resourceEvent . resource . duration = undefined
121
+ }
121
122
122
123
return {
123
124
startTime : startClocks . relative ,
@@ -216,12 +217,6 @@ function computeResourceEntryTracingInfo(entry: RumPerformanceResourceTiming, co
216
217
}
217
218
}
218
219
219
- function computeRequestDuration ( pageStateHistory : PageStateHistory , startClocks : ClocksState , duration : Duration ) {
220
- return ! pageStateHistory . wasInPageStateDuringPeriod ( PageState . FROZEN , startClocks . relative , duration )
221
- ? toServerDuration ( duration )
222
- : undefined
223
- }
224
-
225
220
/**
226
221
* The status is 0 for cross-origin resources without CORS headers, so the status is meaningless, and we shouldn't report it
227
222
* https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/responseStatus#cross-origin_response_status_codes
0 commit comments