11import { Breadcrumb , SentryEvent , SentryEventHint , Severity , User } from '@sentry/types' ;
22import { getGlobalObject } from '@sentry/utils/misc' ;
3- import { assign } from '@sentry/utils/object' ;
3+ import { assign , safeNormalize } from '@sentry/utils/object' ;
44
55export type EventProcessor = ( event : SentryEvent , hint ?: SentryEventHint ) => Promise < SentryEvent | null > ;
66
@@ -85,7 +85,7 @@ export class Scope {
8585 * @param user User context object to merge into current context.
8686 */
8787 public setUser ( user : User ) : Scope {
88- this . user = user ;
88+ this . user = safeNormalize ( user ) ;
8989 this . notifyScopeListeners ( ) ;
9090 return this ;
9191 }
@@ -95,7 +95,7 @@ export class Scope {
9595 * @param tags Tags context object to merge into current context.
9696 */
9797 public setTag ( key : string , value : string ) : Scope {
98- this . tags = { ...this . tags , [ key ] : value } ;
98+ this . tags = { ...this . tags , [ key ] : safeNormalize ( value ) } ;
9999 this . notifyScopeListeners ( ) ;
100100 return this ;
101101 }
@@ -105,7 +105,7 @@ export class Scope {
105105 * @param extra context object to merge into current context.
106106 */
107107 public setExtra ( key : string , extra : any ) : Scope {
108- this . extra = { ...this . extra , [ key ] : extra } ;
108+ this . extra = { ...this . extra , [ key ] : safeNormalize ( extra ) } ;
109109 this . notifyScopeListeners ( ) ;
110110 return this ;
111111 }
@@ -115,7 +115,7 @@ export class Scope {
115115 * @param fingerprint string[] to group events in Sentry.
116116 */
117117 public setFingerprint ( fingerprint : string [ ] ) : Scope {
118- this . fingerprint = fingerprint ;
118+ this . fingerprint = safeNormalize ( fingerprint ) ;
119119 this . notifyScopeListeners ( ) ;
120120 return this ;
121121 }
@@ -125,7 +125,7 @@ export class Scope {
125125 * @param level string {@link Severity}
126126 */
127127 public setLevel ( level : Severity ) : Scope {
128- this . level = level ;
128+ this . level = safeNormalize ( level ) ;
129129 this . notifyScopeListeners ( ) ;
130130 return this ;
131131 }
@@ -167,8 +167,8 @@ export class Scope {
167167 public addBreadcrumb ( breadcrumb : Breadcrumb , maxBreadcrumbs ?: number ) : void {
168168 this . breadcrumbs =
169169 maxBreadcrumbs !== undefined && maxBreadcrumbs >= 0
170- ? [ ...this . breadcrumbs , breadcrumb ] . slice ( - maxBreadcrumbs )
171- : [ ...this . breadcrumbs , breadcrumb ] ;
170+ ? [ ...this . breadcrumbs , safeNormalize ( breadcrumb ) ] . slice ( - maxBreadcrumbs )
171+ : [ ...this . breadcrumbs , safeNormalize ( breadcrumb ) ] ;
172172 this . notifyScopeListeners ( ) ;
173173 }
174174
0 commit comments