Skip to content

Commit 5f52d9c

Browse files
committed
feat(core): Deprecate configureScope
Instead, users should directly access the current scope via `getCurrentScope()`.
1 parent e1d3633 commit 5f52d9c

File tree

16 files changed

+26
-0
lines changed

16 files changed

+26
-0
lines changed

MIGRATION.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ npx @sentry/migr8@latest
88

99
This will let you select which updates to run, and automatically update your code. Make sure to still review all code changes!
1010

11+
## Deprecate `configureScope` in favor of using `getCurrentScope()`
12+
13+
Instead of updating the scope in a callback via `configureScope()`, you should access it via `getCurrentScope()` and configure it directly:
14+
15+
```js
16+
Sentry.getCurrentScope().setTag('xx', 'yy');
17+
```
18+
1119
## Deprecate `addGlobalEventProcessor` in favor of `addEventProcessor`
1220

1321
Instead of using `addGlobalEventProcessor`, you should use `addEventProcessor` which does not add the event processor globally, but to the current client.

packages/astro/src/index.server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export {
1717
captureMessage,
1818
captureCheckIn,
1919
withMonitor,
20+
// eslint-disable-next-line deprecation/deprecation
2021
configureScope,
2122
createTransport,
2223
// eslint-disable-next-line deprecation/deprecation

packages/browser/src/exports.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export {
3030
captureEvent,
3131
captureMessage,
3232
close,
33+
// eslint-disable-next-line deprecation/deprecation
3334
configureScope,
3435
createTransport,
3536
flush,

packages/bun/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export {
3333
captureEvent,
3434
captureMessage,
3535
close,
36+
// eslint-disable-next-line deprecation/deprecation
3637
configureScope,
3738
createTransport,
3839
// eslint-disable-next-line deprecation/deprecation

packages/core/src/exports.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,11 @@ export function captureEvent(event: Event, hint?: EventHint): ReturnType<Hub['ca
7878
/**
7979
* Callback to set context information onto the scope.
8080
* @param callback Callback function that receives Scope.
81+
*
82+
* @deprecated Use getCurrentScope() directly.
8183
*/
8284
export function configureScope(callback: (scope: Scope) => void): ReturnType<Hub['configureScope']> {
85+
// eslint-disable-next-line deprecation/deprecation
8386
getCurrentHub().configureScope(callback);
8487
}
8588

packages/core/src/hub.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,8 @@ export class Hub implements HubInterface {
335335

336336
/**
337337
* @inheritDoc
338+
*
339+
* @deprecated Use `getScope()` directly.
338340
*/
339341
public configureScope(callback: (scope: Scope) => void): void {
340342
const { scope, client } = this.getStackTop();

packages/core/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export {
1414
captureEvent,
1515
captureMessage,
1616
close,
17+
// eslint-disable-next-line deprecation/deprecation
1718
configureScope,
1819
flush,
1920
lastEventId,

packages/deno/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export {
3131
captureEvent,
3232
captureMessage,
3333
close,
34+
// eslint-disable-next-line deprecation/deprecation
3435
configureScope,
3536
createTransport,
3637
// eslint-disable-next-line deprecation/deprecation

packages/hub/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ export const captureMessage = captureMessageCore;
112112
/**
113113
* @deprecated This export has moved to @sentry/core. The @sentry/hub package will be removed in v8.
114114
*/
115+
// eslint-disable-next-line deprecation/deprecation
115116
export const configureScope = configureScopeCore;
116117

117118
/**

packages/node-experimental/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export {
3232
captureEvent,
3333
captureMessage,
3434
close,
35+
// eslint-disable-next-line deprecation/deprecation
3536
configureScope,
3637
createTransport,
3738
// eslint-disable-next-line deprecation/deprecation

packages/node/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export {
3232
captureEvent,
3333
captureMessage,
3434
close,
35+
// eslint-disable-next-line deprecation/deprecation
3536
configureScope,
3637
createTransport,
3738
// eslint-disable-next-line deprecation/deprecation

packages/remix/src/index.server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export {
2020
captureException,
2121
captureEvent,
2222
captureMessage,
23+
// eslint-disable-next-line deprecation/deprecation
2324
configureScope,
2425
createTransport,
2526
// eslint-disable-next-line deprecation/deprecation

packages/serverless/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export {
2424
captureMessage,
2525
captureCheckIn,
2626
withMonitor,
27+
// eslint-disable-next-line deprecation/deprecation
2728
configureScope,
2829
createTransport,
2930
getActiveTransaction,

packages/sveltekit/src/server/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export {
1414
captureMessage,
1515
captureCheckIn,
1616
withMonitor,
17+
// eslint-disable-next-line deprecation/deprecation
1718
configureScope,
1819
createTransport,
1920
// eslint-disable-next-line deprecation/deprecation

packages/types/src/hub.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ export interface Hub {
171171
* Callback to set context information onto the scope.
172172
*
173173
* @param callback Callback function that receives Scope.
174+
* @deprecated Use `getScope()` directly.
174175
*/
175176
configureScope(callback: (scope: Scope) => void): void;
176177

packages/vercel-edge/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export {
3232
captureEvent,
3333
captureMessage,
3434
close,
35+
// eslint-disable-next-line deprecation/deprecation
3536
configureScope,
3637
createTransport,
3738
// eslint-disable-next-line deprecation/deprecation

0 commit comments

Comments
 (0)