Skip to content

Missing LCP/CLS measurements #7341

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

Closed
3 tasks done
efarem opened this issue Mar 6, 2023 · 10 comments · Fixed by #7386
Closed
3 tasks done

Missing LCP/CLS measurements #7341

efarem opened this issue Mar 6, 2023 · 10 comments · Fixed by #7386
Assignees

Comments

@efarem
Copy link

efarem commented Mar 6, 2023

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using? If you use the CDN bundles, please specify the exact bundle (e.g. bundle.tracing.min.js) in your SDK setup.

@sentry/nextjs

SDK Version

7.40.0

Framework Version

No response

Link to Sentry event

No response

SDK Setup

No response

Steps to Reproduce

  • Use a BrowserTracing idleTimeout large enough to allow for the page to fully load
  • Do not interact with the page
  • Inspect the network request to Sentry ingress
  • Find the event ID
  • Query the event in Sentry discovery with id:{event_id}
  • Notice the lack of LCP/CLS

Expected Result

Expected to see LCP/CLS measurements.

  • This line shows the report() callback being called for LCP.
  • This line shows the report() callback being called for CLS.

Notice both of the above trigger the report function with no arguments, report() is a result of bindReporter and will only ever record a measurement if true is passed as the forceReport argument.

This has been present for LCP since the _reportAllChanges option was removed here.

CLS appears to only report onHidden.

Actual Result

No LCP or CLS measurements are ever recorded.

@efarem
Copy link
Author

efarem commented Mar 7, 2023

I realise that the web-vitals documentation suggests that reportAllChanges is "not needed (or recommended)" but in this case I believe it is. The problem being that in most cases Sentry has flushed the pageload transaction before LCP data has been collected at all -- regardless of whether the user has interacted.
I can imagine that in typical usage of the web-vitals library the report could -- perhaps even should -- happen immediately after page load has completed irrespective of user interaction.

I'd be happy to fix this myself as it'd help my team, any chance that someone from Sentry could take a look and guide me on a potential fix?

@AbhiPrasad
Copy link
Member

Hey @efarem thanks for writing in! This is simply a case where your transaction ends before LCP fires. To fix this, we recommend bumping the idleTimeout option. By default this is 1000 ms, so maybe something like 3000 ms fits better?

@efarem
Copy link
Author

efarem commented Mar 8, 2023

Hi @AbhiPrasad, I have idleTimeout set to 5000, LCP is never reported unless the user interacts click/keypress

@AbhiPrasad
Copy link
Member

Gotcha - maybe we need to record LCP on transaction finish then. Let me open a PR.

@AbhiPrasad
Copy link
Member

Yeah let's record LCP on transaction finish. This should hopefully help improve the number of LCP measurements here!

@efarem
Copy link
Author

efarem commented Mar 8, 2023

Thanks, this also happens with CLS. You only see CLS measurements when onHidden is called.

@AbhiPrasad
Copy link
Member

Thanks, this also happens with CLS. You only see CLS measurements when onHidden is called.

Good point, will address this with the PR as well!

@AbhiPrasad
Copy link
Member

Will cut a release with this change today!

@AbhiPrasad
Copy link
Member

@nadavgover
Copy link

@AbhiPrasad is there a fix required also for sentry/react?

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 a pull request may close this issue.

3 participants