1
- import { CaptureContext , Event , Hub , Severity , SeverityLevel } from '@sentry/types' ;
1
+ import { CaptureContext , Event , Severity , SeverityLevel } from '@sentry/types' ;
2
2
3
- import { getCurrentHub } from './hub' ;
3
+ import { getCurrentHub , Hub } from './hub' ;
4
+ import { Scope } from './scope' ;
4
5
5
6
/**
6
7
* This calls a function on the current hub.
@@ -24,7 +25,7 @@ export function callOnHub<T>(method: string, ...args: any[]): T {
24
25
* @returns The generated eventId.
25
26
*/
26
27
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
27
- export function captureException ( exception : any , captureContext ?: CaptureContext ) : string {
28
+ export function captureException ( exception : any , captureContext ?: CaptureContext ) : ReturnType < Hub [ 'captureException' ] > {
28
29
return getCurrentHub ( ) . captureException ( exception , { captureContext } ) ;
29
30
}
30
31
@@ -39,7 +40,7 @@ export function captureMessage(
39
40
message : string ,
40
41
// eslint-disable-next-line deprecation/deprecation
41
42
captureContext ?: CaptureContext | Severity | SeverityLevel ,
42
- ) : string {
43
+ ) : ReturnType < Hub [ 'captureMessage' ] > {
43
44
// This is necessary to provide explicit scopes upgrade, without changing the original
44
45
// arity of the `captureMessage(message, level)` method.
45
46
const level = typeof captureContext === 'string' ? captureContext : undefined ;
@@ -53,6 +54,14 @@ export function captureMessage(
53
54
* @param event The event to send to Sentry.
54
55
* @returns The generated eventId.
55
56
*/
56
- export function captureEvent ( event : Event ) : string {
57
+ export function captureEvent ( event : Event ) : ReturnType < Hub [ 'captureEvent' ] > {
57
58
return getCurrentHub ( ) . captureEvent ( event ) ;
58
59
}
60
+
61
+ /**
62
+ * Callback to set context information onto the scope.
63
+ * @param callback Callback function that receives Scope.
64
+ */
65
+ export function configureScope ( callback : ( scope : Scope ) => void ) : ReturnType < Hub [ 'configureScope' ] > {
66
+ return getCurrentHub ( ) . configureScope ( callback ) ;
67
+ }
0 commit comments