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';
8
8
standalone : true ,
9
9
imports : [ AsyncPipe ] ,
10
10
template : `
11
- <h1>Hello User {{ userId$ | async }}</h1>
11
+ <h1>Hello User {{ userId$ | async }}</h1>
12
+ <button id="userErrorBtn" (click)="throwError()">Throw error</button>
12
13
` ,
13
14
} )
14
15
export class UserComponent {
@@ -17,4 +18,8 @@ export class UserComponent {
17
18
constructor ( private route : ActivatedRoute ) {
18
19
this . userId$ = this . route . paramMap . pipe ( map ( params => params . get ( 'id' ) || 'UNKNOWN USER' ) ) ;
19
20
}
21
+
22
+ throwError ( ) {
23
+ throw new Error ( 'Error thrown from user page' ) ;
24
+ }
20
25
}
Original file line number Diff line number Diff line change 1
1
import { expect , test } from '@playwright/test' ;
2
- import { waitForError } from '../event-proxy-server' ;
2
+ import { waitForError , waitForTransaction } from '../event-proxy-server' ;
3
3
4
4
test ( 'sends an error' , async ( { page } ) => {
5
5
const errorPromise = waitForError ( 'angular-17' , async errorEvent => {
@@ -25,5 +25,41 @@ test('sends an error', async ({ page }) => {
25
25
} ,
26
26
] ,
27
27
} ,
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/' ,
28
64
} ) ;
29
65
} ) ;
Original file line number Diff line number Diff line change @@ -143,10 +143,13 @@ export class TraceService implements OnDestroy {
143
143
( event . state as unknown as RouterState & { root : ActivatedRouteSnapshot } ) . root ,
144
144
) ;
145
145
146
+ if ( route ) {
147
+ getCurrentScope ( ) . setTransactionName ( route ) ;
148
+ }
149
+
146
150
const activeSpan = getActiveSpan ( ) ;
147
151
const rootSpan = activeSpan && getRootSpan ( activeSpan ) ;
148
152
149
- // TODO (v8 / #5416): revisit the source condition. Do we want to make the parameterized route the default?
150
153
_updateSpanAttributesForParametrizedUrl ( route , rootSpan ) ;
151
154
} ) ,
152
155
) ;
You can’t perform that action at this time.
0 commit comments