Skip to content

Commit aa05123

Browse files
author
John Doe
committed
refactor: impl feedback
1 parent 79368e4 commit aa05123

File tree

2 files changed

+5
-21
lines changed

2 files changed

+5
-21
lines changed

packages/utils/src/lib/user-timing-extensibility-api-utils.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,12 @@ export function mergePropertiesWithOverwrite(
4040
* @param options - Marker options excluding dataType
4141
* @returns Complete marker payload
4242
* @example
43-
* ```ts
4443
* const payload = markerPayload({
4544
* color: 'primary',
4645
* tooltipText: 'User action completed',
4746
* properties: [['action', 'save'], ['duration', 150]]
4847
* });
4948
* // { dataType: 'marker', color: 'primary', tooltipText: 'User action completed', ... }
50-
* ```
5149
*/
5250
export function markerPayload(options?: Omit<MarkerPayload, 'dataType'>) {
5351
return {
@@ -61,7 +59,6 @@ export function markerPayload(options?: Omit<MarkerPayload, 'dataType'>) {
6159
* @param options - Track entry options excluding dataType
6260
* @returns Complete track entry payload
6361
* @example
64-
* ```ts
6562
* const payload = trackEntryPayload({
6663
* track: 'user-interactions',
6764
* trackGroup: 'frontend',
@@ -70,7 +67,6 @@ export function markerPayload(options?: Omit<MarkerPayload, 'dataType'>) {
7067
* properties: [['element', 'save-button'], ['response-time', 200]]
7168
* });
7269
* // { dataType: 'track-entry', track: 'user-interactions', ... }
73-
* ```
7470
*/
7571
export function trackEntryPayload(
7672
options: Omit<TrackEntryPayload, 'dataType'>,
@@ -205,7 +201,6 @@ export function errorToMarkerPayload(
205201
* @param devtools - DevTools payload or null
206202
* @returns Performance API options with DevTools detail
207203
* @example
208-
* ```ts
209204
* const marker = markerPayload({ color: 'primary', tooltipText: 'Start' });
210205
* performance.mark('start', asOptions(marker));
211206
*
@@ -215,7 +210,6 @@ export function errorToMarkerPayload(
215210
* end: 'end',
216211
* ...asOptions(trackEntry)
217212
* });
218-
* ```
219213
*/
220214
export function asOptions<T extends MarkerPayload>(
221215
devtools?: T | null,
@@ -307,13 +301,11 @@ type MergeResult<P extends readonly unknown[]> = P extends readonly [
307301
* @param parts - Array of payloads where first is complete and rest are partial
308302
* @returns Merged payload with combined properties
309303
* @example
310-
* ```ts
311304
* const payload = mergeDevtoolsPayload(
312305
* trackEntryPayload({ track: 'user-interactions', color: 'secondary' }),
313306
* { color: 'primary', tooltipText: 'User action completed' },
314307
* );
315308
* // { track: 'user-interactions', color: 'primary', tooltipText: 'User action completed' }
316-
* ```
317309
*/
318310
export function mergeDevtoolsPayload<
319311
const P extends readonly [
@@ -420,7 +412,6 @@ export type MeasureCtxOptions = ActionTrackEntryPayload & {
420412
* @param cfg - Configuration defining default track properties, optional prefix, and global error handling
421413
* @returns Function that creates measurement controllers for specific events
422414
* @example
423-
* ```ts
424415
* // Basic usage with defaults
425416
* const measure = measureCtx({
426417
* track: 'api-calls',
@@ -432,9 +423,7 @@ export type MeasureCtxOptions = ActionTrackEntryPayload & {
432423
* start(); // Creates "fetch-user:start" mark
433424
* // ... async operation ...
434425
* success({ userCount: 42 }); // Creates "fetch-user:end" mark and "fetch-user" measure
435-
* ```
436426
* @example
437-
* ```ts
438427
* // Advanced usage with callbacks and error handling
439428
* const measure = measureCtx({
440429
* track: 'user-actions',
@@ -461,9 +450,7 @@ export type MeasureCtxOptions = ActionTrackEntryPayload & {
461450
* } catch (err) {
462451
* error(err); // Applies both global and specific error metadata
463452
* }
464-
* ```
465453
* @example
466-
* ```ts
467454
* // onetime config of defaults
468455
* const apiMeasure = measureCtx({
469456
* prefix: 'http:',
@@ -480,8 +467,6 @@ export type MeasureCtxOptions = ActionTrackEntryPayload & {
480467
* } catch(err) {
481468
* error(err)
482469
* }
483-
*
484-
* ```
485470
* @returns Object with measurement control methods:
486471
* - `start()`: Marks the beginning of the measurement
487472
* - `success(result?)`: Completes successful measurement with optional result metadata

packages/utils/src/lib/user-timing-extensibility-api-utils.unit.test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
trackEntryPayload,
2121
} from './user-timing-extensibility-api-utils.js';
2222
import type {
23+
ActionTrackEntryPayload,
2324
EntryMeta,
2425
TrackEntryPayload,
2526
TrackMeta,
@@ -362,10 +363,6 @@ describe('getNames', () => {
362363
});
363364

364365
describe('mergeDevtoolsPayload', () => {
365-
it('should return empty object when no payloads provided', () => {
366-
expect(mergeDevtoolsPayload()).toStrictEqual({});
367-
});
368-
369366
it('should return the same payload when single payload provided', () => {
370367
const payload: TrackEntryPayload = {
371368
dataType: 'track-entry',
@@ -403,7 +400,8 @@ describe('mergeDevtoolsPayload', () => {
403400
});
404401

405402
it('should merge multiple property payloads with overwrite behavior', () => {
406-
const payload1: EntryMeta = {
403+
const payload1: ActionTrackEntryPayload = {
404+
track: 'Test Track',
407405
properties: [['key1', 'value1']],
408406
};
409407
const payload2: EntryMeta = {
@@ -414,6 +412,7 @@ describe('mergeDevtoolsPayload', () => {
414412
};
415413

416414
expect(mergeDevtoolsPayload(payload1, payload2)).toStrictEqual({
415+
track: 'Test Track',
417416
properties: [
418417
['key1', 'overwrite'],
419418
['key2', 'value2'],
@@ -438,7 +437,7 @@ describe('mergeDevtoolsPayload', () => {
438437

439438
describe('setupTracks', () => {
440439
it('should create track definitions with defaults as base', () => {
441-
const defaults: TrackEntryPayload = {
440+
const defaults: ActionTrackEntryPayload = {
442441
track: 'Main Track',
443442
color: 'primary',
444443
trackGroup: 'My Group',

0 commit comments

Comments
 (0)