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