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', 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 {