@@ -134,6 +134,28 @@ export class MetricsInstrumentation {
134134
135135 // Measurements are only available for pageload transactions
136136 if ( transaction . op === 'pageload' ) {
137+ // normalize applicable web vital values to be relative to transaction.startTimestamp
138+
139+ const timeOrigin = msToSec ( performance . timeOrigin ) ;
140+
141+ [ 'fcp' , 'fp' , 'lcp' , 'ttfb' ] . forEach ( name => {
142+ if ( ! this . _measurements [ name ] ) {
143+ return ;
144+ }
145+
146+ const oldValue = this . _measurements [ name ] . value ;
147+ const measurementTimestamp = timeOrigin + msToSec ( oldValue ) ;
148+ // normalizedValue should be in milliseconds
149+ const normalizedValue = ( measurementTimestamp - transaction . startTimestamp ) * 1000 ;
150+
151+ const delta = normalizedValue - oldValue ;
152+ logger . log (
153+ `[Measurements] Normalized ${ name } from ${ this . _measurements [ name ] . value } to ${ normalizedValue } (${ delta } )` ,
154+ ) ;
155+
156+ this . _measurements [ name ] = { value : normalizedValue } ;
157+ } ) ;
158+
137159 transaction . setMeasurements ( this . _measurements ) ;
138160 }
139161 }
@@ -253,6 +275,7 @@ function addNavigationSpans(transaction: Transaction, entry: Record<string, any>
253275 addPerformanceNavigationTiming ( transaction , entry , 'loadEvent' , timeOrigin ) ;
254276 addPerformanceNavigationTiming ( transaction , entry , 'connect' , timeOrigin ) ;
255277 addPerformanceNavigationTiming ( transaction , entry , 'secureConnection' , timeOrigin , 'connectEnd' ) ;
278+ addPerformanceNavigationTiming ( transaction , entry , 'fetch' , timeOrigin , 'domainLookupStart' ) ;
256279 addPerformanceNavigationTiming ( transaction , entry , 'domainLookup' , timeOrigin ) ;
257280 addRequest ( transaction , entry , timeOrigin ) ;
258281}
0 commit comments