question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Web vitals (LCP, CLS, FID) not sent in most case with load transaction

See original GitHub issue

Package + Version

  • @sentry/integrations 6.10.0
  • @sentry/tracing 6.10.0
  • @sentry/vue 6.10.0

Description

Summary

In our project, using vuejs, we don’t receive the web vitals LCP, CLS and FID in most case.

image

image

Investigation

We have enabled the debug and seems that thoses webvitals are added to the transaction only when the user click, use the keyboard or switch tab for instance. So the transaction in most case is already sent to the sentry server. (unless we click quickly after the page is loaded)

packages/tracing/src/browser/web-vitals/getLCP.ts:76

    ['keydown', 'click'].forEach(type => {
      addEventListener(type, stopListening, { once: true, capture: true });
    });

    onHidden(stopListening, true);
Debug logs

Sentry Logger [Log]: Integration installed: InboundFilters logger.js?f0b6:31 Sentry Logger [Log]: Integration installed: FunctionToString logger.js?f0b6:31 Sentry Logger [Log]: Integration installed: TryCatch logger.js?f0b6:31 Sentry Logger [Log]: Global Handler attached: onerror logger.js?f0b6:31 Sentry Logger [Log]: Global Handler attached: onunhandledrejection logger.js?f0b6:31 Sentry Logger [Log]: Integration installed: GlobalHandlers logger.js?f0b6:31 Sentry Logger [Log]: Integration installed: LinkedErrors logger.js?f0b6:31 Sentry Logger [Log]: Integration installed: UserAgent logger.js?f0b6:31 Sentry Logger [Log]: Integration installed: Breadcrumbs logger.js?f0b6:31 Sentry Logger [Log]: Integration installed: CaptureConsole logger.js?f0b6:31 Sentry Logger [Log]: Integration installed: Dedupe logger.js?f0b6:44 Sentry Logger [Warn]: [Tracing] You need to define tracingOrigins in the options. logger.js?f0b6:31 Sentry Logger [Log]: [Tracing] Starting pageload transaction on scope logger.js?f0b6:31 Sentry Logger [Log]: Setting idle transaction on scope. Span ID: 956e1442589f33c1 logger.js?f0b6:31 Sentry Logger [Log]: [Tracing] starting pageload transaction - home logger.js?f0b6:31 Sentry Logger [Log]: Starting heartbeat logger.js?f0b6:31 Sentry Logger [Log]: pinging Heartbeat -> current counter: 0 logger.js?f0b6:31 Sentry Logger [Log]: Integration installed: BrowserTracing logger.js?f0b6:31 Sentry Logger [Log]: [Tracing] pushActivity: 9f6d4c3eeddc52a7 logger.js?f0b6:31 Sentry Logger [Log]: [Tracing] new activities count 1 logger.js?f0b6:31 Sentry Logger [Log]: [Tracing] pushActivity: a25303d5cc71b1de logger.js?f0b6:31 Sentry Logger [Log]: [Tracing] new activities count 2 logger.js?f0b6:31 Sentry Logger [Log]: [Tracing] popActivity a25303d5cc71b1de logger.js?f0b6:31 Sentry Logger [Log]: [Tracing] new activities count 1 logger.js?f0b6:31 Sentry Logger [Log]: [Tracing] pushActivity: a62cca7658533ea9 logger.js?f0b6:31 Sentry Logger [Log]: [Tracing] new activities count 2 logger.js?f0b6:31 Sentry Logger [Log]: [Tracing] popActivity a62cca7658533ea9 logger.js?f0b6:31 Sentry Logger [Log]: [Tracing] new activities count 1 logger.js?f0b6:31 Sentry Logger [Log]: [Tracing] Finishing loadData transaction: loadData - home. logger.js?f0b6:31 Sentry Logger [Log]: [Tracing] popActivity 9f6d4c3eeddc52a7 logger.js?f0b6:31 Sentry Logger [Log]: [Tracing] new activities count 0 logger.js?f0b6:31 Sentry Logger [Log]: [Tracing] finishing IdleTransaction 2021-07-23T15:27:46.636Z pageload logger.js?f0b6:31 Sentry Logger [Log]: [Tracing] Adding & adjusting spans using Performance API logger.js?f0b6:31 Sentry Logger [Log]: [Measurements] Adding FP logger.js?f0b6:31 Sentry Logger [Log]: [Measurements] Adding FCP logger.js?f0b6:31 Sentry Logger [Log]: [Measurements] Adding TTFB logger.js?f0b6:31 Sentry Logger [Log]: [Measurements] Normalized fcp from 1937.1000000014901 to 1925.6000518798828 (-11.499948121607304) logger.js?f0b6:31 Sentry Logger [Log]: [Measurements] Normalized fp from 1937.1000000014901 to 1925.6000518798828 (-11.499948121607304) logger.js?f0b6:31 Sentry Logger [Log]: [Tracing] flushing IdleTransaction logger.js?f0b6:31 Sentry Logger [Log]: [Measurements] Adding measurements to transaction { “fp”: { “value”: 1925.6000518798828 }, “mark.fp”: { “value”: 1627054063.8981 }, “fcp”: { “value”: 1925.6000518798828 }, “mark.fcp”: { “value”: 1627054063.8981 }, “connection.rtt”: { “value”: 50 }, “connection.downlink”: { “value”: 8.2 }, “ttfb”: { “value”: 10.900020599365234 }, “ttfb.requestTime”: { “value”: 4.400014877319336 } } logger.js?f0b6:31 Sentry Logger [Log]: [Tracing] Finishing pageload transaction: home. logger.js?f0b6:31 Sentry Logger [Log]: [Measurements] Adding FID logger.js?f0b6:31 Sentry Logger [Log]: [Measurements] Adding LCP

