File tree Expand file tree Collapse file tree 2 files changed +17
-11
lines changed Expand file tree Collapse file tree 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 {
127127 /**
128128 * @inheritDoc
129129 */
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+
133134 this . getStack ( ) . push ( {
134135 client : this . getClient ( ) ,
135- scope,
136+ scope : newScope ,
136137 } ) ;
137- return scope ;
138+
139+ return newScope ;
138140 }
139141
140142 /**
Original file line number Diff line number Diff line change @@ -35,14 +35,18 @@ export interface Hub {
3535 /**
3636 * Create a new scope to store context information.
3737 *
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.
4240 *
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
4448 */
45- pushScope ( ) : Scope ;
49+ pushScope ( scope ?: Scope ) : Scope ;
4650
4751 /**
4852 * Removes a previously pushed scope from the stack.
You can’t perform that action at this time.
0 commit comments