File tree 2 files changed +4
-18
lines changed
packages/tracing/src/browser
2 files changed +4
-18
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,6 @@ export class MetricsInstrumentation {
21
21
private _performanceCursor : number = 0 ;
22
22
private _lcpEntry : LargestContentfulPaint | undefined ;
23
23
private _clsEntry : LayoutShift | undefined ;
24
- private _reportLCP : ReturnType < typeof getLCP > ;
25
24
26
25
public constructor ( private _reportAllChanges : boolean = false ) {
27
26
if ( ! isNodeEnv ( ) && global && global . performance && global . document ) {
@@ -44,12 +43,6 @@ export class MetricsInstrumentation {
44
43
45
44
logger . log ( '[Tracing] Adding & adjusting spans using Performance API' ) ;
46
45
47
- // `addPerformanceEntries` should be called on transaction.finish
48
- // If we are finishing a transaction, we should force report the LCP.
49
- if ( this . _reportLCP ) {
50
- this . _reportLCP ( true ) ;
51
- }
52
-
53
46
const timeOrigin = msToSec ( browserPerformanceTimeOrigin ) ;
54
47
55
48
let responseStartTimestamp : number | undefined ;
@@ -230,7 +223,7 @@ export class MetricsInstrumentation {
230
223
231
224
/** Starts tracking the Largest Contentful Paint on the current page. */
232
225
private _trackLCP ( ) : void {
233
- this . _reportLCP = getLCP ( metric => {
226
+ getLCP ( metric => {
234
227
const entry = metric . entries . pop ( ) ;
235
228
if ( ! entry ) {
236
229
return ;
Original file line number Diff line number Diff line change @@ -34,13 +34,10 @@ export interface LargestContentfulPaint extends PerformanceEntry {
34
34
35
35
const reportedMetricIDs : Record < string , boolean > = { } ;
36
36
37
- export const getLCP = (
38
- onReport : ReportHandler ,
39
- reportAllChanges ?: boolean ,
40
- ) : ReturnType < typeof bindReporter > | undefined => {
37
+ export const getLCP = ( onReport : ReportHandler , reportAllChanges ?: boolean ) : void => {
41
38
const visibilityWatcher = getVisibilityWatcher ( ) ;
42
39
const metric = initMetric ( 'LCP' ) ;
43
- let report : ReturnType < typeof bindReporter > | undefined ;
40
+ let report : ReturnType < typeof bindReporter > ;
44
41
45
42
const entryHandler = ( entry : PerformanceEntry ) : void => {
46
43
// The startTime attribute returns the value of the renderTime if it is not 0,
@@ -69,9 +66,7 @@ export const getLCP = (
69
66
po . takeRecords ( ) . map ( entryHandler as PerformanceEntryHandler ) ;
70
67
po . disconnect ( ) ;
71
68
reportedMetricIDs [ metric . id ] = true ;
72
- if ( report ) {
73
- report ( true ) ;
74
- }
69
+ report ( true ) ;
75
70
}
76
71
} ;
77
72
@@ -84,6 +79,4 @@ export const getLCP = (
84
79
85
80
onHidden ( stopListening , true ) ;
86
81
}
87
-
88
- return report ;
89
82
} ;
You can’t perform that action at this time.
0 commit comments