-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(browser): Send CLS as standalone span (experimental) (#13056)
Add an experimental feature to `browserTracingIntegration` to no longer tie CLS reporting to the ongoing pageload span but instead send a standalone CLS span similarly to how we report INP. The big advantage of this reporting strategy is that layout shifts happening after the pageload idle span ended, will also get reported. This should give users more accurate CLS values in the web vitals performance insights module.
- Loading branch information
Showing
11 changed files
with
760 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
.../browser-integration-tests/suites/tracing/metrics/web-vitals-cls-standalone-spans/init.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import * as Sentry from '@sentry/browser'; | ||
|
||
window.Sentry = Sentry; | ||
|
||
Sentry.init({ | ||
dsn: 'https://[email protected]/1337', | ||
integrations: [ | ||
Sentry.browserTracingIntegration({ | ||
idleTimeout: 9000, | ||
_experiments: { | ||
enableStandaloneClsSpans: true, | ||
}, | ||
}), | ||
], | ||
tracesSampleRate: 1, | ||
debug: true, | ||
}); |
17 changes: 17 additions & 0 deletions
17
...owser-integration-tests/suites/tracing/metrics/web-vitals-cls-standalone-spans/subject.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { simulateCLS } from '../../../../utils/web-vitals/cls.ts'; | ||
|
||
// Simulate Layout shift right at the beginning of the page load, depending on the URL hash | ||
// don't run if expected CLS is NaN | ||
const expectedCLS = Number(location.hash.slice(1)); | ||
if (expectedCLS && expectedCLS >= 0) { | ||
simulateCLS(expectedCLS).then(() => window.dispatchEvent(new Event('cls-done'))); | ||
} | ||
|
||
// Simulate layout shift whenever the trigger-cls event is dispatched | ||
// Cannot trigger cia a button click because expected layout shift after | ||
// an interaction doesn't contribute to CLS. | ||
window.addEventListener('trigger-cls', () => { | ||
simulateCLS(0.1).then(() => { | ||
window.dispatchEvent(new Event('cls-done')); | ||
}); | ||
}); |
12 changes: 12 additions & 0 deletions
12
...er-integration-tests/suites/tracing/metrics/web-vitals-cls-standalone-spans/template.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
</head> | ||
<body> | ||
<div id="content"></div> | ||
<p> | ||
Some content | ||
</p> | ||
</body> | ||
</html> |
Oops, something went wrong.