Skip to content

Commit 240a991

Browse files
committed
only track updated CLS if FCP is recorded
1 parent 3865a54 commit 240a991

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

packages/tracing/src/browser/metrics.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,12 @@ export class MetricsInstrumentation {
189189
});
190190
}
191191

192+
// If FCP is not recorded we should not record the updated cls value
193+
// according to the new definition of CLS.
194+
if (!('fcp' in this._measurements)) {
195+
delete this._measurements['updated-cls'];
196+
}
197+
192198
transaction.setMeasurements(this._measurements);
193199
this._tagMetricInfo(transaction);
194200
}
@@ -245,6 +251,9 @@ export class MetricsInstrumentation {
245251
this._clsEntry = entry as LayoutShift;
246252
});
247253

254+
// See:
255+
// https://web.dev/evolving-cls/
256+
// https://web.dev/cls-web-tooling/
248257
getUpdatedCLS(metric => {
249258
const entry = metric.entries.pop();
250259
if (!entry) {

packages/tracing/src/browser/web-vitals/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ Current vendored web vitals are:
1212
- FID (First Input Delay)
1313
- CLS (Cumulative Layout Shift)
1414

15+
## Notable Changes from web-vitals library
16+
17+
This vendored web-vitals library is meant to be used in conjugtion with the `@sentry/tracing` `BrowserTracing` integration.
18+
As such, logic around `BFCache` and multiple reports were removed from the library as our web-vitals only report once per pageload.
19+
1520
## License
1621

1722
[Apache 2.0](https://github.com/GoogleChrome/web-vitals/blob/master/LICENSE)

0 commit comments

Comments
 (0)