Skip to content

Commit 9d48700

Browse files
committed
fix integration, add unit test
1 parent 84630a3 commit 9d48700

File tree

2 files changed

+9
-3
lines changed
  • dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-lcp-standalone-spans
  • packages/browser-utils/src/metrics

2 files changed

+9
-3
lines changed

dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-lcp-standalone-spans/test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ sentryTest('captures LCP vital as a standalone span', async ({ getLocalTestUrl,
6060
'user_agent.original': expect.stringContaining('Chrome'),
6161
'sentry.pageload.span_id': expect.stringMatching(/[a-f0-9]{16}/),
6262
'lcp.element': 'body > img',
63-
'lcp.id': '',
6463
'lcp.loadTime': expect.any(Number),
6564
'lcp.renderTime': expect.any(Number),
6665
'lcp.size': expect.any(Number),

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function trackLcpAsStandaloneSpan(): void {
4444
}
4545
sentSpan = true;
4646
if (pageloadSpanId) {
47-
sendStandaloneLcpSpan(standaloneLcpValue, standaloneLcpEntry, pageloadSpanId);
47+
_sendStandaloneLcpSpan(standaloneLcpValue, standaloneLcpEntry, pageloadSpanId);
4848
}
4949
cleanupLcpHandler();
5050
}
@@ -88,7 +88,14 @@ export function trackLcpAsStandaloneSpan(): void {
8888
}, 0);
8989
}
9090

91-
function sendStandaloneLcpSpan(lcpValue: number, entry: LargestContentfulPaint | undefined, pageloadSpanId: string) {
91+
/**
92+
* Exported only for testing!
93+
*/
94+
export function _sendStandaloneLcpSpan(
95+
lcpValue: number,
96+
entry: LargestContentfulPaint | undefined,
97+
pageloadSpanId: string,
98+
) {
9299
DEBUG_BUILD && logger.log(`Sending LCP span (${lcpValue})`);
93100

94101
const startTime = msToSec((browserPerformanceTimeOrigin() || 0) + (entry?.startTime || 0));

0 commit comments

Comments
 (0)