Skip to content

Commit

Permalink
chore: improve readability existing interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
devcorpio committed Dec 21, 2023
1 parent 71b0f89 commit 967d718
Showing 1 changed file with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,19 +172,14 @@ function storeUserInteraction(entry) {
* Please see the EventTiming spec for more details about
* the algorithm: https://www.w3.org/TR/event-timing/#sec-computing-interactionid
*/
let foundIndex = -1
let i = 0
while (i < inpState.longestInteractions.length && foundIndex === -1) {
if (inpState.longestInteractions[i].id === entry.interactionId) {
foundIndex = i
}
i++
}

if (foundIndex >= 0) {
const filteredInteraction = inpState.longestInteractions.filter(
interaction => interaction.id === entry.interactionId
)
if (filteredInteraction.length > 0) {
// Override existing interaction
inpState.longestInteractions[foundIndex].duration = Math.max(
inpState.longestInteractions[foundIndex].duration,
const foundInteraction = filteredInteraction[0]
foundInteraction.duration = Math.max(
foundInteraction.duration,
entry.duration
)
} else {
Expand Down

0 comments on commit 967d718

Please sign in to comment.