Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions packages/tracing-internal/src/browser/instrument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,15 @@ function triggerHandlers(type: InstrumentHandlerType, data: unknown): void {
}

function instrumentCls(): StopListening {
return onCLS(metric => {
triggerHandlers('cls', {
metric,
});
_previousCls = metric;
});
return onCLS(
metric => {
triggerHandlers('cls', {
metric,
});
_previousCls = metric;
},
{ reportAllChanges: true },
);
}

function instrumentFid(): void {
Expand Down
7 changes: 5 additions & 2 deletions packages/tracing-internal/src/browser/web-vitals/getCLS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ import type { CLSMetric, ReportCallback, StopListening } from './types';
* hidden. As a result, the `callback` function might be called multiple times
* during the same page load._
*/
export const onCLS = (onReport: ReportCallback): StopListening | undefined => {
export const onCLS = (
onReport: ReportCallback,
options: { reportAllChanges?: boolean } = {},
): StopListening | undefined => {
const metric = initMetric('CLS', 0);
let report: ReturnType<typeof bindReporter>;

Expand Down Expand Up @@ -87,7 +90,7 @@ export const onCLS = (onReport: ReportCallback): StopListening | undefined => {

const po = observe('layout-shift', handleEntries);
if (po) {
report = bindReporter(onReport, metric);
report = bindReporter(onReport, metric, options.reportAllChanges);

const stopListening = (): void => {
handleEntries(po.takeRecords() as CLSMetric['entries']);
Expand Down