Skip to content

Commit d94bfe3

Browse files
authored
Fix loaf monitoring bug (#3675)
* Fix LoAF monitoring bug * Add semi colon
1 parent 63f2c9f commit d94bfe3

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/static/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)