-
-
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)
- Loading branch information
Showing
11 changed files
with
673 additions
and
75 deletions.
There are no files selected for viewing
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')); | ||
}); | ||
}); |
9 changes: 9 additions & 0 deletions
9
...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,9 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
</head> | ||
<body> | ||
<div id="content"></div> | ||
</body> | ||
</html> |
Oops, something went wrong.