File tree 2 files changed +17
-11
lines changed
2 files changed +17
-11
lines changed Original file line number Diff line number Diff line change @@ -127,14 +127,16 @@ export class Hub implements HubInterface {
127
127
/**
128
128
* @inheritDoc
129
129
*/
130
- public pushScope ( ) : Scope {
131
- // We want to clone the content of prev scope
132
- const scope = Scope . clone ( this . getScope ( ) ) ;
130
+ public pushScope ( scope ?: Scope ) : Scope {
131
+ // Use a clone of the current scope if no scope is given
132
+ const newScope = Scope . clone ( scope || this . getScope ( ) ) ;
133
+
133
134
this . getStack ( ) . push ( {
134
135
client : this . getClient ( ) ,
135
- scope,
136
+ scope : newScope ,
136
137
} ) ;
137
- return scope ;
138
+
139
+ return newScope ;
138
140
}
139
141
140
142
/**
Original file line number Diff line number Diff line change @@ -35,14 +35,18 @@ export interface Hub {
35
35
/**
36
36
* Create a new scope to store context information.
37
37
*
38
- * The scope will be layered on top of the current one. It is isolated, i.e. all
39
- * breadcrumbs and context information added to this scope will be removed once
40
- * the scope ends. Be sure to always remove this scope with {@link this.popScope}
41
- * when the operation finishes or throws.
38
+ * If an existing scope is given, it will be cloned and that clone used as the new scope. If no scope is given, a
39
+ * clone of the currently-active scope will be used.
42
40
*
43
- * @returns Scope, the new cloned scope
41
+ * The cloned scope will be layered on top of the current one. It is isolated, i.e. it does not mutate the given scope
42
+ * (if any) or the current scope. So, for example, all breadcrumbs and context information added to this scope will be
43
+ * removed once the scope ends. Be sure to always remove this scope with {@link this.popScope} when the operation
44
+ * finishes or throws.
45
+ *
46
+ * @param scope An existing scope to clone for use as the new scope
47
+ * @returns The newly-active scope
44
48
*/
45
- pushScope ( ) : Scope ;
49
+ pushScope ( scope ?: Scope ) : Scope ;
46
50
47
51
/**
48
52
* Removes a previously pushed scope from the stack.
You can’t perform that action at this time.
0 commit comments