@@ -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,8 +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 ;
510
+
511
+ // event.contexts.trace.data may contain circular/dangerous data so we need to normalize it
512
+ if ( event . contexts . trace . data ) {
513
+ normalized . contexts . trace . data = normalize ( event . contexts . trace . data , depth , maxBreadth ) ;
514
+ }
515
+ }
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 here because `toJSON` on `span` is non-enumerable
521
+ if ( span . data ) {
522
+ span . data = normalize ( span . data , depth , maxBreadth ) ;
523
+ }
524
+ return span ;
525
+ } ) ;
509
526
}
510
527
511
528
normalized . sdkProcessingMetadata = { ...normalized . sdkProcessingMetadata , baseClientNormalized : true } ;
0 commit comments