Skip to content

Commit

Permalink
fix: no lcp target text from missing element (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
ekremney authored Apr 22, 2024
1 parent a1babb4 commit 1156663
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ sampleRUM.drain('cwv', (() => {
data.cwv[measurement.name] = measurement.value;

if (measurement.name === 'LCP' && measurement.entries.length > 0) {
const { element } = measurement.entries.pop();
data.target = sampleRUM.targetselector(element);
data.source = sampleRUM.sourceselector(element) || element.outerHTML.slice(0, 30);
const { element: el } = measurement.entries.pop();
data.target = sampleRUM.targetselector(el);
data.source = sampleRUM.sourceselector(el) || (el && el.outerHTML.slice(0, 30));
}

sampleRUM('cwv', data);
Expand Down

0 comments on commit 1156663

Please sign in to comment.