Skip to content

Commit d764f2e

Browse files
logaretmclaude
andcommitted
fix(browser-utils): Cache browserPerformanceTimeOrigin call in _sendLcpSpan
Avoid calling browserPerformanceTimeOrigin() twice by caching the result in a local variable. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3bc1f0a commit d764f2e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,9 @@ export function _sendLcpSpan(
124124
): void {
125125
DEBUG_BUILD && debug.log(`Sending LCP span (${lcpValue})`);
126126

127-
const timeOrigin = msToSec(browserPerformanceTimeOrigin() || 0);
128-
const endTime = msToSec((browserPerformanceTimeOrigin() || 0) + (entry?.startTime || 0));
127+
const performanceTimeOrigin = browserPerformanceTimeOrigin() || 0;
128+
const timeOrigin = msToSec(performanceTimeOrigin);
129+
const endTime = msToSec(performanceTimeOrigin + (entry?.startTime || 0));
129130
const name = entry ? htmlTreeAsString(entry.element) : 'Largest contentful paint';
130131

131132
const attributes: SpanAttributes = {};

0 commit comments

Comments
 (0)