@@ -476,7 +476,7 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
476
476
return null ;
477
477
}
478
478
479
- const normalized = {
479
+ const normalized : Event = {
480
480
...event ,
481
481
...( event . breadcrumbs && {
482
482
breadcrumbs : event . breadcrumbs . map ( b => ( {
@@ -496,6 +496,7 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
496
496
extra : normalize ( event . extra , depth , maxBreadth ) ,
497
497
} ) ,
498
498
} ;
499
+
499
500
// event.contexts.trace stores information about a Transaction. Similarly,
500
501
// event.spans[] stores information about child Spans. Given that a
501
502
// Transaction is conceptually a Span, normalization should apply to both
@@ -504,16 +505,24 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
504
505
// so this block overwrites the normalized event to add back the original
505
506
// Transaction information prior to normalization.
506
507
if ( event . contexts && event . contexts . trace ) {
507
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
508
+ normalized . contexts = { } ;
508
509
normalized . contexts . trace = event . contexts . trace ;
509
510
510
511
// event.contexts.trace.data may contain circular/dangerous data so we need to normalize it
511
512
if ( event . contexts . trace . data ) {
512
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
513
513
normalized . contexts . trace . data = normalize ( event . contexts . trace . data , depth , maxBreadth ) ;
514
514
}
515
515
}
516
516
517
+ // event.spans[].data may contain circular/dangerous data so we need to normalize it
518
+ if ( event . spans ) {
519
+ normalized . spans = event . spans . map ( span => {
520
+ // We cannot use the spread operator on span here because that overwrites the `toJSON` method
521
+ span . data = normalize ( span . data , depth , maxBreadth ) ;
522
+ return span ;
523
+ } ) ;
524
+ }
525
+
517
526
normalized . sdkProcessingMetadata = { ...normalized . sdkProcessingMetadata , baseClientNormalized : true } ;
518
527
519
528
return normalized ;
0 commit comments