@@ -222,7 +222,7 @@ test.describe('TraceDirective', () => {
222222 } ) ;
223223} ) ;
224224
225- test . describe ( 'TraceClassDecorator ' , ( ) => {
225+ test . describe ( 'TraceClass Decorator ' , ( ) => {
226226 test ( 'adds init span for decorated class' , async ( { page } ) => {
227227 const navigationTxnPromise = waitForTransaction ( 'angular-17' , async transactionEvent => {
228228 return ! ! transactionEvent ?. transaction && transactionEvent . contexts ?. trace ?. op === 'navigation' ;
@@ -244,8 +244,7 @@ test.describe('TraceClassDecorator', () => {
244244 [ SEMANTIC_ATTRIBUTE_SENTRY_OP ] : 'ui.angular.init' ,
245245 [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] : 'auto.ui.angular.trace_class_decorator' ,
246246 } ,
247- // todo: right now, it shows the minified version of the component name - we will add a name input to the Decorator
248- description : expect . any ( String ) ,
247+ description : '<ComponentTrackingComponent>' ,
249248 op : 'ui.angular.init' ,
250249 origin : 'auto.ui.angular.trace_class_decorator' ,
251250 start_timestamp : expect . any ( Number ) ,
@@ -255,8 +254,8 @@ test.describe('TraceClassDecorator', () => {
255254 } ) ;
256255} ) ;
257256
258- test . describe ( 'TraceMethodDecorator ' , ( ) => {
259- test ( 'instruments decorated methods ( `ngOnInit` and `ngAfterViewInit`) ' , async ( { page } ) => {
257+ test . describe ( 'TraceMethod Decorator ' , ( ) => {
258+ test ( 'adds name to span description of decorated method `ngOnInit`' , async ( { page } ) => {
260259 const navigationTxnPromise = waitForTransaction ( 'angular-17' , async transactionEvent => {
261260 return ! ! transactionEvent ?. transaction && transactionEvent . contexts ?. trace ?. op === 'navigation' ;
262261 } ) ;
@@ -267,7 +266,6 @@ test.describe('TraceMethodDecorator', () => {
267266 const [ _ , navigationTxn ] = await Promise . all ( [ page . locator ( '#componentTracking' ) . click ( ) , navigationTxnPromise ] ) ;
268267
269268 const ngInitSpan = navigationTxn . spans ?. find ( span => span . op === 'ui.angular.ngOnInit' ) ;
270- const ngAfterViewInitSpan = navigationTxn . spans ?. find ( span => span . op === 'ui.angular.ngAfterViewInit' ) ;
271269
272270 expect ( ngInitSpan ) . toBeDefined ( ) ;
273271 expect ( ngInitSpan ) . toEqual (
@@ -276,14 +274,26 @@ test.describe('TraceMethodDecorator', () => {
276274 [ SEMANTIC_ATTRIBUTE_SENTRY_OP ] : 'ui.angular.ngOnInit' ,
277275 [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] : 'auto.ui.angular.trace_method_decorator' ,
278276 } ,
279- // todo: right now, it shows the minified version of the component name - we will add a name input to the Decorator
280- description : expect . any ( String ) ,
277+ description : '<ngOnInit>' ,
281278 op : 'ui.angular.ngOnInit' ,
282279 origin : 'auto.ui.angular.trace_method_decorator' ,
283280 start_timestamp : expect . any ( Number ) ,
284281 timestamp : expect . any ( Number ) ,
285282 } ) ,
286283 ) ;
284+ } ) ;
285+
286+ test ( 'adds fallback name to span description of decorated method `ngAfterViewInit`' , async ( { page } ) => {
287+ const navigationTxnPromise = waitForTransaction ( 'angular-17' , async transactionEvent => {
288+ return ! ! transactionEvent ?. transaction && transactionEvent . contexts ?. trace ?. op === 'navigation' ;
289+ } ) ;
290+
291+ await page . goto ( `/` ) ;
292+
293+ // immediately navigate to a different route
294+ const [ _ , navigationTxn ] = await Promise . all ( [ page . locator ( '#componentTracking' ) . click ( ) , navigationTxnPromise ] ) ;
295+
296+ const ngAfterViewInitSpan = navigationTxn . spans ?. find ( span => span . op === 'ui.angular.ngAfterViewInit' ) ;
287297
288298 expect ( ngAfterViewInitSpan ) . toBeDefined ( ) ;
289299 expect ( ngAfterViewInitSpan ) . toEqual (
@@ -292,8 +302,7 @@ test.describe('TraceMethodDecorator', () => {
292302 [ SEMANTIC_ATTRIBUTE_SENTRY_OP ] : 'ui.angular.ngAfterViewInit' ,
293303 [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] : 'auto.ui.angular.trace_method_decorator' ,
294304 } ,
295- // todo: right now, it shows the minified version of the component name - we will add a name input to the Decorator
296- description : expect . any ( String ) ,
305+ description : '<unnamed>' ,
297306 op : 'ui.angular.ngAfterViewInit' ,
298307 origin : 'auto.ui.angular.trace_method_decorator' ,
299308 start_timestamp : expect . any ( Number ) ,
0 commit comments