Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pick the first non-null target for INP attribution #421

Merged
merged 7 commits into from Jan 24, 2024
Merged

Conversation

rviscomi
Copy link
Member

Some pointer entries have a known bug causing them to have null event targets. In cases where there are mouse or click entries in the same interaction that do have non-null event targets, always prefer those.

This PR works around the bug by changing the eventTarget in INP attribution to use the first entry in the list having a non-null target, rather than always using the longest entry in the list, which may sometimes be a pointer entry.

Co-authored-by: Barry Pollard <barrypollard@google.com>
src/attribution/onINP.ts Outdated Show resolved Hide resolved
src/attribution/onINP.ts Outdated Show resolved Hide resolved
rviscomi and others added 2 commits January 23, 2024 14:15
Co-authored-by: Barry Pollard <barrypollard@google.com>
@tunetheweb
Copy link
Member

@mmocny can you review?

@rviscomi rviscomi requested a review from mmocny January 23, 2024 20:30
Copy link
Member

@mmocny mmocny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a strict improvement, thanks Rick.

@mmocny
Copy link
Member

mmocny commented Jan 23, 2024

This PR is similar to the strategy I've been advertising for measuring interaction targets.

--

There is also a different strategy that works around the other problem with event targets... that they can be removed and GC-ed by the time Event Timing is reported.

That gist is very rough, but gives you the idea: manage a map of event type + timestamp to whatever metadata you want, saved during event dispatch, then look it up from Event Timing.

src/attribution/onINP.ts Outdated Show resolved Hide resolved
src/attribution/onINP.ts Outdated Show resolved Hide resolved
rviscomi and others added 2 commits January 23, 2024 16:23
Co-authored-by: Philip Walton <philipwalton@users.noreply.github.com>
@philipwalton
Copy link
Member

I added a test to cover the logic Rick added. It fails when run against main but passed when run on this branch.

@rviscomi rviscomi merged commit 92ea1e5 into main Jan 24, 2024
4 checks passed
@rviscomi rviscomi deleted the rviscomi-patch-1 branch January 24, 2024 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants