File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
packages/browser-utils/test/metrics Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -113,4 +113,35 @@ describe('_onInp', () => {
113113 transaction : undefined ,
114114 } ) ;
115115 } ) ;
116+
117+ it ( 'uses <unknown> as element name when entry.target is null and no cached name exists' , ( ) => {
118+ const startStandaloneWebVitalSpanSpy = vi . spyOn ( utils , 'startStandaloneWebVitalSpan' ) ;
119+
120+ const metric = {
121+ value : 150 ,
122+ entries : [
123+ {
124+ name : 'click' ,
125+ duration : 150 ,
126+ interactionId : 999 ,
127+ target : null , // Element was removed from DOM
128+ startTime : 1234567 ,
129+ } ,
130+ ] ,
131+ } ;
132+ // @ts -expect-error - incomplete metric object
133+ _onInp ( { metric } ) ;
134+
135+ expect ( startStandaloneWebVitalSpanSpy ) . toHaveBeenCalledTimes ( 1 ) ;
136+ expect ( startStandaloneWebVitalSpanSpy ) . toHaveBeenCalledWith ( {
137+ attributes : {
138+ 'sentry.exclusive_time' : 150 ,
139+ 'sentry.op' : 'ui.interaction.click' ,
140+ 'sentry.origin' : 'auto.http.browser.inp' ,
141+ } ,
142+ name : '<unknown>' , // Should fall back to <unknown> when element cannot be determined
143+ startTime : expect . any ( Number ) ,
144+ transaction : undefined ,
145+ } ) ;
146+ } ) ;
116147} ) ;
You can’t perform that action at this time.
0 commit comments