diff --git a/src/attribution/onCLS.ts b/src/attribution/onCLS.ts index 0e62a7d8..1b86b85d 100644 --- a/src/attribution/onCLS.ts +++ b/src/attribution/onCLS.ts @@ -81,7 +81,7 @@ export const onCLS = ( opts?: ReportOpts ) => { unattributedOnCLS( - ((metric: CLSMetric) => { + ((metric: CLSMetricWithAttribution) => { attributeCLS(metric); onReport(metric); }) as CLSReportCallback, diff --git a/src/types/base.ts b/src/types/base.ts index 3cce6b7f..f1e4b401 100644 --- a/src/types/base.ts +++ b/src/types/base.ts @@ -116,6 +116,10 @@ export interface ReportCallback { (metric: Metric): void; } +export interface ReportCallbackWithAttribution { + (metric: MetricWithAttribution): void; +} + export interface ReportOpts { reportAllChanges?: boolean; durationThreshold?: number; diff --git a/src/types/cls.ts b/src/types/cls.ts index 58dbce35..ef99741e 100644 --- a/src/types/cls.ts +++ b/src/types/cls.ts @@ -14,7 +14,12 @@ * limitations under the License. */ -import {LoadState, Metric, ReportCallback} from './base.js'; +import { + LoadState, + Metric, + ReportCallback, + ReportCallbackWithAttribution, +} from './base.js'; /** * A CLS-specific version of the Metric object. @@ -83,6 +88,7 @@ export interface CLSReportCallback extends ReportCallback { /** * A CLS-specific version of the ReportCallback function with attribution. */ -export interface CLSReportCallbackWithAttribution extends CLSReportCallback { +export interface CLSReportCallbackWithAttribution + extends ReportCallbackWithAttribution { (metric: CLSMetricWithAttribution): void; } diff --git a/src/types/fcp.ts b/src/types/fcp.ts index b7755629..ca65f4dd 100644 --- a/src/types/fcp.ts +++ b/src/types/fcp.ts @@ -14,7 +14,12 @@ * limitations under the License. */ -import {LoadState, Metric, ReportCallback} from './base.js'; +import { + LoadState, + Metric, + ReportCallback, + ReportCallbackWithAttribution, +} from './base.js'; import {NavigationTimingPolyfillEntry} from './polyfills.js'; /** @@ -75,6 +80,7 @@ export interface FCPReportCallback extends ReportCallback { /** * An FCP-specific version of the ReportCallback function with attribution. */ -export interface FCPReportCallbackWithAttribution extends FCPReportCallback { +export interface FCPReportCallbackWithAttribution + extends ReportCallbackWithAttribution { (metric: FCPMetricWithAttribution): void; } diff --git a/src/types/fid.ts b/src/types/fid.ts index a5449753..49ddd401 100644 --- a/src/types/fid.ts +++ b/src/types/fid.ts @@ -14,7 +14,12 @@ * limitations under the License. */ -import {LoadState, Metric, ReportCallback} from './base.js'; +import { + LoadState, + Metric, + ReportCallback, + ReportCallbackWithAttribution, +} from './base.js'; import {FirstInputPolyfillEntry} from './polyfills.js'; /** @@ -76,6 +81,7 @@ export interface FIDReportCallback extends ReportCallback { /** * An FID-specific version of the ReportCallback function with attribution. */ -export interface FIDReportCallbackWithAttribution extends FIDReportCallback { +export interface FIDReportCallbackWithAttribution + extends ReportCallbackWithAttribution { (metric: FIDMetricWithAttribution): void; } diff --git a/src/types/inp.ts b/src/types/inp.ts index cc1a0794..ec9c5e76 100644 --- a/src/types/inp.ts +++ b/src/types/inp.ts @@ -14,7 +14,12 @@ * limitations under the License. */ -import {LoadState, Metric, ReportCallback} from './base.js'; +import { + LoadState, + Metric, + ReportCallback, + ReportCallbackWithAttribution, +} from './base.js'; /** * An INP-specific version of the Metric object. @@ -75,6 +80,7 @@ export interface INPReportCallback extends ReportCallback { /** * An INP-specific version of the ReportCallback function with attribution. */ -export interface INPReportCallbackWithAttribution extends INPReportCallback { +export interface INPReportCallbackWithAttribution + extends ReportCallbackWithAttribution { (metric: INPMetricWithAttribution): void; } diff --git a/src/types/lcp.ts b/src/types/lcp.ts index b2418dbe..4aedd4ff 100644 --- a/src/types/lcp.ts +++ b/src/types/lcp.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import {Metric, ReportCallback} from './base.js'; +import {Metric, ReportCallback, ReportCallbackWithAttribution} from './base.js'; import {NavigationTimingPolyfillEntry} from './polyfills.js'; /** @@ -98,6 +98,7 @@ export interface LCPReportCallback extends ReportCallback { /** * An LCP-specific version of the ReportCallback function with attribution. */ -export interface LCPReportCallbackWithAttribution extends LCPReportCallback { +export interface LCPReportCallbackWithAttribution + extends ReportCallbackWithAttribution { (metric: LCPMetricWithAttribution): void; } diff --git a/src/types/ttfb.ts b/src/types/ttfb.ts index 5b7b62b5..66fa23ac 100644 --- a/src/types/ttfb.ts +++ b/src/types/ttfb.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import {Metric, ReportCallback} from './base.js'; +import {Metric, ReportCallback, ReportCallbackWithAttribution} from './base.js'; import {NavigationTimingPolyfillEntry} from './polyfills.js'; /** @@ -76,6 +76,7 @@ export interface TTFBReportCallback extends ReportCallback { /** * A TTFB-specific version of the ReportCallback function with attribution. */ -export interface TTFBReportCallbackWithAttribution extends TTFBReportCallback { +export interface TTFBReportCallbackWithAttribution + extends ReportCallbackWithAttribution { (metric: TTFBMetricWithAttribution): void; }