From 5e4842976d6b814cb9aae60799297aa01c100d13 Mon Sep 17 00:00:00 2001 From: Philip Walton Date: Sun, 19 May 2024 19:27:21 -0700 Subject: [PATCH 1/3] Add ReportCallback type back but deprecate it --- src/types/base.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/types/base.ts b/src/types/base.ts index 9d574e90..f883affc 100644 --- a/src/types/base.ts +++ b/src/types/base.ts @@ -116,6 +116,15 @@ export type MetricWithAttribution = */ export type MetricRatingThresholds = [number, number]; +/** + * @deprecated Use metric-specific function types instead, such as: + * `(metric: LCPMetric) => void`. If a single callback type is needed for + * multiple metrics, use `(metric: MetricType) => void`. + */ +export interface ReportCallback { + (metric: MetricType): void; +} + export interface ReportOpts { reportAllChanges?: boolean; durationThreshold?: number; From 4b808fd2b249aac3c7f6c31d1318fb45bea4f637 Mon Sep 17 00:00:00 2001 From: Philip Walton Date: Sun, 19 May 2024 20:04:42 -0700 Subject: [PATCH 2/3] Update the Upgrading to v4 guide --- docs/upgrading-to-v4.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/upgrading-to-v4.md b/docs/upgrading-to-v4.md index 19fc0de1..40b67c3f 100644 --- a/docs/upgrading-to-v4.md +++ b/docs/upgrading-to-v4.md @@ -1,8 +1,8 @@ # Upgrading to v4 -This document lists the full set of changes between version 3 and version 4 that are relevant to anyone wanting to upgrade to the new version. This document groups changes into "breaking changes" and "new features" across both the "standard" and "attribution" builds (see [build options](/#build-options) for details). +This document lists the full set of changes between version 3 and version 4 that are relevant to anyone wanting to upgrade to the new version. This document groups changes into "breaking changes", "new features", and "deprecations" across both the "standard" and "attribution" builds (see [build options](/#build-options) for details). -## ⚠️ Breaking changes +## ❌ Breaking changes ### Standard build @@ -56,3 +56,12 @@ No new features were introduced into the "standard" build, outside of the breaki #### `TTFBAttribution` - **Added** `cacheDuration`, which marks the total time spent checking the HTTP cache for a match ([#458](https://github.com/GoogleChrome/web-vitals/pull/458)). + +## ⚠️ Deprecations + +### Standard and attribution builds + +- The `onFID()` function has been deprecated. Developers should use `onINP()` instead ([#435](https://github.com/GoogleChrome/web-vitals/pull/435)). +- The `ReportCallback` type has been deprecated in favor of explicit callback types for each metric function ([#483](https://github.com/GoogleChrome/web-vitals/pull/483)). + +_All deprecated APIs will be removed in the next major version._ From 473e3b12857726c61a869c19467f52dd675b97d9 Mon Sep 17 00:00:00 2001 From: Philip Walton Date: Mon, 20 May 2024 10:12:23 -0700 Subject: [PATCH 3/3] Update docs/upgrading-to-v4.md Co-authored-by: Barry Pollard --- docs/upgrading-to-v4.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/upgrading-to-v4.md b/docs/upgrading-to-v4.md index 40b67c3f..d3d2237d 100644 --- a/docs/upgrading-to-v4.md +++ b/docs/upgrading-to-v4.md @@ -61,7 +61,7 @@ No new features were introduced into the "standard" build, outside of the breaki ### Standard and attribution builds -- The `onFID()` function has been deprecated. Developers should use `onINP()` instead ([#435](https://github.com/GoogleChrome/web-vitals/pull/435)). +- The `onFID()` function [has been deprecated]https://web.dev/blog/inp-cwv-launch#fid_deprecation_timeline). Developers should use `onINP()` instead ([#435](https://github.com/GoogleChrome/web-vitals/pull/435)). - The `ReportCallback` type has been deprecated in favor of explicit callback types for each metric function ([#483](https://github.com/GoogleChrome/web-vitals/pull/483)). _All deprecated APIs will be removed in the next major version._