Skip to content

Commit aff12df

Browse files
refactor enums
1 parent a1df365 commit aff12df

File tree

1 file changed

+29
-36
lines changed
  • packages/tracing-internal/src/browser/metrics

1 file changed

+29
-36
lines changed

packages/tracing-internal/src/browser/metrics/index.ts

Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -201,40 +201,33 @@ function _trackFID(): () => void {
201201
});
202202
}
203203

204-
enum InteractionType {
205-
Click = 'click',
206-
Hover = 'hover',
207-
Drag = 'drag',
208-
Press = 'press',
209-
}
210-
211-
const INP_ENTRY_MAP: Record<string, InteractionType> = {
212-
click: InteractionType.Click,
213-
pointerdown: InteractionType.Click,
214-
pointerup: InteractionType.Click,
215-
mousedown: InteractionType.Click,
216-
mouseup: InteractionType.Click,
217-
touchstart: InteractionType.Click,
218-
touchend: InteractionType.Click,
219-
mouseover: InteractionType.Hover,
220-
mouseout: InteractionType.Hover,
221-
mouseenter: InteractionType.Hover,
222-
mouseleave: InteractionType.Hover,
223-
pointerover: InteractionType.Hover,
224-
pointerout: InteractionType.Hover,
225-
pointerenter: InteractionType.Hover,
226-
pointerleave: InteractionType.Hover,
227-
dragstart: InteractionType.Drag,
228-
dragend: InteractionType.Drag,
229-
drag: InteractionType.Drag,
230-
dragenter: InteractionType.Drag,
231-
dragleave: InteractionType.Drag,
232-
dragover: InteractionType.Drag,
233-
drop: InteractionType.Drag,
234-
keydown: InteractionType.Press,
235-
keyup: InteractionType.Press,
236-
keypress: InteractionType.Press,
237-
input: InteractionType.Press,
204+
const INP_ENTRY_MAP: Record<string, 'click' | 'hover' | 'drag' | 'press'> = {
205+
click: 'click',
206+
pointerdown: 'click',
207+
pointerup: 'click',
208+
mousedown: 'click',
209+
mouseup: 'click',
210+
touchstart: 'click',
211+
touchend: 'click',
212+
mouseover: 'hover',
213+
mouseout: 'hover',
214+
mouseenter: 'hover',
215+
mouseleave: 'hover',
216+
pointerover: 'hover',
217+
pointerout: 'hover',
218+
pointerenter: 'hover',
219+
pointerleave: 'hover',
220+
dragstart: 'drag',
221+
dragend: 'drag',
222+
drag: 'drag',
223+
dragenter: 'drag',
224+
dragleave: 'drag',
225+
dragover: 'drag',
226+
drop: 'drag',
227+
keydown: 'press',
228+
keyup: 'press',
229+
keypress: 'press',
230+
input: 'press',
238231
};
239232

240233
/** Starts tracking the Interaction to Next Paint on the current page. */
@@ -250,7 +243,7 @@ function _trackINP(interactionIdtoRouteNameMapping: InteractionRouteNameMapping)
250243
if (!entry || !client) {
251244
return;
252245
}
253-
const InteractionType = INP_ENTRY_MAP[entry.name];
246+
const interactionType = INP_ENTRY_MAP[entry.name];
254247
const options = client.getOptions();
255248
/** Build the INP span, create an envelope from the span, and then send the envelope */
256249
const startTime = msToSec((browserPerformanceTimeOrigin as number) + entry.startTime);
@@ -271,7 +264,7 @@ function _trackINP(interactionIdtoRouteNameMapping: InteractionRouteNameMapping)
271264
const span = new Span({
272265
startTimestamp: startTime,
273266
endTimestamp: startTime + duration,
274-
op: `ui.interaction.${InteractionType}`,
267+
op: `ui.interaction.${interactionType}`,
275268
name: htmlTreeAsString(entry.target),
276269
attributes: {
277270
release: options.release,

0 commit comments

Comments
 (0)