Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions packages/browser-utils/src/metrics/lcp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,21 @@ function sendStandaloneLcpSpan(lcpValue: number, entry: LargestContentfulPaint |
};

if (entry) {
attributes['lcp.element'] = htmlTreeAsString(entry.element);
attributes['lcp.id'] = entry.id;
attributes['lcp.url'] = entry.url;
attributes['lcp.loadTime'] = entry.loadTime;
attributes['lcp.renderTime'] = entry.renderTime;
attributes['lcp.size'] = entry.size;
entry.element && (attributes['lcp.element'] = htmlTreeAsString(entry.element));
entry.id && (attributes['lcp.id'] = entry.id);

// Trim URL to the first 200 characters.
entry.url && (attributes['lcp.url'] = entry.url.trim().slice(0, 200));

// loadTime is the time of LCP that's related to receiving the LCP element response..
entry.loadTime != null && (attributes['lcp.loadTime'] = entry.loadTime);

// renderTime is loadTime + rendering time
// it's 0 if the LCP element is loaded from a 3rd party origin that doesn't send the
// `Timing-Allow-Origin` header.
entry.renderTime != null && (attributes['lcp.renderTime'] = entry.renderTime);

entry.size != null && (attributes['lcp.size'] = entry.size);
}

const span = startStandaloneWebVitalSpan({
Expand Down
Loading