@@ -6,7 +6,6 @@ import { browserPerformanceTimeOrigin, getGlobalObject, htmlTreeAsString, isNode
6
6
import { Span } from '../span' ;
7
7
import { Transaction } from '../transaction' ;
8
8
import { msToSec } from '../utils' ;
9
- import { BrowserMetricOptions } from './browsertracing' ;
10
9
import { getCLS , LayoutShift } from './web-vitals/getCLS' ;
11
10
import { getFID } from './web-vitals/getFID' ;
12
11
import { getLCP , LargestContentfulPaint } from './web-vitals/getLCP' ;
@@ -15,6 +14,17 @@ import { NavigatorDeviceMemory, NavigatorNetworkInformation } from './web-vitals
15
14
16
15
const global = getGlobalObject < Window > ( ) ;
17
16
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
+
18
28
/** Class tracking metrics */
19
29
export class MetricsInstrumentation {
20
30
private _measurements : Measurements = { } ;
@@ -23,15 +33,15 @@ export class MetricsInstrumentation {
23
33
private _lcpEntry : LargestContentfulPaint | undefined ;
24
34
private _clsEntry : LayoutShift | undefined ;
25
35
26
- public constructor ( _options ?: BrowserMetricOptions ) {
36
+ public constructor ( _options : MetricsInstrumentationOptions = DEFAULT_METRICS_INSTR_OPTIONS ) {
27
37
if ( ! isNodeEnv ( ) && global ?. performance ) {
28
38
if ( global . performance . mark ) {
29
39
global . performance . mark ( 'sentry-tracing-init' ) ;
30
40
}
31
41
32
- this . _trackCLS ( _options ) ;
33
- this . _trackLCP ( _options ) ;
34
- this . _trackFID ( _options ) ;
42
+ this . _trackCLS ( ) ;
43
+ this . _trackLCP ( _options . _reportAllChanges ) ;
44
+ this . _trackFID ( ) ;
35
45
}
36
46
}
37
47
@@ -231,7 +241,7 @@ export class MetricsInstrumentation {
231
241
}
232
242
233
243
/** Starts tracking the Cumulative Layout Shift on the current page. */
234
- private _trackCLS ( _options ?: BrowserMetricOptions ) : void {
244
+ private _trackCLS ( ) : void {
235
245
// See:
236
246
// https://web.dev/evolving-cls/
237
247
// https://web.dev/cls-web-tooling/
@@ -286,7 +296,7 @@ export class MetricsInstrumentation {
286
296
}
287
297
288
298
/** Starts tracking the Largest Contentful Paint on the current page. */
289
- private _trackLCP ( _options ?: BrowserMetricOptions ) : void {
299
+ private _trackLCP ( reportAllChanges : boolean ) : void {
290
300
getLCP ( metric => {
291
301
const entry = metric . entries . pop ( ) ;
292
302
@@ -300,11 +310,11 @@ export class MetricsInstrumentation {
300
310
this . _measurements [ 'lcp' ] = { value : metric . value } ;
301
311
this . _measurements [ 'mark.lcp' ] = { value : timeOrigin + startTime } ;
302
312
this . _lcpEntry = entry as LargestContentfulPaint ;
303
- } , _options ?. _reportAllChanges ) ;
313
+ } , reportAllChanges ) ;
304
314
}
305
315
306
316
/** Starts tracking the First Input Delay on the current page. */
307
- private _trackFID ( _options ?: BrowserMetricOptions ) : void {
317
+ private _trackFID ( ) : void {
308
318
getFID ( metric => {
309
319
const entry = metric . entries . pop ( ) ;
310
320
0 commit comments