@@ -91,22 +91,22 @@ export class WebVitalsPlugin extends InternalPlugin {
9191 private handleLCP ( metric : LCPMetricWithAttribution | Metric ) {
9292 const a = ( metric as LCPMetricWithAttribution ) . attribution ;
9393 const attribution : RumLCPAttribution = {
94- element : a . element ,
95- url : a . url ,
96- timeToFirstByte : a . timeToFirstByte ,
97- resourceLoadDelay : a . resourceLoadDelay ,
94+ element : a ? .element ,
95+ url : a ? .url ,
96+ timeToFirstByte : a ? .timeToFirstByte ,
97+ resourceLoadDelay : a ? .resourceLoadDelay ,
9898 /**
9999 * `resourceLoadTime` was renamed to `resourceLoadDuration` in web-vitals 4.x
100100 * This is a cosmetic change, and does not affect the underlying value.
101101 * We can update the name to `resourceLoadDuration` in RUM's next major version.
102102 * (See https://github.com/GoogleChrome/web-vitals/pull/450)
103103 */
104- resourceLoadTime : a . resourceLoadDuration ,
104+ resourceLoadTime : a ? .resourceLoadDuration ,
105105 // See https://github.com/GoogleChrome/web-vitals/pull/450
106- elementRenderDelay : a . elementRenderDelay
106+ elementRenderDelay : a ? .elementRenderDelay
107107 } ;
108- if ( a . lcpResourceEntry ) {
109- const key = performanceKey ( a . lcpResourceEntry as HasLatency ) ;
108+ if ( a ? .lcpResourceEntry ) {
109+ const key = performanceKey ( a ? .lcpResourceEntry as HasLatency ) ;
110110 attribution . lcpResourceEntry = this . resourceEventIds . get ( key ) ;
111111 }
112112 if ( this . navigationEventId ) {
@@ -131,10 +131,10 @@ export class WebVitalsPlugin extends InternalPlugin {
131131 version : '1.0.0' ,
132132 value : metric . value ,
133133 attribution : {
134- largestShiftTarget : a . largestShiftTarget ,
135- largestShiftValue : a . largestShiftValue ,
136- largestShiftTime : a . largestShiftTime ,
137- loadState : a . loadState
134+ largestShiftTarget : a ? .largestShiftTarget ,
135+ largestShiftValue : a ? .largestShiftValue ,
136+ largestShiftTime : a ? .largestShiftTime ,
137+ loadState : a ? .loadState
138138 }
139139 } as CumulativeLayoutShiftEvent ) ;
140140 }
@@ -145,10 +145,10 @@ export class WebVitalsPlugin extends InternalPlugin {
145145 version : '1.0.0' ,
146146 value : metric . value ,
147147 attribution : {
148- eventTarget : a . eventTarget ,
149- eventType : a . eventType ,
150- eventTime : a . eventTime ,
151- loadState : a . loadState
148+ eventTarget : a ? .eventTarget ,
149+ eventType : a ? .eventType ,
150+ eventTime : a ? .eventTime ,
151+ loadState : a ? .loadState
152152 }
153153 } as FirstInputDelayEvent ) ;
154154 }
@@ -160,14 +160,14 @@ export class WebVitalsPlugin extends InternalPlugin {
160160 version : '1.0.0' ,
161161 value : metric . value ,
162162 attribution : {
163- interactionTarget : a . interactionTarget ,
164- interactionTime : a . interactionTime ,
165- nextPaintTime : a . nextPaintTime ,
166- interactionType : a . interactionType ,
167- inputDelay : a . inputDelay ,
168- processingDuration : a . processingDuration ,
169- presentationDelay : a . presentationDelay ,
170- loadState : a . loadState
163+ interactionTarget : a ? .interactionTarget ,
164+ interactionTime : a ? .interactionTime ,
165+ nextPaintTime : a ? .nextPaintTime ,
166+ interactionType : a ? .interactionType ,
167+ inputDelay : a ? .inputDelay ,
168+ processingDuration : a ? .processingDuration ,
169+ presentationDelay : a ? .presentationDelay ,
170+ loadState : a ? .loadState
171171 }
172172 } as InteractionToNextPaintEvent ) ;
173173 }
0 commit comments