@@ -476,7 +476,7 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
476476 return null ;
477477 }
478478
479- const normalized = {
479+ const normalized : Event = {
480480 ...event ,
481481 ...( event . breadcrumbs && {
482482 breadcrumbs : event . breadcrumbs . map ( b => ( {
@@ -496,6 +496,7 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
496496 extra : normalize ( event . extra , depth , maxBreadth ) ,
497497 } ) ,
498498 } ;
499+
499500 // event.contexts.trace stores information about a Transaction. Similarly,
500501 // event.spans[] stores information about child Spans. Given that a
501502 // Transaction is conceptually a Span, normalization should apply to both
@@ -504,16 +505,24 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
504505 // so this block overwrites the normalized event to add back the original
505506 // Transaction information prior to normalization.
506507 if ( event . contexts && event . contexts . trace ) {
507- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
508+ normalized . contexts = { } ;
508509 normalized . contexts . trace = event . contexts . trace ;
509510
510511 // event.contexts.trace.data may contain circular/dangerous data so we need to normalize it
511512 if ( event . contexts . trace . data ) {
512- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
513513 normalized . contexts . trace . data = normalize ( event . contexts . trace . data , depth , maxBreadth ) ;
514514 }
515515 }
516516
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+
517526 normalized . sdkProcessingMetadata = { ...normalized . sdkProcessingMetadata , baseClientNormalized : true } ;
518527
519528 return normalized ;
0 commit comments