1
1
import { expect , test } from '@playwright/test' ;
2
- import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/browser' ;
3
- import { SEMANTIC_ATTRIBUTE_SENTRY_OP } from '@sentry/core/src' ;
2
+ import { SEMANTIC_ATTRIBUTE_SENTRY_OP , SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core' ;
4
3
import { waitForTransaction } from '../event-proxy-server' ;
5
4
6
5
test ( 'sends a pageload transaction with a parameterized URL' , async ( { page } ) => {
@@ -169,14 +168,16 @@ test.describe('finish routing span', () => {
169
168
// immediately navigate to a different route
170
169
const [ _ , navigationTxn ] = await Promise . all ( [ page . locator ( '#nonExistentLink' ) . click ( ) , navigationTxnPromise ] ) ;
171
170
171
+ const nonExistentRoute = '/non-existent' ;
172
+
172
173
expect ( navigationTxn ) . toMatchObject ( {
173
174
contexts : {
174
175
trace : {
175
176
op : 'navigation' ,
176
177
origin : 'auto.navigation.angular' ,
177
178
} ,
178
179
} ,
179
- transaction : '/non-existent' ,
180
+ transaction : nonExistentRoute ,
180
181
transaction_info : {
181
182
source : 'url' ,
182
183
} ,
@@ -185,7 +186,7 @@ test.describe('finish routing span', () => {
185
186
const routingSpan = navigationTxn . spans ?. find ( span => span . op === 'ui.angular.routing' ) ;
186
187
187
188
expect ( routingSpan ) . toBeDefined ( ) ;
188
- expect ( routingSpan ?. description ) . toBe ( '/nonExistentLink' ) ;
189
+ expect ( routingSpan ?. description ) . toBe ( nonExistentRoute ) ;
189
190
} ) ;
190
191
} ) ;
191
192
@@ -200,25 +201,25 @@ test.describe('TraceDirective', () => {
200
201
// immediately navigate to a different route
201
202
const [ _ , navigationTxn ] = await Promise . all ( [ page . locator ( '#componentTracking' ) . click ( ) , navigationTxnPromise ] ) ;
202
203
203
- const traceDirectiveSpan = navigationTxn . spans ?. find ( span => span . op === 'ui.angular.init' ) ;
204
+ const traceDirectiveSpan = navigationTxn . spans ?. find (
205
+ span => span ?. data && span ?. data [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] === 'auto.ui.angular.trace_directive' ,
206
+ ) ;
204
207
205
208
expect ( traceDirectiveSpan ) . toBeDefined ( ) ;
206
209
expect ( traceDirectiveSpan ) . toEqual (
207
210
expect . objectContaining ( {
208
- description : '<sample-component>' ,
209
- attributes : {
211
+ data : {
210
212
[ SEMANTIC_ATTRIBUTE_SENTRY_OP ] : 'ui.angular.init' ,
211
213
[ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] : 'auto.ui.angular.trace_directive' ,
212
214
} ,
215
+ description : '<sample-component>' ,
213
216
op : 'ui.angular.init' ,
214
217
origin : 'auto.ui.angular.trace_directive' ,
218
+ start_timestamp : expect . any ( Number ) ,
219
+ timestamp : expect . any ( Number ) ,
215
220
} ) ,
216
221
) ;
217
222
} ) ;
218
-
219
- test ( 'finishes tracingSpan after ngAfterViewInit' , ( ) => {
220
- // todo
221
- } ) ;
222
223
} ) ;
223
224
224
225
test . describe ( 'TraceClassDecorator' , ( ) => {
@@ -232,9 +233,25 @@ test.describe('TraceClassDecorator', () => {
232
233
// immediately navigate to a different route
233
234
const [ _ , navigationTxn ] = await Promise . all ( [ page . locator ( '#componentTracking' ) . click ( ) , navigationTxnPromise ] ) ;
234
235
235
- const initSpan = navigationTxn . spans ?. find ( span => span . op === 'ui.angular.init' ) ;
236
+ const classDecoratorSpan = navigationTxn . spans ?. find (
237
+ span => span ?. data && span ?. data [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] === 'auto.ui.angular.trace_class_decorator' ,
238
+ ) ;
236
239
237
- expect ( initSpan ) . toBeDefined ( ) ;
240
+ expect ( classDecoratorSpan ) . toBeDefined ( ) ;
241
+ expect ( classDecoratorSpan ) . toEqual (
242
+ expect . objectContaining ( {
243
+ data : {
244
+ [ SEMANTIC_ATTRIBUTE_SENTRY_OP ] : 'ui.angular.init' ,
245
+ [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] : 'auto.ui.angular.trace_class_decorator' ,
246
+ } ,
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 ) ,
249
+ op : 'ui.angular.init' ,
250
+ origin : 'auto.ui.angular.trace_class_decorator' ,
251
+ start_timestamp : expect . any ( Number ) ,
252
+ timestamp : expect . any ( Number ) ,
253
+ } ) ,
254
+ ) ;
238
255
} ) ;
239
256
} ) ;
240
257
@@ -255,26 +272,32 @@ test.describe('TraceMethodDecorator', () => {
255
272
expect ( ngInitSpan ) . toBeDefined ( ) ;
256
273
expect ( ngInitSpan ) . toEqual (
257
274
expect . objectContaining ( {
258
- description : '<ComponentTrackingComponent>' ,
259
- op : 'ui.angular.ngOnInit' ,
260
- attributes : {
275
+ data : {
261
276
[ SEMANTIC_ATTRIBUTE_SENTRY_OP ] : 'ui.angular.ngOnInit' ,
262
- [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] : 'auto.ui.angular.trace_class_decorator ' ,
277
+ [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] : 'auto.ui.angular.trace_method_decorator ' ,
263
278
} ,
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 ) ,
281
+ op : 'ui.angular.ngOnInit' ,
282
+ origin : 'auto.ui.angular.trace_method_decorator' ,
283
+ start_timestamp : expect . any ( Number ) ,
284
+ timestamp : expect . any ( Number ) ,
264
285
} ) ,
265
286
) ;
266
287
267
288
expect ( ngAfterViewInitSpan ) . toBeDefined ( ) ;
268
289
expect ( ngAfterViewInitSpan ) . toEqual (
269
290
expect . objectContaining ( {
270
- description : '<ComponentTrackingComponent>' ,
271
- op : 'ui.angular.ngAfterViewInit' ,
272
- attributes : {
273
- [ SEMANTIC_ATTRIBUTE_SENTRY_OP ] : 'ui.angular.ngOnInit' ,
291
+ data : {
292
+ [ SEMANTIC_ATTRIBUTE_SENTRY_OP ] : 'ui.angular.ngAfterViewInit' ,
274
293
[ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] : 'auto.ui.angular.trace_method_decorator' ,
275
294
} ,
276
- startTimestamp : expect . any ( Number ) ,
277
- endTimestamp : expect . any ( Number ) ,
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 ) ,
297
+ op : 'ui.angular.ngAfterViewInit' ,
298
+ origin : 'auto.ui.angular.trace_method_decorator' ,
299
+ start_timestamp : expect . any ( Number ) ,
300
+ timestamp : expect . any ( Number ) ,
278
301
} ) ,
279
302
) ;
280
303
} ) ;
0 commit comments