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 the ReportCallback type back but deprecate it #483

Merged
merged 3 commits into from
May 22, 2024
Merged
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
13 changes: 11 additions & 2 deletions docs/upgrading-to-v4.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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]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._
9 changes: 9 additions & 0 deletions src/types/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading