1
1
import { Breadcrumb , SentryEvent , SentryEventHint , Severity , User } from '@sentry/types' ;
2
2
import { getGlobalObject } from '@sentry/utils/misc' ;
3
- import { assign } from '@sentry/utils/object' ;
3
+ import { assign , safeNormalize } from '@sentry/utils/object' ;
4
4
5
5
export type EventProcessor = ( event : SentryEvent , hint ?: SentryEventHint ) => Promise < SentryEvent | null > ;
6
6
@@ -85,7 +85,7 @@ export class Scope {
85
85
* @param user User context object to merge into current context.
86
86
*/
87
87
public setUser ( user : User ) : Scope {
88
- this . user = user ;
88
+ this . user = safeNormalize ( user ) ;
89
89
this . notifyScopeListeners ( ) ;
90
90
return this ;
91
91
}
@@ -95,7 +95,7 @@ export class Scope {
95
95
* @param tags Tags context object to merge into current context.
96
96
*/
97
97
public setTag ( key : string , value : string ) : Scope {
98
- this . tags = { ...this . tags , [ key ] : value } ;
98
+ this . tags = { ...this . tags , [ key ] : safeNormalize ( value ) } ;
99
99
this . notifyScopeListeners ( ) ;
100
100
return this ;
101
101
}
@@ -105,7 +105,7 @@ export class Scope {
105
105
* @param extra context object to merge into current context.
106
106
*/
107
107
public setExtra ( key : string , extra : any ) : Scope {
108
- this . extra = { ...this . extra , [ key ] : extra } ;
108
+ this . extra = { ...this . extra , [ key ] : safeNormalize ( extra ) } ;
109
109
this . notifyScopeListeners ( ) ;
110
110
return this ;
111
111
}
@@ -115,7 +115,7 @@ export class Scope {
115
115
* @param fingerprint string[] to group events in Sentry.
116
116
*/
117
117
public setFingerprint ( fingerprint : string [ ] ) : Scope {
118
- this . fingerprint = fingerprint ;
118
+ this . fingerprint = safeNormalize ( fingerprint ) ;
119
119
this . notifyScopeListeners ( ) ;
120
120
return this ;
121
121
}
@@ -125,7 +125,7 @@ export class Scope {
125
125
* @param level string {@link Severity}
126
126
*/
127
127
public setLevel ( level : Severity ) : Scope {
128
- this . level = level ;
128
+ this . level = safeNormalize ( level ) ;
129
129
this . notifyScopeListeners ( ) ;
130
130
return this ;
131
131
}
@@ -167,8 +167,8 @@ export class Scope {
167
167
public addBreadcrumb ( breadcrumb : Breadcrumb , maxBreadcrumbs ?: number ) : void {
168
168
this . breadcrumbs =
169
169
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 ) ] ;
172
172
this . notifyScopeListeners ( ) ;
173
173
}
174
174
0 commit comments