-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathindex.ts
31 lines (27 loc) · 953 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import type { Carrier } from './../carrier';
import { getMainCarrier, getSentryCarrier } from './../carrier';
import { getStackAsyncContextStrategy } from './stackStrategy';
import type { AsyncContextStrategy } from './types';
/**
* @private Private API with no semver guarantees!
*
* Sets the global async context strategy
*/
export function setAsyncContextStrategy(strategy: AsyncContextStrategy | undefined): void {
// Get main carrier (global for every environment)
const registry = getMainCarrier();
const sentry = getSentryCarrier(registry);
sentry.acs = strategy;
}
/**
* Get the current async context strategy.
* If none has been setup, the default will be used.
*/
export function getAsyncContextStrategy(carrier: Carrier): AsyncContextStrategy {
const sentry = getSentryCarrier(carrier);
if (sentry.acs) {
return sentry.acs;
}
// Otherwise, use the default one (stack)
return getStackAsyncContextStrategy();
}