@@ -6,7 +6,6 @@ import { browserPerformanceTimeOrigin, getGlobalObject, htmlTreeAsString, isNode
66import { Span } from '../span' ;
77import { Transaction } from '../transaction' ;
88import { msToSec } from '../utils' ;
9- import { BrowserMetricOptions } from './browsertracing' ;
109import { getCLS , LayoutShift } from './web-vitals/getCLS' ;
1110import { getFID } from './web-vitals/getFID' ;
1211import { getLCP , LargestContentfulPaint } from './web-vitals/getLCP' ;
@@ -15,6 +14,17 @@ import { NavigatorDeviceMemory, NavigatorNetworkInformation } from './web-vitals
1514
1615const global = getGlobalObject < Window > ( ) ;
1716
17+ /**
18+ * Exports a way to add options to our metric collection. Currently experimental.
19+ */
20+ export interface MetricsInstrumentationOptions {
21+ _reportAllChanges : boolean ;
22+ }
23+
24+ const DEFAULT_METRICS_INSTR_OPTIONS : MetricsInstrumentationOptions = {
25+ _reportAllChanges : false ,
26+ } ;
27+
1828/** Class tracking metrics */
1929export class MetricsInstrumentation {
2030 private _measurements : Measurements = { } ;
@@ -23,15 +33,15 @@ export class MetricsInstrumentation {
2333 private _lcpEntry : LargestContentfulPaint | undefined ;
2434 private _clsEntry : LayoutShift | undefined ;
2535
26- public constructor ( _options ?: BrowserMetricOptions ) {
36+ public constructor ( _options : MetricsInstrumentationOptions = DEFAULT_METRICS_INSTR_OPTIONS ) {
2737 if ( ! isNodeEnv ( ) && global ?. performance ) {
2838 if ( global . performance . mark ) {
2939 global . performance . mark ( 'sentry-tracing-init' ) ;
3040 }
3141
32- this . _trackCLS ( _options ) ;
33- this . _trackLCP ( _options ) ;
34- this . _trackFID ( _options ) ;
42+ this . _trackCLS ( ) ;
43+ this . _trackLCP ( _options . _reportAllChanges ) ;
44+ this . _trackFID ( ) ;
3545 }
3646 }
3747
@@ -231,7 +241,7 @@ export class MetricsInstrumentation {
231241 }
232242
233243 /** Starts tracking the Cumulative Layout Shift on the current page. */
234- private _trackCLS ( _options ?: BrowserMetricOptions ) : void {
244+ private _trackCLS ( ) : void {
235245 // See:
236246 // https://web.dev/evolving-cls/
237247 // https://web.dev/cls-web-tooling/
@@ -286,7 +296,7 @@ export class MetricsInstrumentation {
286296 }
287297
288298 /** Starts tracking the Largest Contentful Paint on the current page. */
289- private _trackLCP ( _options ?: BrowserMetricOptions ) : void {
299+ private _trackLCP ( reportAllChanges : boolean ) : void {
290300 getLCP ( metric => {
291301 const entry = metric . entries . pop ( ) ;
292302
@@ -300,11 +310,11 @@ export class MetricsInstrumentation {
300310 this . _measurements [ 'lcp' ] = { value : metric . value } ;
301311 this . _measurements [ 'mark.lcp' ] = { value : timeOrigin + startTime } ;
302312 this . _lcpEntry = entry as LargestContentfulPaint ;
303- } , _options ?. _reportAllChanges ) ;
313+ } , reportAllChanges ) ;
304314 }
305315
306316 /** Starts tracking the First Input Delay on the current page. */
307- private _trackFID ( _options ?: BrowserMetricOptions ) : void {
317+ private _trackFID ( ) : void {
308318 getFID ( metric => {
309319 const entry = metric . entries . pop ( ) ;
310320
0 commit comments