@@ -134,6 +134,28 @@ export class MetricsInstrumentation {
134
134
135
135
// Measurements are only available for pageload transactions
136
136
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
+
137
159
transaction . setMeasurements ( this . _measurements ) ;
138
160
}
139
161
}
@@ -253,6 +275,7 @@ function addNavigationSpans(transaction: Transaction, entry: Record<string, any>
253
275
addPerformanceNavigationTiming ( transaction , entry , 'loadEvent' , timeOrigin ) ;
254
276
addPerformanceNavigationTiming ( transaction , entry , 'connect' , timeOrigin ) ;
255
277
addPerformanceNavigationTiming ( transaction , entry , 'secureConnection' , timeOrigin , 'connectEnd' ) ;
278
+ addPerformanceNavigationTiming ( transaction , entry , 'fetch' , timeOrigin , 'domainLookupStart' ) ;
256
279
addPerformanceNavigationTiming ( transaction , entry , 'domainLookup' , timeOrigin ) ;
257
280
addRequest ( transaction , entry , timeOrigin ) ;
258
281
}
0 commit comments