fix(performance): Fix LCP not getting picked up on initial pageload transaction by setting reportAllChanges to true#12360
Merged
AbhiPrasad merged 2 commits intodevelopfrom Jun 6, 2024
Conversation
Contributor
size-limit report 📦
|
Contributor
|
I went through the same exercise with CLS before: #11934. Should we think about doing the same exact thing for FID too? |
Contributor
Author
Took a quick look at the FID code. Looks like FID is always reported: https://github.com/getsentry/sentry-javascript/blob/develop/packages/browser-utils/src/metrics/web-vitals/getFID.ts#L50 So |
AbhiPrasad
approved these changes
Jun 6, 2024
billyvg
pushed a commit
that referenced
this pull request
Jun 10, 2024
…ransaction by setting reportAllChanges to true (#12360) There's currently an issue where initial pageloads frequently do not capture LCP. This is because LCP is only reported when there is a user interaction on the page, or the user triggers a pagehide. Either of these events must happen within the initial pageload transaction boundary for the LCP value to be capture. Previously, in v7, we added custom code the the vendored LCP library to force report when closing the initial pageload transaction. This custom code was removed when we moved to v8. In this change, we are using the `reportAllChanges` option, so that any time a new LCP is detected, we add the LCP value to the initial pageload transaction, as long as the transaction has not closed yet. This solution is no worse than the previous solution in v7 because: - The risk of reporting an early LCP is the same because in either situation this is completely dependant on when the pageload transaction closes, which this PR does not change. - using `reportAllChanges`, we always go with the longest LCP recorded - We avoid introducing custom code to the vendored LCP library, and we use the intended `reportAllChanges`, so there's less risk of introducing a regression the next time we update the library. It's not a perfect solution, but I think it's reasonable to go with this until we come up with a better one (specifically to resolve the span/transaction boundary issue).
This was referenced Jul 3, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There's currently an issue where initial pageloads frequently do not capture LCP. This is because LCP is only reported when there is a user interaction on the page, or the user triggers a pagehide. Either of these events must happen within the initial pageload transaction boundary for the LCP value to be capture.
Previously, in v7, we added custom code the the vendored LCP library to force report when closing the initial pageload transaction. This custom code was removed when we moved to v8.
In this change, we are using the
reportAllChangesoption, so that any time a new LCP is detected, we add the LCP value to the initial pageload transaction, as long as the transaction has not closed yet.This solution is no worse than the previous solution in v7 because:
The risk of reporting an early LCP is the same because in either situation this is completely dependant on when the pageload transaction closes, which this PR does not change.
reportAllChanges, we always go with the longest LCP recordedWe avoid introducing custom code to the vendored LCP library, and we use the intended
reportAllChanges, so there's less risk of introducing a regression the next time we update the library.It's not a perfect solution, but I think it's reasonable to go with this until we come up with a better one (specifically to resolve the span/transaction boundary issue).