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

Conversation

philipwalton
Copy link
Member

Fixes #482 by re-adding the ReportCallback type but marking it as deprecated.

In most cases developers should not need to explicitly type their metric function callbacks (e.g. the type can be inferred from usage), but in the event that you do, the recommended replacement for ReportCallback is either:

  • Specify a metric-specific function type, e.g. (meric: LCPMetric) => void, or
  • Specify a type that could be used for any metric function, e.g. (metric: MetricType) => void

The MetricType type can be imported as follows:

// If using the "standard" build:
import type {MetricType} from 'web-vitals';

// If using the "attribution" build:
import type {MetricType} from 'web-vitals/attribution';

Copy link
Member

@tunetheweb tunetheweb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with one suggestion.

docs/upgrading-to-v4.md Outdated Show resolved Hide resolved
reefdog added a commit to PhilanthropyDataCommons/front-end that referenced this pull request May 20, 2024
Web Vitals v3 deprecated several methods and types, and v4 fully removed
them. This commit adapts our code to the breaking changes.

Note that the breaking removal of the `ReportHandler` type has been
complained about[1] and may return in deprecated form[2], but we should
go ahead and replace it anyway with the suggested inline typedef.

[1] GoogleChrome/web-vitals#482
[2] GoogleChrome/web-vitals#483

PR #745 Bump web-vitals from 3.5.2 to 4.0.0
Co-authored-by: Barry Pollard <[email protected]>
Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Deprecation text looks good in vscode:
screenshot from vscode showing deprecation warning in tooltip

yutakusuno added a commit to yutakusuno/world-weather-map that referenced this pull request May 22, 2024
yutakusuno added a commit to yutakusuno/world-weather-map that referenced this pull request May 22, 2024
* ---
updated-dependencies:
- dependency-name: web-vitals
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

* build: Fix reportWebVitals to use MetricType type

GoogleChrome/web-vitals#483

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Yuta Kusuno <[email protected]>
@philipwalton philipwalton merged commit cae70b1 into main May 22, 2024
8 checks passed
@philipwalton philipwalton deleted the report-callback branch May 22, 2024 03:15
@philipwalton philipwalton changed the title Add ReportCallback type back but deprecate it Add the ReportCallback type back but deprecate it May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

can't find ReportCallback or ReportHandler type
3 participants