@@ -110,27 +110,33 @@ export class Scope implements ScopeInterface {
110110
111111 /**
112112 * Inherit values from the parent scope.
113- * @param scope to clone .
113+ * @deprecated Use ` scope.clone()` and `new Scope()` instead .
114114 */
115115 public static clone ( scope ?: Scope ) : Scope {
116+ return scope ? scope . clone ( ) : new Scope ( ) ;
117+ }
118+
119+ /**
120+ * Clone this scope instance.
121+ */
122+ public clone ( ) : Scope {
116123 const newScope = new Scope ( ) ;
117- if ( scope ) {
118- newScope . _breadcrumbs = [ ...scope . _breadcrumbs ] ;
119- newScope . _tags = { ...scope . _tags } ;
120- newScope . _extra = { ...scope . _extra } ;
121- newScope . _contexts = { ...scope . _contexts } ;
122- newScope . _user = scope . _user ;
123- newScope . _level = scope . _level ;
124- newScope . _span = scope . _span ;
125- newScope . _session = scope . _session ;
126- newScope . _transactionName = scope . _transactionName ;
127- newScope . _fingerprint = scope . _fingerprint ;
128- newScope . _eventProcessors = [ ...scope . _eventProcessors ] ;
129- newScope . _requestSession = scope . _requestSession ;
130- newScope . _attachments = [ ...scope . _attachments ] ;
131- newScope . _sdkProcessingMetadata = { ...scope . _sdkProcessingMetadata } ;
132- newScope . _propagationContext = { ...scope . _propagationContext } ;
133- }
124+ newScope . _breadcrumbs = [ ...this . _breadcrumbs ] ;
125+ newScope . _tags = { ...this . _tags } ;
126+ newScope . _extra = { ...this . _extra } ;
127+ newScope . _contexts = { ...this . _contexts } ;
128+ newScope . _user = this . _user ;
129+ newScope . _level = this . _level ;
130+ newScope . _span = this . _span ;
131+ newScope . _session = this . _session ;
132+ newScope . _transactionName = this . _transactionName ;
133+ newScope . _fingerprint = this . _fingerprint ;
134+ newScope . _eventProcessors = [ ...this . _eventProcessors ] ;
135+ newScope . _requestSession = this . _requestSession ;
136+ newScope . _attachments = [ ...this . _attachments ] ;
137+ newScope . _sdkProcessingMetadata = { ...this . _sdkProcessingMetadata } ;
138+ newScope . _propagationContext = { ...this . _propagationContext } ;
139+
134140 return newScope ;
135141 }
136142
0 commit comments