@@ -19,65 +19,15 @@ import type {
19
19
User ,
20
20
} from '@sentry/types' ;
21
21
import { GLOBAL_OBJ , consoleSandbox , dateTimestampInSeconds } from '@sentry/utils' ;
22
-
23
22
import { getScopesFromContext , setScopesOnContext } from '../utils/contextData' ;
23
+
24
24
import type { ExclusiveEventHintOrCaptureContext } from '../utils/prepareEvent' ;
25
25
import { parseEventHintOrCaptureContext } from '../utils/prepareEvent' ;
26
- import { getGlobalCarrier } from './globals' ;
27
- import { Scope } from './scope' ;
28
- import type { CurrentScopes , SentryCarrier } from './types' ;
29
-
30
- /** Get the currently active client. */
31
- export function getClient < C extends Client > ( ) : C {
32
- const currentScope = getCurrentScope ( ) ;
33
- const isolationScope = getIsolationScope ( ) ;
34
- const globalScope = getGlobalScope ( ) ;
35
-
36
- const client = currentScope . getClient ( ) || isolationScope . getClient ( ) || globalScope . getClient ( ) ;
37
- if ( client ) {
38
- return client as C ;
39
- }
40
-
41
- // TODO otherwise ensure we use a noop client
42
- return { } as C ;
43
- }
26
+ import type { Scope } from './scope' ;
27
+ import { getClient , getCurrentScope , getGlobalScope , getIsolationScope } from './scope' ;
44
28
45
- /** Get the current scope. */
46
- export function getCurrentScope ( ) : Scope {
47
- return getScopes ( ) . scope as Scope ;
48
- }
49
-
50
- /**
51
- * Set the current scope on the execution context.
52
- * This should mostly only be called in Sentry.init()
53
- */
54
- export function setCurrentScope ( scope : Scope ) : void {
55
- getScopes ( ) . scope = scope ;
56
- }
57
-
58
- /** Get the global scope. */
59
- export function getGlobalScope ( ) : Scope {
60
- const carrier = getGlobalCarrier ( ) ;
61
-
62
- if ( ! carrier . globalScope ) {
63
- carrier . globalScope = new Scope ( ) ;
64
- }
65
-
66
- return carrier . globalScope as Scope ;
67
- }
68
-
69
- /** Get the currently active isolation scope. */
70
- export function getIsolationScope ( ) : Scope {
71
- return getScopes ( ) . isolationScope as Scope ;
72
- }
73
-
74
- /**
75
- * Set the currently active isolation scope.
76
- * Use this with caution! As it updates the isolation scope for the current execution context.
77
- */
78
- export function setIsolationScope ( isolationScope : Scope ) : void {
79
- getScopes ( ) . isolationScope = isolationScope ;
80
- }
29
+ export { getCurrentScope , getGlobalScope , getIsolationScope , getClient } ;
30
+ export { setCurrentScope , setIsolationScope } from './scope' ;
81
31
82
32
/**
83
33
* Fork a scope from the current scope, and make it the current scope in the given callback
@@ -261,31 +211,6 @@ export function endSession(): void {
261
211
scope . setSession ( ) ;
262
212
}
263
213
264
- function getScopes ( ) : CurrentScopes {
265
- const carrier = getGlobalCarrier ( ) ;
266
-
267
- if ( carrier . acs && carrier . acs . getScopes ) {
268
- const scopes = carrier . acs . getScopes ( ) ;
269
-
270
- if ( scopes ) {
271
- return scopes ;
272
- }
273
- }
274
-
275
- return getGlobalCurrentScopes ( carrier ) ;
276
- }
277
-
278
- function getGlobalCurrentScopes ( carrier : SentryCarrier ) : CurrentScopes {
279
- if ( ! carrier . scopes ) {
280
- carrier . scopes = {
281
- scope : new Scope ( ) ,
282
- isolationScope : new Scope ( ) ,
283
- } ;
284
- }
285
-
286
- return carrier . scopes ;
287
- }
288
-
289
214
/**
290
215
* Sends the current Session on the scope
291
216
*/
0 commit comments