From edc76913c584e4d2bd4723ca57564fdbce7462bd Mon Sep 17 00:00:00 2001 From: Edward Gou Date: Tue, 4 Jun 2024 22:30:25 -0400 Subject: [PATCH 1/2] add reportAllChanges to lcp --- .../browser-utils/src/metrics/instrument.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/browser-utils/src/metrics/instrument.ts b/packages/browser-utils/src/metrics/instrument.ts index acd3717e8bd4..06a27c4225ff 100644 --- a/packages/browser-utils/src/metrics/instrument.ts +++ b/packages/browser-utils/src/metrics/instrument.ts @@ -225,12 +225,17 @@ function instrumentFid(): void { } function instrumentLcp(): StopListening { - return onLCP(metric => { - triggerHandlers('lcp', { - metric, - }); - _previousLcp = metric; - }); + return onLCP( + metric => { + triggerHandlers('lcp', { + metric, + }); + _previousLcp = metric; + }, + // We want the callback to be called whenever the LCP value updates. + // By default, the callback is only called when the tab goes to the background. + { reportAllChanges: true }, + ); } function instrumentTtfb(): StopListening { From 1480b9bdd4382155058c14084adaf5f35f61db35 Mon Sep 17 00:00:00 2001 From: Edward Gou Date: Thu, 6 Jun 2024 10:38:02 -0400 Subject: [PATCH 2/2] fix test --- .../react-create-hash-router/tests/transactions.test.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dev-packages/e2e-tests/test-applications/react-create-hash-router/tests/transactions.test.ts b/dev-packages/e2e-tests/test-applications/react-create-hash-router/tests/transactions.test.ts index e39db36ea6cb..10442a4a2bde 100644 --- a/dev-packages/e2e-tests/test-applications/react-create-hash-router/tests/transactions.test.ts +++ b/dev-packages/e2e-tests/test-applications/react-create-hash-router/tests/transactions.test.ts @@ -14,6 +14,9 @@ test('Captures a pageload transaction', async ({ page }) => { deviceMemory: expect.any(String), effectiveConnectionType: expect.any(String), hardwareConcurrency: expect.any(String), + 'lcp.element': 'body > div#root > input#exception-button[type="button"]', + 'lcp.id': 'exception-button', + 'lcp.size': 1650, 'sentry.idle_span_finish_reason': 'idleTimeout', 'sentry.op': 'pageload', 'sentry.origin': 'auto.pageload.react.reactrouter_v6',