File tree Expand file tree Collapse file tree 1 file changed +15
-6
lines changed
packages/browser-utils/src/metrics Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -105,12 +105,21 @@ function sendStandaloneLcpSpan(lcpValue: number, entry: LargestContentfulPaint |
105
105
} ;
106
106
107
107
if ( entry ) {
108
- attributes [ 'lcp.element' ] = htmlTreeAsString ( entry . element ) ;
109
- attributes [ 'lcp.id' ] = entry . id ;
110
- attributes [ 'lcp.url' ] = entry . url ;
111
- attributes [ 'lcp.loadTime' ] = entry . loadTime ;
112
- attributes [ 'lcp.renderTime' ] = entry . renderTime ;
113
- attributes [ 'lcp.size' ] = entry . size ;
108
+ entry . element && ( attributes [ 'lcp.element' ] = htmlTreeAsString ( entry . element ) ) ;
109
+ entry . id && ( attributes [ 'lcp.id' ] = entry . id ) ;
110
+
111
+ // Trim URL to the first 200 characters.
112
+ entry . url && ( attributes [ 'lcp.url' ] = entry . url . trim ( ) . slice ( 0 , 200 ) ) ;
113
+
114
+ // loadTime is the time of LCP that's related to receiving the LCP element response..
115
+ entry . loadTime != null && ( attributes [ 'lcp.loadTime' ] = entry . loadTime ) ;
116
+
117
+ // renderTime is loadTime + rendering time
118
+ // it's 0 if the LCP element is loaded from a 3rd party origin that doesn't send the
119
+ // `Timing-Allow-Origin` header.
120
+ entry . renderTime != null && ( attributes [ 'lcp.renderTime' ] = entry . renderTime ) ;
121
+
122
+ entry . size && ( attributes [ 'lcp.size' ] = entry . size ) ;
114
123
}
115
124
116
125
const span = startStandaloneWebVitalSpan ( {
You can’t perform that action at this time.
0 commit comments