Skip to content

Commit 7a869b8

Browse files
committed
small refs
1 parent bbb947b commit 7a869b8

File tree

1 file changed

+23
-29
lines changed

1 file changed

+23
-29
lines changed

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

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -462,23 +462,35 @@ function _addNavigationSpans(span: Span, entry: PerformanceNavigationTiming, tim
462462
_addRequest(span, entry, timeOrigin);
463463
}
464464

465+
type StartEventName =
466+
| 'secureConnection'
467+
| 'fetch'
468+
| 'domainLookup'
469+
| 'unloadEvent'
470+
| 'redirect'
471+
| 'connect'
472+
| 'domContentLoadedEvent'
473+
| 'loadEvent';
474+
475+
type EndEventName =
476+
| 'connectEnd'
477+
| 'domainLookupStart'
478+
| 'domainLookupEnd'
479+
| 'unloadEventEnd'
480+
| 'redirectEnd'
481+
| 'connectEnd'
482+
| 'domContentLoadedEventEnd'
483+
| 'loadEventEnd';
484+
465485
/** Create performance navigation related spans */
466486
function _addPerformanceNavigationTiming(
467487
span: Span,
468488
entry: PerformanceNavigationTiming,
469-
event:
470-
| 'secureConnection'
471-
| 'fetch'
472-
| 'domainLookup'
473-
| 'unloadEvent'
474-
| 'redirect'
475-
| 'connect'
476-
| 'domContentLoadedEvent'
477-
| 'loadEvent',
489+
event: StartEventName,
478490
timeOrigin: number,
479491
name?: string,
480492
): void {
481-
const eventEnd = getEndPropertyNameForNavigationTiming(event) satisfies keyof PerformanceNavigationTiming;
493+
const eventEnd = _getEndPropertyNameForNavigationTiming(event) satisfies keyof PerformanceNavigationTiming;
482494
const end = entry[eventEnd];
483495
const start = entry[`${event}Start`];
484496
if (!start || !end) {
@@ -493,25 +505,7 @@ function _addPerformanceNavigationTiming(
493505
});
494506
}
495507

496-
function getEndPropertyNameForNavigationTiming(
497-
event:
498-
| 'secureConnection'
499-
| 'fetch'
500-
| 'domainLookup'
501-
| 'unloadEvent'
502-
| 'redirect'
503-
| 'connect'
504-
| 'domContentLoadedEvent'
505-
| 'loadEvent',
506-
):
507-
| 'connectEnd'
508-
| 'domainLookupStart'
509-
| 'domainLookupEnd'
510-
| 'unloadEventEnd'
511-
| 'redirectEnd'
512-
| 'connectEnd'
513-
| 'domContentLoadedEventEnd'
514-
| 'loadEventEnd' {
508+
function _getEndPropertyNameForNavigationTiming(event: StartEventName): EndEventName {
515509
if (event === 'secureConnection') {
516510
return 'connectEnd';
517511
}

0 commit comments

Comments
 (0)