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

Calling onINP() multiple times duplicates attribution entry data #582

Open
philipwalton opened this issue Dec 20, 2024 · 0 comments
Open

Comments

@philipwalton
Copy link
Member

While playing around with a potential implementation for the idea proposed in #562 (comment), I discovered a bug that occurs if the attribution version of onINP() gets called multiple times on the same page.

While not a common use case, there may be reasons why a user might want to do this (e.g. to allow for multiple configurations to run simultaneously), and currently it does not work because the when onINP() is called twice (or more times), multiple PerformanceObserver objects are created and the entryPreProcessingCallbacks functions—which are effectively global—get called for both sets of dispatched entries.

To prevent this, we could scope the INP attribution logic to within the closure of the onINP() function, so multiple calls to onINP() get their own set of entryPreProcessingCallbacks functions.

Something like this would also be necessary if we wanted to allow users to pass in custom selector generation logic (as discussed in #562 (comment)) since in that case the entryPreProcessingCallbacks functions would need access to the opts object passed to onINP().

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

No branches or pull requests

1 participant