UNPKG

2.55 kBTypeScriptView Raw
1import type { Scope } from '@sentry/types';
2import type { Client } from '@sentry/types';
3/**
4 * Get the currently active scope.
5 */
6export declare function getCurrentScope(): Scope;
7/**
8 * Get the currently active isolation scope.
9 * The isolation scope is active for the current exection context.
10 */
11export declare function getIsolationScope(): Scope;
12/**
13 * Get the global scope.
14 * This scope is applied to _all_ events.
15 */
16export declare function getGlobalScope(): Scope;
17/**
18 * Creates a new scope with and executes the given operation within.
19 * The scope is automatically removed once the operation
20 * finishes or throws.
21 */
22export declare function withScope<T>(callback: (scope: Scope) => T): T;
23/**
24 * Set the given scope as the active scope in the callback.
25 */
26export declare function withScope<T>(scope: Scope | undefined, callback: (scope: Scope) => T): T;
27/**
28 * Attempts to fork the current isolation scope and the current scope based on the current async context strategy. If no
29 * async context strategy is set, the isolation scope and the current scope will not be forked (this is currently the
30 * case, for example, in the browser).
31 *
32 * Usage of this function in environments without async context strategy is discouraged and may lead to unexpected behaviour.
33 *
34 * This function is intended for Sentry SDK and SDK integration development. It is not recommended to be used in "normal"
35 * applications directly because it comes with pitfalls. Use at your own risk!
36 */
37export declare function withIsolationScope<T>(callback: (isolationScope: Scope) => T): T;
38/**
39 * Set the provided isolation scope as active in the given callback. If no
40 * async context strategy is set, the isolation scope and the current scope will not be forked (this is currently the
41 * case, for example, in the browser).
42 *
43 * Usage of this function in environments without async context strategy is discouraged and may lead to unexpected behaviour.
44 *
45 * This function is intended for Sentry SDK and SDK integration development. It is not recommended to be used in "normal"
46 * applications directly because it comes with pitfalls. Use at your own risk!
47 *
48 * If you pass in `undefined` as a scope, it will fork a new isolation scope, the same as if no scope is passed.
49 */
50export declare function withIsolationScope<T>(isolationScope: Scope | undefined, callback: (isolationScope: Scope) => T): T;
51/**
52 * Get the currently active client.
53 */
54export declare function getClient<C extends Client>(): C | undefined;
55//# sourceMappingURL=currentScopes.d.ts.map
\No newline at end of file