Skip to content

Commit 6406110

Browse files
committed
debug in package
1 parent 563a89b commit 6406110

File tree

2 files changed

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

2 files changed

+9
-11
lines changed

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

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,15 @@ sentryTest('should capture a LCP vital with element details.', async ({ browserN
1515
});
1616

1717
const url = await getLocalTestPath({ testDir: __dirname });
18-
const [eventData] = await Promise.all([
19-
getFirstSentryEnvelopeRequest<Event>(page),
20-
page.goto(url),
21-
// Clicking the button before image loads will result in the button being the LCP
22-
page.waitForFunction(() => {
23-
const images = Array.from(document.querySelectorAll('img'));
24-
return images.every(img => img.complete);
25-
}),
26-
]);
18+
const [eventData] = await Promise.all([getFirstSentryEnvelopeRequest<Event>(page), page.goto(url)]);
19+
20+
// Clicking the button before image loads will result in the button being the LCP
21+
await page.waitForFunction(() => {
22+
const images = Array.from(document.querySelectorAll('img'));
23+
return images.every(img => img.complete);
24+
}),
25+
expect(eventData.contexts?.trace?.data?.['lcp.element']).toBe('body > img');
2726

28-
console.log(eventData.contexts?.trace);
29-
expect(eventData.contexts?.trace?.data?.['lcp.element']).toBe('body > img');
3027
await page.locator('button').click();
3128

3229
expect(eventData.measurements).toBeDefined();

packages/browser-utils/src/metrics/web-vitals/getLCP.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export const onLCP = (onReport: LCPReportCallback, opts: ReportOpts = {}) => {
6060
// clamped at 0.
6161
metric.value = Math.max(lastEntry.startTime - getActivationStart(), 0);
6262
metric.entries = [lastEntry];
63+
console.log(lastEntry);
6364
report();
6465
}
6566
}

0 commit comments

Comments
 (0)