File tree Expand file tree Collapse file tree 3 files changed +47
-3
lines changed
dev-packages/e2e-tests/test-applications/angular-17 Expand file tree Collapse file tree 3 files changed +47
-3
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,8 @@ import { Observable, map } from 'rxjs';
88 standalone : true ,
99 imports : [ AsyncPipe ] ,
1010 template : `
11- <h1>Hello User {{ userId$ | async }}</h1>
11+ <h1>Hello User {{ userId$ | async }}</h1>
12+ <button id="userErrorBtn" (click)="throwError()">Throw error</button>
1213 ` ,
1314} )
1415export class UserComponent {
@@ -17,4 +18,8 @@ export class UserComponent {
1718 constructor ( private route : ActivatedRoute ) {
1819 this . userId$ = this . route . paramMap . pipe ( map ( params => params . get ( 'id' ) || 'UNKNOWN USER' ) ) ;
1920 }
21+
22+ throwError ( ) {
23+ throw new Error ( 'Error thrown from user page' ) ;
24+ }
2025}
Original file line number Diff line number Diff line change 11import { expect , test } from '@playwright/test' ;
2- import { waitForError } from '../event-proxy-server' ;
2+ import { waitForError , waitForTransaction } from '../event-proxy-server' ;
33
44test ( 'sends an error' , async ( { page } ) => {
55 const errorPromise = waitForError ( 'angular-17' , async errorEvent => {
@@ -25,5 +25,41 @@ test('sends an error', async ({ page }) => {
2525 } ,
2626 ] ,
2727 } ,
28+ transaction : '/home/' ,
29+ } ) ;
30+ } ) ;
31+
32+ test ( 'assigns the correct transaction value after a navigation' , async ( { page } ) => {
33+ const pageloadTxnPromise = waitForTransaction ( 'angular-17' , async transactionEvent => {
34+ return ! ! transactionEvent ?. transaction && transactionEvent . contexts ?. trace ?. op === 'pageload' ;
35+ } ) ;
36+
37+ const errorPromise = waitForError ( 'angular-17' , async errorEvent => {
38+ return ! errorEvent . type ;
39+ } ) ;
40+
41+ await page . goto ( `/` ) ;
42+ await pageloadTxnPromise ;
43+
44+ await page . waitForTimeout ( 5000 ) ;
45+
46+ await page . locator ( '#navLink' ) . click ( ) ;
47+
48+ const [ _ , error ] = await Promise . all ( [ page . locator ( '#userErrorBtn' ) . click ( ) , errorPromise ] ) ;
49+
50+ expect ( error ) . toMatchObject ( {
51+ exception : {
52+ values : [
53+ {
54+ type : 'Error' ,
55+ value : 'Error thrown from user page' ,
56+ mechanism : {
57+ type : 'angular' ,
58+ handled : false ,
59+ } ,
60+ } ,
61+ ] ,
62+ } ,
63+ transaction : '/users/:id/' ,
2864 } ) ;
2965} ) ;
Original file line number Diff line number Diff line change @@ -143,10 +143,13 @@ export class TraceService implements OnDestroy {
143143 ( event . state as unknown as RouterState & { root : ActivatedRouteSnapshot } ) . root ,
144144 ) ;
145145
146+ if ( route ) {
147+ getCurrentScope ( ) . setTransactionName ( route ) ;
148+ }
149+
146150 const activeSpan = getActiveSpan ( ) ;
147151 const rootSpan = activeSpan && getRootSpan ( activeSpan ) ;
148152
149- // TODO (v8 / #5416): revisit the source condition. Do we want to make the parameterized route the default?
150153 _updateSpanAttributesForParametrizedUrl ( route , rootSpan ) ;
151154 } ) ,
152155 ) ;
You can’t perform that action at this time.
0 commit comments