Skip to content

Commit 0434474

Browse files
authored
fix(tracing): Deprecate and remove reportAllChanges option (#6456)
1 parent 51b0a27 commit 0434474

File tree

5 files changed

+28
-32
lines changed

5 files changed

+28
-32
lines changed

packages/tracing/src/browser/browsertracing.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,12 @@ export interface BrowserTracingOptions extends RequestInstrumentationOptions {
8080
*
8181
* Default: undefined
8282
*/
83-
_metricOptions?: Partial<{ _reportAllChanges: boolean }>;
83+
_metricOptions?: Partial<{
84+
/**
85+
* @deprecated This property no longer has any effect and will be removed in v8.
86+
*/
87+
_reportAllChanges: boolean;
88+
}>;
8489

8590
/**
8691
* _experiments allows the user to send options to define how this integration works.
@@ -162,8 +167,7 @@ export class BrowserTracing implements Integration {
162167
this.options.tracePropagationTargets = _options.tracingOrigins;
163168
}
164169

165-
const { _metricOptions } = this.options;
166-
startTrackingWebVitals(_metricOptions && _metricOptions._reportAllChanges);
170+
startTrackingWebVitals();
167171
if (this.options._experiments?.enableLongTask) {
168172
startTrackingLongTasks();
169173
}

packages/tracing/src/browser/metrics/index.ts

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ let _clsEntry: LayoutShift | undefined;
2727
/**
2828
* Start tracking web vitals
2929
*/
30-
export function startTrackingWebVitals(reportAllChanges: boolean = false): void {
30+
export function startTrackingWebVitals(): void {
3131
const performance = getBrowserPerformanceAPI();
3232
if (performance && browserPerformanceTimeOrigin) {
3333
if (performance.mark) {
3434
WINDOW.performance.mark('sentry-tracing-init');
3535
}
3636
_trackCLS();
37-
_trackLCP(reportAllChanges);
37+
_trackLCP();
3838
_trackFID();
3939
}
4040
}
@@ -82,20 +82,17 @@ function _trackCLS(): void {
8282
}
8383

8484
/** Starts tracking the Largest Contentful Paint on the current page. */
85-
function _trackLCP(reportAllChanges: boolean): void {
86-
onLCP(
87-
metric => {
88-
const entry = metric.entries.pop();
89-
if (!entry) {
90-
return;
91-
}
85+
function _trackLCP(): void {
86+
onLCP(metric => {
87+
const entry = metric.entries.pop();
88+
if (!entry) {
89+
return;
90+
}
9291

93-
__DEBUG_BUILD__ && logger.log('[Measurements] Adding LCP');
94-
_measurements['lcp'] = { value: metric.value, unit: 'millisecond' };
95-
_lcpEntry = entry as LargestContentfulPaint;
96-
},
97-
{ reportAllChanges },
98-
);
92+
__DEBUG_BUILD__ && logger.log('[Measurements] Adding LCP');
93+
_measurements['lcp'] = { value: metric.value, unit: 'millisecond' };
94+
_lcpEntry = entry as LargestContentfulPaint;
95+
});
9996
}
10097

10198
/** Starts tracking the First Input Delay on the current page. */

packages/tracing/src/browser/web-vitals/getCLS.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { bindReporter } from './lib/bindReporter';
1818
import { initMetric } from './lib/initMetric';
1919
import { observe } from './lib/observe';
2020
import { onHidden } from './lib/onHidden';
21-
import { CLSMetric, ReportCallback, ReportOpts } from './types';
21+
import { CLSMetric, ReportCallback } from './types';
2222

2323
/**
2424
* Calculates the [CLS](https://web.dev/cls/) value for the current page and
@@ -41,7 +41,7 @@ import { CLSMetric, ReportCallback, ReportOpts } from './types';
4141
* hidden. As a result, the `callback` function might be called multiple times
4242
* during the same page load._
4343
*/
44-
export const onCLS = (onReport: ReportCallback, opts: ReportOpts = {}): void => {
44+
export const onCLS = (onReport: ReportCallback): void => {
4545
const metric = initMetric('CLS', 0);
4646
let report: ReturnType<typeof bindReporter>;
4747

@@ -87,7 +87,7 @@ export const onCLS = (onReport: ReportCallback, opts: ReportOpts = {}): void =>
8787

8888
const po = observe('layout-shift', handleEntries);
8989
if (po) {
90-
report = bindReporter(onReport, metric, opts.reportAllChanges);
90+
report = bindReporter(onReport, metric);
9191

9292
onHidden(() => {
9393
handleEntries(po.takeRecords() as CLSMetric['entries']);

packages/tracing/src/browser/web-vitals/getFID.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { getVisibilityWatcher } from './lib/getVisibilityWatcher';
1919
import { initMetric } from './lib/initMetric';
2020
import { observe } from './lib/observe';
2121
import { onHidden } from './lib/onHidden';
22-
import { FIDMetric, PerformanceEventTiming, ReportCallback, ReportOpts } from './types';
22+
import { FIDMetric, PerformanceEventTiming, ReportCallback } from './types';
2323

2424
/**
2525
* Calculates the [FID](https://web.dev/fid/) value for the current page and
@@ -30,7 +30,7 @@ import { FIDMetric, PerformanceEventTiming, ReportCallback, ReportOpts } from '.
3030
* _**Important:** since FID is only reported after the user interacts with the
3131
* page, it's possible that it will not be reported for some page loads._
3232
*/
33-
export const onFID = (onReport: ReportCallback, opts: ReportOpts = {}): void => {
33+
export const onFID = (onReport: ReportCallback): void => {
3434
const visibilityWatcher = getVisibilityWatcher();
3535
const metric = initMetric('FID');
3636
// eslint-disable-next-line prefer-const
@@ -50,7 +50,7 @@ export const onFID = (onReport: ReportCallback, opts: ReportOpts = {}): void =>
5050
};
5151

5252
const po = observe('first-input', handleEntries);
53-
report = bindReporter(onReport, metric, opts.reportAllChanges);
53+
report = bindReporter(onReport, metric);
5454

5555
if (po) {
5656
onHidden(() => {

packages/tracing/src/browser/web-vitals/getLCP.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { getVisibilityWatcher } from './lib/getVisibilityWatcher';
2020
import { initMetric } from './lib/initMetric';
2121
import { observe } from './lib/observe';
2222
import { onHidden } from './lib/onHidden';
23-
import { LCPMetric, ReportCallback, ReportOpts } from './types';
23+
import { LCPMetric, ReportCallback } from './types';
2424

2525
const reportedMetricIDs: Record<string, boolean> = {};
2626

@@ -29,13 +29,8 @@ const reportedMetricIDs: Record<string, boolean> = {};
2929
* calls the `callback` function once the value is ready (along with the
3030
* relevant `largest-contentful-paint` performance entry used to determine the
3131
* value). The reported value is a `DOMHighResTimeStamp`.
32-
*
33-
* If the `reportAllChanges` configuration option is set to `true`, the
34-
* `callback` function will be called any time a new `largest-contentful-paint`
35-
* performance entry is dispatched, or once the final value of the metric has
36-
* been determined.
3732
*/
38-
export const onLCP = (onReport: ReportCallback, opts: ReportOpts = {}): void => {
33+
export const onLCP = (onReport: ReportCallback): void => {
3934
const visibilityWatcher = getVisibilityWatcher();
4035
const metric = initMetric('LCP');
4136
let report: ReturnType<typeof bindReporter>;
@@ -61,7 +56,7 @@ export const onLCP = (onReport: ReportCallback, opts: ReportOpts = {}): void =>
6156
const po = observe('largest-contentful-paint', handleEntries);
6257

6358
if (po) {
64-
report = bindReporter(onReport, metric, opts.reportAllChanges);
59+
report = bindReporter(onReport, metric);
6560

6661
const stopListening = (): void => {
6762
if (!reportedMetricIDs[metric.id]) {

0 commit comments

Comments
 (0)