Skip to content

Commit 182a63b

Browse files
authored
Fix bug with loaf data (#872)
* Fix bug with LoAF data * Uncomment correct code :-)
1 parent 7b0c188 commit 182a63b

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/js/send-web-vitals.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
function sendWebVitals() {
22

33
function getLoafAttribution(attribution) {
4-
if (!attribution?.longAnimationFrameEntries) {
4+
const loafEntriesLength = attribution?.longAnimationFrameEntries?.length || 0;
5+
if (loafEntriesLength === 0) {
56
return {};
67
}
78

@@ -10,7 +11,7 @@ function sendWebVitals() {
1011
};
1112

1213
// The last LoAF entry is usually the most relevant.
13-
const loaf = attribution.longAnimationFrameEntries.at(-1)
14+
const loaf = attribution.longAnimationFrameEntries.at(-1);
1415
const loafEndTime = loaf.startTime + loaf.duration;
1516
loaf.scripts.forEach(script => {
1617
if (script.duration <= loafAttribution.debug_loaf_script_total_duration) {
@@ -38,7 +39,7 @@ function sendWebVitals() {
3839
debug_loaf_script_source_char_position: script.sourceCharPosition,
3940

4041
// LoAF metadata.
41-
debug_loaf_meta_length: attribution.longAnimationFrameEntries.length,
42+
debug_loaf_meta_length: loafEntriesLength,
4243
}
4344
});
4445

0 commit comments

Comments
 (0)