Skip to content

Commit 99c9af0

Browse files
committed
port configureScope
1 parent 091524b commit 99c9af0

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

packages/hub/src/exports.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { CaptureContext, Event, Hub, Severity, SeverityLevel } from '@sentry/types';
1+
import { CaptureContext, Event, Severity, SeverityLevel } from '@sentry/types';
22

3-
import { getCurrentHub } from './hub';
3+
import { getCurrentHub, Hub } from './hub';
4+
import { Scope } from './scope';
45

56
/**
67
* This calls a function on the current hub.
@@ -24,7 +25,7 @@ export function callOnHub<T>(method: string, ...args: any[]): T {
2425
* @returns The generated eventId.
2526
*/
2627
// 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']> {
2829
return getCurrentHub().captureException(exception, { captureContext });
2930
}
3031

@@ -39,7 +40,7 @@ export function captureMessage(
3940
message: string,
4041
// eslint-disable-next-line deprecation/deprecation
4142
captureContext?: CaptureContext | Severity | SeverityLevel,
42-
): string {
43+
): ReturnType<Hub['captureMessage']> {
4344
// This is necessary to provide explicit scopes upgrade, without changing the original
4445
// arity of the `captureMessage(message, level)` method.
4546
const level = typeof captureContext === 'string' ? captureContext : undefined;
@@ -53,6 +54,14 @@ export function captureMessage(
5354
* @param event The event to send to Sentry.
5455
* @returns The generated eventId.
5556
*/
56-
export function captureEvent(event: Event): string {
57+
export function captureEvent(event: Event): ReturnType<Hub['captureEvent']> {
5758
return getCurrentHub().captureEvent(event);
5859
}
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+
}

packages/minimal/src/index.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,6 @@ function callOnHub<T>(method: string, ...args: any[]): T {
2929
throw new Error(`No hub defined or ${method} was not found on the hub, please open a bug report.`);
3030
}
3131

32-
/**
33-
* Callback to set context information onto the scope.
34-
* @param callback Callback function that receives Scope.
35-
*/
36-
export function configureScope(callback: (scope: Scope) => void): void {
37-
callOnHub<void>('configureScope', callback);
38-
}
39-
4032
/**
4133
* Records a new breadcrumb which will be attached to future events.
4234
*

0 commit comments

Comments
 (0)