Hypothetical solution

I’m not sure this is the right call, however I’ve tried to add “true” in :

  • getLCP(function(){}, true) in _trackLCP
  • getFID(function(){}, true) in _trackFID
  • getCLS(function(){}, true) in _trackCLS

It does seems to solve our issue. The metrics are attached (multiple time on js, is that an issue ??) to the transaction and sent with the loadpage transation.

An other solution could be to send the metrics after and update the transaction server side ?

Also, may be, it is possible that this is a configuration issue on our part.

Thanks a lot !

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:19 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
AbhiPrasadcommented, Aug 31, 2021

Hey @ymenard-aramis, thanks for your patience. We recently cut a beta, could you give it a try to see if your web vitals collections improve? @sentry/tracing @ 6.12.0-beta.2.

Then in your SDK init, please opt in to the new option:

Sentry.init({
  integrations: [
    // other options
    new Integrations.BrowserTracing({
      _metricOptions: {
        _reportAllChanges: true,
      },
    });
  ],
});
1reaction
AbhiPrasadcommented, Nov 3, 2021

It’s still under a flag as the instructions here: https://github.com/getsentry/sentry-javascript/issues/3833#issuecomment-909652059, but should work on latest release 6.14.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Core Web Vitals report - Search Console Help - Google Support
The Core Web Vitals report shows URL performance grouped by status (Poor, Need improvement, Good), metric type (CLS, FID, LCP), and URL group...
Read more >
Learn about the three Core Web Vitals: LCP, FID & CLS - Yoast
The three pillars of page experience. For now, the three pillars of page experience are: Loading performance (how fast does stuff appear on...
Read more >
Track Core Web Vitals In GA4 With Google Tag Manager
A guide for measuring Core Web Vitals (LCP, FID, and CLS) in Google Analytics 4 using Google Tag Manager and a custom template...
Read more >
Core Web Vitals - New Metrics for User Experience - Atatus
Core web vitals shows how your web page is performing. It's your fastest way to verify your SEO, identify opportunities, and track progress....
Read more >
What the "Heck" are Core Web Vitals?: LCP, FID & CLS
The Google Core Web Vitals constitute three new page experience signals, namely Largest Contentful Paint (LCP), First Input Delay (FID), and Cumulative Layout ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found