Skip to content

Commit 7c3abfc

Browse files
committed
debug: log LCP handler calls in CI (temporary)
1 parent 2ac1063 commit 7c3abfc

2 files changed

Lines changed: 22 additions & 6 deletions

File tree

  • dev-packages/browser-integration-tests/suites/tracing/metrics/handlers-lcp
Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
import { addLcpInstrumentationHandler } from '@sentry/browser-utils';
22

3-
addLcpInstrumentationHandler(({ metric }) => {
3+
function describe(label, metric) {
44
const entry = metric.entries[metric.entries.length - 1];
5-
window._LCP = entry.size;
5+
console.log(
6+
`LCP ${label} size=${entry.size} el=${entry.element && entry.element.tagName} start=${entry.startTime} n=${metric.entries.length} value=${metric.value}`,
7+
);
8+
return entry.size;
9+
}
10+
11+
addLcpInstrumentationHandler(({ metric }) => {
12+
window._LCP = describe('h1', metric);
613
});
714

815
addLcpInstrumentationHandler(({ metric }) => {
9-
const entry = metric.entries[metric.entries.length - 1];
10-
window._LCP2 = entry.size;
16+
window._LCP2 = describe('h2', metric);
1117
});
1218

1319
window.ADD_HANDLER = () => {
1420
addLcpInstrumentationHandler(({ metric }) => {
15-
const entry = metric.entries[metric.entries.length - 1];
16-
window._LCP3 = entry.size;
21+
window._LCP3 = describe('h3', metric);
1722
});
1823
};

‎dev-packages/browser-integration-tests/suites/tracing/metrics/handlers-lcp/test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,24 @@ sentryTest(
2323
route.fulfill({ path: `${__dirname}/assets/sentry-logo-600x179.png` }),
2424
);
2525

26+
page.on('console', message => console.log('[browser]', message.text()));
27+
2628
const url = await getLocalTestUrl({ testDir: __dirname });
2729

2830
const lcpPromise = waitForStreamedSpan(page, span => getSpanOp(span) === 'ui.webvital.lcp');
2931
await page.goto(url);
3032
await waitForLcpCandidate(page, 'img');
3133
await page.locator('button').click();
3234
const lcpSpan = await lcpPromise;
35+
console.log(
36+
'[debug] entries',
37+
await page.evaluate(
38+
"JSON.stringify(performance.getEntriesByType('largest-contentful-paint').map(e => ({ size: e.size, el: e.element && e.element.tagName, start: e.startTime })))",
39+
),
40+
'LCP',
41+
await page.evaluate('window._LCP'),
42+
await page.evaluate('window._LCP2'),
43+
);
3344

3445
expect(lcpSpan.attributes[BROWSER_WEB_VITAL_LCP_VALUE]?.value).toBeGreaterThan(0);
3546
expect(lcpSpan.attributes[BROWSER_WEB_VITAL_LCP_ELEMENT]).toEqual({ type: 'string', value: 'body > img' });

0 commit comments

Comments
 (0)