Skip to content

Commit a0bfb46

Browse files
committed
cleanup
1 parent b307949 commit a0bfb46

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME,
1010
SEMANTIC_ATTRIBUTE_SENTRY_OP,
1111
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
12-
spanToJSON,
1312
spanToStreamedSpanJSON,
1413
startInactiveSpan,
1514
timestampInSeconds,
@@ -23,6 +22,25 @@ import type { WebVitalReportEvent } from './utils';
2322
import { getBrowserPerformanceAPI, listenForWebVitalReportEvents, msToSec, supportsWebVital } from './utils';
2423
import type { PerformanceEventTiming } from './instrument';
2524

25+
// Locally-defined interfaces to avoid leaking bare global type references into the
26+
// generated .d.ts. The `declare global` augmentations in web-vitals/types.ts make these
27+
// available during this package's compilation but are NOT carried to consumers.
28+
// This mirrors the pattern used for PerformanceEventTiming in instrument.ts.
29+
export interface LayoutShift extends PerformanceEntry {
30+
value: number;
31+
sources: Array<{ node: Node | null }>;
32+
hadRecentInput: boolean;
33+
}
34+
35+
export interface LargestContentfulPaint extends PerformanceEntry {
36+
readonly renderTime: DOMHighResTimeStamp;
37+
readonly loadTime: DOMHighResTimeStamp;
38+
readonly size: number;
39+
readonly id: string;
40+
readonly url: string;
41+
readonly element: Element | null;
42+
}
43+
2644
interface WebVitalSpanOptions {
2745
name: string;
2846
op: string;
@@ -268,7 +286,9 @@ export function _sendInpSpan(inpValue: number, entry: PerformanceEventTiming): v
268286
const rootSpan = activeSpan ? getRootSpan(activeSpan) : undefined;
269287

270288
const spanToUse = cachedContext?.span || rootSpan;
271-
const routeName = spanToUse ? spanToJSON(spanToUse).description : getCurrentScope().getScopeData().transactionName;
289+
const routeName = spanToUse
290+
? spanToStreamedSpanJSON(spanToUse).name
291+
: getCurrentScope().getScopeData().transactionName;
272292
const name = cachedContext?.elementName || htmlTreeAsString(entry.target);
273293

274294
_emitWebVitalSpan({

0 commit comments

Comments
 (0)