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

Add all Web Vitals to Replay Breadcrumbs #11639

Closed
5 of 6 tasks
Tracked by #69881
jas-kas opened this issue Apr 16, 2024 · 1 comment · Fixed by #12296
Closed
5 of 6 tasks
Tracked by #69881

Add all Web Vitals to Replay Breadcrumbs #11639

jas-kas opened this issue Apr 16, 2024 · 1 comment · Fixed by #12296
Assignees
Labels
Feature: Spans Package: replay Issues related to the Sentry Replay SDK

Comments

@jas-kas
Copy link
Member

jas-kas commented Apr 16, 2024

Summary from Abhi:

In my opinion short term I think we can just add more breadcrumbs for CLS, FCP like we do with LCP (we should dedupe so this is created regardless of using performance or replay). I assume CLS is the most important, so perhaps we can focus on that and skip FCP considering idk how useful FCP is for a replay where you can already visually see how page is being painted.

Update

export function setupPerformanceObserver(replay: ReplayContainer): () => void {
to add CLS, FCP, INP.

these handlers are exposed in browser-utils

/**
* Add a callback that will be triggered when a CLS metric is available.
* Returns a cleanup callback which can be called to remove the instrumentation handler.
*
* Pass `stopOnCallback = true` to stop listening for CLS when the cleanup callback is called.
* This will lead to the CLS being finalized and frozen.
*/
export function addClsInstrumentationHandler(
callback: (data: { metric: Metric }) => void,
stopOnCallback = false,
): CleanupHandlerCallback {
return addMetricObserver('cls', callback, instrumentCls, _previousCls, stopOnCallback);
}
/**
* Add a callback that will be triggered when a LCP metric is available.
* Returns a cleanup callback which can be called to remove the instrumentation handler.
*
* Pass `stopOnCallback = true` to stop listening for LCP when the cleanup callback is called.
* This will lead to the LCP being finalized and frozen.
*/
export function addLcpInstrumentationHandler(
callback: (data: { metric: Metric }) => void,
stopOnCallback = false,
): CleanupHandlerCallback {
return addMetricObserver('lcp', callback, instrumentLcp, _previousLcp, stopOnCallback);
}
/**
* Add a callback that will be triggered when a FID metric is available.
* Returns a cleanup callback which can be called to remove the instrumentation handler.
*/
export function addFidInstrumentationHandler(callback: (data: { metric: Metric }) => void): CleanupHandlerCallback {
return addMetricObserver('fid', callback, instrumentFid, _previousFid);
}
/**
* Add a callback that will be triggered when a FID metric is available.
*/
export function addTtfbInstrumentationHandler(callback: (data: { metric: Metric }) => void): CleanupHandlerCallback {
return addMetricObserver('ttfb', callback, instrumentTtfb, _previousTtfb);
}
and the approach can be identical to what we do with LCP.

Tasks

@jas-kas jas-kas transferred this issue from getsentry/sentry-docs Apr 16, 2024
@jas-kas
Copy link
Member Author

jas-kas commented Apr 16, 2024

cc/ @AbhiPrasad

@AbhiPrasad AbhiPrasad added Feature: Spans Package: replay Issues related to the Sentry Replay SDK labels Apr 24, 2024
@c298lee c298lee closed this as completed in 691e5de Jun 7, 2024
billyvg pushed a commit that referenced this issue Jun 10, 2024
Adds CLS, FID, and INP breadcrumbs. Updates all web vital breadcrumbs to
include rating

Closes #11639

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Luca Forstner <[email protected]>
Co-authored-by: Andrei <[email protected]>
Co-authored-by: Francesco Novy <[email protected]>
Co-authored-by: Lukas Stracke <[email protected]>
Co-authored-by: Yamagishi Kazutoshi <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: Spans Package: replay Issues related to the Sentry Replay SDK
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants