-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ [RUMF-992] New CLS implementation #1026
Conversation
2fe84c6
to
733f765
Compare
Codecov Report
@@ Coverage Diff @@
## main #1026 +/- ##
==========================================
+ Coverage 89.04% 89.06% +0.02%
==========================================
Files 88 88
Lines 4143 4161 +18
Branches 952 957 +5
==========================================
+ Hits 3689 3706 +17
- Misses 454 455 +1
Continue to review full report at Codecov.
|
packages/rum-core/src/domain/rumEventsCollection/view/trackViewMetrics.ts
Outdated
Show resolved
Hide resolved
packages/rum-core/src/domain/rumEventsCollection/view/trackViewMetrics.ts
Outdated
Show resolved
Hide resolved
packages/rum-core/src/domain/rumEventsCollection/view/trackViewMetrics.ts
Outdated
Show resolved
Hide resolved
packages/rum-core/src/domain/rumEventsCollection/view/trackViewMetrics.spec.ts
Outdated
Show resolved
Hide resolved
packages/rum-core/src/domain/rumEventsCollection/view/trackViewMetrics.spec.ts
Outdated
Show resolved
Hide resolved
// first session window | ||
newLayoutShift(lifeCycle, 0.1) | ||
clock.tick(4500) | ||
newLayoutShift(lifeCycle, 0.2) | ||
// second session window | ||
clock.tick(501) | ||
newLayoutShift(lifeCycle, 0.1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FMU, this is not what is expected to be tested: the first shift creates a session, then the session expires (after 1 second), then the second shift creates the second session, and the third shift gets added to the second session. So this test is similar to the previous one.
You should do something like:
for (let i = 0; i < 6; i += 1) {
newLayoutShift(lifeCycle, 0.1)
clock.tick(999)
}
(the first five are in the same session, the sixth creates a new session)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, I will update this test.
let windowStartedAt = 0 as RelativeTime | ||
let windowLastEntryAt = 0 as RelativeTime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to start with an "undefined" window so it is created at the first shift instead of at the begining of the navigation.
const { unsubscribe: stop } = lifeCycle.subscribe(LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, (entry) => { | ||
if (entry.entryType === 'layout-shift' && !entry.hadRecentInput) { | ||
callback(entry.value) | ||
window.update(entry) | ||
if (window.value() > clsValue) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (window.value() > clsValue) { | |
if (window.value() > maxClsValue) { |
it could be a bit clearer by expressing that the cls value is the max one
Motivation
The strategy to compute CLS has changed.
Old strategy: CLS is the sum of all layout shifts
New strategy:
Changes
Testing
unit, CI
I have gone over the contributing documentation.