Skip to content

feat(browser)!: Remove FID web vital collection #17076

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

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,20 @@ Additionally, we hold ourselves accountable to any security issues, meaning that

Note, that it is decided on a case-per-case basis, what gets backported or not.
If you need a fix or feature in a previous version of the SDK, please reach out via a GitHub Issue.

## 3. Behaviour Changes

### Removal of First Input Delay (FID) Web Vital Reporting

Affected SDKs: All SDKs running in browser applications (`@sentry/browser`, `@sentry/react`, `@sentry/nextjs`, etc.)

In v10, the SDK stopped reporting the First Input Delay (FID) web vital.
This was done because FID has been replaced by Interaction to Next Paint (INP) and is therefore no longer relevant for assessing and tracking a website's performance.
For reference, FID has long been deprecated by Google's official `web-vitals` library and was eventually removed in version `5.0.0`.
Sentry now follows Google's lead by also removing it.

The removal entails **no breaking API changes**. However, in rare cases, you might need to adjust some of your Sentry SDK and product setup:

- Remove any logic in `beforeSend` or other filtering/event processing logic that depends on FID or replace it with INP logic.
- If you set up Sentry Alerts that depend on FID, be aware that these could trigger once you upgrade the SDK, due to a lack of new values.
To replace them, adjust your alerts (or dashbaords) to use INP.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
expectedClickBreadcrumb,
expectedCLSPerformanceSpan,
expectedFCPPerformanceSpan,
expectedFIDPerformanceSpan,
expectedFPPerformanceSpan,
expectedLCPPerformanceSpan,
expectedMemoryPerformanceSpan,
Expand Down Expand Up @@ -56,7 +55,6 @@ sentryTest(
expectedNavigationPerformanceSpan,
expectedLCPPerformanceSpan,
expectedCLSPerformanceSpan,
expectedFIDPerformanceSpan,
expectedFPPerformanceSpan,
expectedFCPPerformanceSpan,
expectedMemoryPerformanceSpan, // two memory spans - once per flush
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
expectedClickBreadcrumb,
expectedCLSPerformanceSpan,
expectedFCPPerformanceSpan,
expectedFIDPerformanceSpan,
expectedFPPerformanceSpan,
expectedLCPPerformanceSpan,
expectedMemoryPerformanceSpan,
Expand Down Expand Up @@ -77,7 +76,6 @@ sentryTest(
expectedNavigationPerformanceSpan,
expectedLCPPerformanceSpan,
expectedCLSPerformanceSpan,
expectedFIDPerformanceSpan,
expectedFPPerformanceSpan,
expectedFCPPerformanceSpan,
expectedMemoryPerformanceSpan, // two memory spans - once per flush
Expand Down Expand Up @@ -117,7 +115,6 @@ sentryTest(
expectedReloadPerformanceSpan,
expectedLCPPerformanceSpan,
expectedCLSPerformanceSpan,
expectedFIDPerformanceSpan,
expectedFPPerformanceSpan,
expectedFCPPerformanceSpan,
expectedMemoryPerformanceSpan,
Expand Down Expand Up @@ -188,7 +185,6 @@ sentryTest(
expectedNavigationPerformanceSpan,
expectedLCPPerformanceSpan,
expectedCLSPerformanceSpan,
expectedFIDPerformanceSpan,
expectedFPPerformanceSpan,
expectedFCPPerformanceSpan,
expectedMemoryPerformanceSpan,
Expand Down Expand Up @@ -326,7 +322,6 @@ sentryTest(
expectedNavigationPerformanceSpan,
expectedLCPPerformanceSpan,
expectedCLSPerformanceSpan,
expectedFIDPerformanceSpan,
expectedFPPerformanceSpan,
expectedFCPPerformanceSpan,
expectedMemoryPerformanceSpan,
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -148,19 +148,6 @@ export const expectedCLSPerformanceSpan = {
},
};

export const expectedFIDPerformanceSpan = {
op: 'web-vital',
description: 'first-input-delay',
startTimestamp: expect.any(Number),
endTimestamp: expect.any(Number),
data: {
value: expect.any(Number),
rating: expect.any(String),
size: expect.any(Number),
nodeIds: expect.any(Array),
},
};

export const expectedINPPerformanceSpan = {
op: 'web-vital',
description: 'interaction-to-next-paint',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,25 +245,6 @@ export const ReplayRecordingData = [
},
},
},
{
type: 5,
timestamp: expect.any(Number),
data: {
tag: 'performanceSpan',
payload: {
op: 'web-vital',
description: 'first-input-delay',
startTimestamp: expect.any(Number),
endTimestamp: expect.any(Number),
data: {
value: expect.any(Number),
size: expect.any(Number),
rating: expect.any(String),
nodeIds: [10],
},
},
},
},
{
type: 5,
timestamp: expect.any(Number),
Expand Down
1 change: 0 additions & 1 deletion packages/browser-utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export {
addPerformanceInstrumentationHandler,
addClsInstrumentationHandler,
addFidInstrumentationHandler,
addTtfbInstrumentationHandler,
addLcpInstrumentationHandler,
addInpInstrumentationHandler,
Expand Down
33 changes: 0 additions & 33 deletions packages/browser-utils/src/metrics/browserMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { trackClsAsStandaloneSpan } from './cls';
import {
type PerformanceLongAnimationFrameTiming,
addClsInstrumentationHandler,
addFidInstrumentationHandler,
addLcpInstrumentationHandler,
addPerformanceInstrumentationHandler,
addTtfbInstrumentationHandler,
Expand Down Expand Up @@ -103,13 +102,11 @@ export function startTrackingWebVitals({
if (performance.mark) {
WINDOW.performance.mark('sentry-tracing-init');
}
const fidCleanupCallback = _trackFID();
const lcpCleanupCallback = recordLcpStandaloneSpans ? trackLcpAsStandaloneSpan(client) : _trackLCP();
const ttfbCleanupCallback = _trackTtfb();
const clsCleanupCallback = recordClsStandaloneSpans ? trackClsAsStandaloneSpan(client) : _trackCLS();

return (): void => {
fidCleanupCallback();
lcpCleanupCallback?.();
ttfbCleanupCallback();
clsCleanupCallback?.();
Expand Down Expand Up @@ -277,21 +274,6 @@ function _trackLCP(): () => void {
}, true);
}

/** Starts tracking the First Input Delay on the current page. */
function _trackFID(): () => void {
return addFidInstrumentationHandler(({ metric }) => {
const entry = metric.entries[metric.entries.length - 1];
if (!entry) {
return;
}

const timeOrigin = msToSec(browserPerformanceTimeOrigin() as number);
const startTime = msToSec(entry.startTime);
_measurements['fid'] = { value: metric.value, unit: 'millisecond' };
_measurements['mark.fid'] = { value: timeOrigin + startTime, unit: 'second' };
});
}

function _trackTtfb(): () => void {
return addTtfbInstrumentationHandler(({ metric }) => {
const entry = metric.entries[metric.entries.length - 1];
Expand Down Expand Up @@ -415,21 +397,6 @@ export function addPerformanceEntries(span: Span, options: AddPerformanceEntries
if (op === 'pageload') {
_addTtfbRequestTimeToMeasurements(_measurements);

const fidMark = _measurements['mark.fid'];
if (fidMark && _measurements['fid']) {
// create span for FID
startAndEndSpan(span, fidMark.value, fidMark.value + msToSec(_measurements['fid'].value), {
name: 'first input delay',
op: 'ui.action',
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.browser.metrics',
},
});

// Delete mark.fid as we don't want it to be part of final payload
delete _measurements['mark.fid'];
}

// If FCP is not recorded we should not record the cls value
// according to the new definition of CLS.
// TODO: Check if the first condition is still necessary: `onCLS` already only fires once `onFCP` was called.
Expand Down
30 changes: 6 additions & 24 deletions packages/browser-utils/src/metrics/instrument.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { debug, getFunctionName } from '@sentry/core';
import { DEBUG_BUILD } from '../debug-build';
import { onCLS } from './web-vitals/getCLS';
import { onFID } from './web-vitals/getFID';
import { onINP } from './web-vitals/getINP';
import { onLCP } from './web-vitals/getLCP';
import { observe } from './web-vitals/lib/observe';
Expand All @@ -13,10 +12,11 @@ type InstrumentHandlerTypePerformanceObserver =
| 'navigation'
| 'paint'
| 'resource'
| 'first-input'
| 'element';
| 'element'
// fist-input is still needed for INP
| 'first-input';

type InstrumentHandlerTypeMetric = 'cls' | 'lcp' | 'fid' | 'ttfb' | 'inp';
type InstrumentHandlerTypeMetric = 'cls' | 'lcp' | 'ttfb' | 'inp';

// We provide this here manually instead of relying on a global, as this is not available in non-browser environements
// And we do not want to expose such types
Expand Down Expand Up @@ -51,7 +51,7 @@ interface Metric {
/**
* The name of the metric (in acronym form).
*/
name: 'CLS' | 'FCP' | 'FID' | 'INP' | 'LCP' | 'TTFB';
name: 'CLS' | 'FCP' | 'INP' | 'LCP' | 'TTFB';

/**
* The current value of the metric.
Expand Down Expand Up @@ -111,7 +111,6 @@ const handlers: { [key in InstrumentHandlerType]?: InstrumentHandlerCallback[] }
const instrumented: { [key in InstrumentHandlerType]?: boolean } = {};

let _previousCls: Metric | undefined;
let _previousFid: Metric | undefined;
let _previousLcp: Metric | undefined;
let _previousTtfb: Metric | undefined;
let _previousInp: Metric | undefined;
Expand Down Expand Up @@ -145,15 +144,7 @@ export function addLcpInstrumentationHandler(
}

/**
* 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.
* Add a callback that will be triggered when a TTFD metric is available.
*/
export function addTtfbInstrumentationHandler(callback: (data: { metric: Metric }) => void): CleanupHandlerCallback {
return addMetricObserver('ttfb', callback, instrumentTtfb, _previousTtfb);
Expand Down Expand Up @@ -236,15 +227,6 @@ function instrumentCls(): StopListening {
);
}

function instrumentFid(): void {
return onFID(metric => {
triggerHandlers('fid', {
metric,
});
_previousFid = metric;
});
}

function instrumentLcp(): StopListening {
return onLCP(
metric => {
Expand Down
4 changes: 4 additions & 0 deletions packages/browser-utils/src/metrics/web-vitals/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ web-vitals only report once per pageload.

## CHANGELOG

TODO: PR Url

- Removed FID-related code with v10 of the SDK

https://github.com/getsentry/sentry-javascript/pull/16492

- Bumped from Web Vitals 4.2.5 to 5.0.2
Expand Down
76 changes: 0 additions & 76 deletions packages/browser-utils/src/metrics/web-vitals/getFID.ts

This file was deleted.

Loading
Loading