Skip to content

Commit 3138695

Browse files
authored
fix(browser): Continuously record CLS web vital (#11934)
1 parent 3804ff0 commit 3138695

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

packages/browser-utils/src/metrics/instrument.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,17 @@ function triggerHandlers(type: InstrumentHandlerType, data: unknown): void {
202202
}
203203

204204
function instrumentCls(): StopListening {
205-
return onCLS(metric => {
206-
triggerHandlers('cls', {
207-
metric,
208-
});
209-
_previousCls = metric;
210-
});
205+
return onCLS(
206+
metric => {
207+
triggerHandlers('cls', {
208+
metric,
209+
});
210+
_previousCls = metric;
211+
},
212+
// We want the callback to be called whenever the CLS value updates.
213+
// By default, the callback is only called when the tab goes to the background.
214+
{ reportAllChanges: true },
215+
);
211216
}
212217

213218
function instrumentFid(): void {

0 commit comments

Comments
 (0)