Skip to content

Commit fea5745

Browse files
committed
refactor: use ActionTrackConfigs type alias instead of inline Record type
- Import ActionTrackConfigs from user-timing-extensibility-api-utils - Replace Record<string, ActionTrackEntryPayload> with ActionTrackConfigs in type constraints - Improves code consistency and reduces repetition
1 parent ea7f955 commit fea5745

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

packages/utils/src/lib/profiler/profiler.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import process from 'node:process';
22
import { isEnvVarEnabled } from '../env.js';
33
import {
4+
type ActionTrackConfigs,
45
type MeasureCtxOptions,
56
type MeasureOptions,
67
asOptions,
@@ -20,7 +21,7 @@ import { PROFILER_ENABLED } from './constants.js';
2021
*
2122
* @template T - Record type defining available track names and their configurations
2223
*/
23-
type ProfilerMeasureOptions<T extends Record<string, ActionTrackEntryPayload>> =
24+
type ProfilerMeasureOptions<T extends ActionTrackConfigs> =
2425
MeasureCtxOptions & {
2526
/** Custom track configurations that will be merged with default settings */
2627
tracks?: Record<keyof T, Partial<ActionTrackEntryPayload>>;
@@ -48,10 +49,7 @@ export type MarkerOptions = EntryMeta & { color?: DevToolsColor };
4849
* @property tracks - Custom track configurations merged with defaults
4950
*/
5051
export type ProfilerOptions<
51-
T extends Record<string, ActionTrackEntryPayload> = Record<
52-
string,
53-
ActionTrackEntryPayload
54-
>,
52+
T extends ActionTrackConfigs = Record<string, ActionTrackEntryPayload>,
5553
> = ProfilerMeasureOptions<T>;
5654

5755
/**
@@ -61,7 +59,7 @@ export type ProfilerOptions<
6159
* It supports both synchronous and asynchronous operations with all having smart defaults for custom track data.
6260
*
6361
*/
64-
export class Profiler<T extends Record<string, ActionTrackEntryPayload>> {
62+
export class Profiler<T extends ActionTrackConfigs> {
6563
#enabled: boolean;
6664
readonly #defaults: ActionTrackEntryPayload;
6765
readonly tracks: Record<keyof T, ActionTrackEntryPayload> | undefined;

0 commit comments

Comments
 (0)