Skip to content

Commit

Permalink
🔇 remove pointerup_delay info for #1958
Browse files Browse the repository at this point in the history
  • Loading branch information
BenoitZugmeyer committed Feb 7, 2023
1 parent 54c700a commit 6af98d5
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ describe('actionCollection', () => {
x: 1,
y: 2,
},
pointer_up_delay: undefined,
},
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ function processAction(
action: {
target: action.target,
position: action.position,
pointer_up_delay: action.pointerUpDelay,
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ describe('listenActionEvents', () => {
expect(actionEventsHooks.onStartEvent).toHaveBeenCalledOnceWith(
{},
jasmine.objectContaining({ type: 'pointerup' }),
jasmine.any(Function),
jasmine.any(Function)
)
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { TimeStamp } from '@datadog/browser-core'
import { addEventListener, DOM_EVENT, isExperimentalFeatureEnabled, timeStampNow } from '@datadog/browser-core'
import { addEventListener, DOM_EVENT } from '@datadog/browser-core'

export type MouseEventOnElement = PointerEvent & { target: Element }

Expand All @@ -9,12 +8,7 @@ export interface UserActivity {
}
export interface ActionEventsHooks<ClickContext> {
onPointerDown: (event: MouseEventOnElement) => ClickContext | undefined
onStartEvent: (
context: ClickContext,
event: MouseEventOnElement,
getUserActivity: () => UserActivity,
getClickEventTimeStamp: () => TimeStamp | undefined
) => void
onStartEvent: (context: ClickContext, event: MouseEventOnElement, getUserActivity: () => UserActivity) => void
}

export function listenActionEvents<ClickContext>({ onPointerDown, onStartEvent }: ActionEventsHooks<ClickContext>) {
Expand Down Expand Up @@ -60,24 +54,8 @@ export function listenActionEvents<ClickContext>({ onPointerDown, onStartEvent }
if (isValidPointerEvent(startEvent) && clickContext) {
// Use a scoped variable to make sure the value is not changed by other clicks
const localUserActivity = userActivity
let clickEventTimeStamp: TimeStamp | undefined
onStartEvent(
clickContext,
startEvent,
() => localUserActivity,
() => clickEventTimeStamp
)
onStartEvent(clickContext, startEvent, () => localUserActivity)
clickContext = undefined
if (isExperimentalFeatureEnabled('dead_click_fixes')) {
addEventListener(
window,
DOM_EVENT.CLICK,
() => {
clickEventTimeStamp = timeStampNow()
},
{ capture: true, once: true }
)
}
}
},
{ capture: true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ describe('trackClickActions', () => {
target: undefined,
position: undefined,
events: [domEvent],
pointerUpDelay: undefined,
},
])
})
Expand Down Expand Up @@ -459,17 +458,6 @@ describe('trackClickActions', () => {
expect(events.length).toBe(1)
expect(events[0].duration).toBe(0 as Duration)
})

it('reports the delay between pointerup and click event', () => {
const { clock } = setupBuilder.build()

const pointerUpActivityDelay = 5 as Duration
emulateClick({ activity: { on: 'pointerup', delay: pointerUpActivityDelay } })

clock.tick(EXPIRE_DELAY)
expect(events.length).toBe(1)
expect(events[0].pointerUpDelay).toBe(pointerUpActivityDelay)
})
})

it('does not consider a click with activity happening on pointerup as a dead click', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export interface ClickAction {
event: MouseEventOnElement
frustrationTypes: FrustrationType[]
events: Event[]
pointerUpDelay?: Duration
}

export interface ActionContexts {
Expand Down Expand Up @@ -85,12 +84,7 @@ export function trackClickActions(
}>({
onPointerDown: (pointerDownEvent) =>
processPointerDown(configuration, lifeCycle, domMutationObservable, history, pointerDownEvent),
onStartEvent: (
{ clickActionBase, hadActivityOnPointerDown },
startEvent,
getUserActivity,
getClickEventTimeStamp
) =>
onStartEvent: ({ clickActionBase, hadActivityOnPointerDown }, startEvent, getUserActivity) =>
startClickAction(
configuration,
lifeCycle,
Expand All @@ -101,8 +95,7 @@ export function trackClickActions(
clickActionBase,
startEvent,
getUserActivity,
hadActivityOnPointerDown,
getClickEventTimeStamp
hadActivityOnPointerDown
),
})

Expand Down Expand Up @@ -185,10 +178,9 @@ function startClickAction(
clickActionBase: ClickActionBase,
startEvent: MouseEventOnElement,
getUserActivity: () => UserActivity,
hadActivityOnPointerDown: () => boolean,
getClickEventTimeStamp: () => TimeStamp | undefined
hadActivityOnPointerDown: () => boolean
) {
const click = newClick(lifeCycle, history, getUserActivity, getClickEventTimeStamp, clickActionBase, startEvent)
const click = newClick(lifeCycle, history, getUserActivity, clickActionBase, startEvent)

if (configuration.trackFrustrations) {
appendClickToClickChain(click)
Expand Down Expand Up @@ -289,7 +281,6 @@ function newClick(
lifeCycle: LifeCycle,
history: ClickActionIdHistory,
getUserActivity: () => UserActivity,
getClickEventTimeStamp: () => TimeStamp | undefined,
clickActionBase: ClickActionBase,
startEvent: MouseEventOnElement
) {
Expand Down Expand Up @@ -341,7 +332,7 @@ function newClick(

isStopped: () => status === ClickStatus.STOPPED || status === ClickStatus.FINALIZED,

clone: () => newClick(lifeCycle, history, getUserActivity, getClickEventTimeStamp, clickActionBase, startEvent),
clone: () => newClick(lifeCycle, history, getUserActivity, clickActionBase, startEvent),

validate: (domEvents?: Event[]) => {
stop()
Expand All @@ -350,7 +341,6 @@ function newClick(
}

const { resourceCount, errorCount, longTaskCount } = eventCountsSubscription.eventCounts
const clickEventTimeStamp = getClickEventTimeStamp()
const clickAction: ClickAction = assign(
{
type: ActionType.CLICK as const,
Expand All @@ -365,7 +355,6 @@ function newClick(
},
events: domEvents ?? [startEvent],
event: startEvent,
pointerUpDelay: clickEventTimeStamp && elapsed(startClocks.timeStamp, clickEventTimeStamp),
},
clickActionBase
)
Expand Down

0 comments on commit 6af98d5

Please sign in to comment.