Skip to content

Commit a2670a3

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

File tree

19 files changed

+32
-8
lines changed

19 files changed

+32
-8
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/e2e-tests/test-applications/node-hapi-app/event-proxy-server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import type { Envelope, EnvelopeItem, Event } from '@sentry/types';
2-
import { parseEnvelope } from '@sentry/utils';
31
import * as fs from 'fs';
42
import * as http from 'http';
53
import * as https from 'https';
@@ -8,6 +6,8 @@ import * as os from 'os';
86
import * as path from 'path';
97
import * as util from 'util';
108
import * as zlib from 'zlib';
9+
import type { Envelope, EnvelopeItem, Event } from '@sentry/types';
10+
import { parseEnvelope } from '@sentry/utils';
1111

1212
const readFile = util.promisify(fs.readFile);
1313
const writeFile = util.promisify(fs.writeFile);

packages/e2e-tests/test-applications/node-hapi-app/tests/server.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { test, expect } from '@playwright/test';
1+
import { expect, test } from '@playwright/test';
22
import axios, { AxiosError, AxiosResponse } from 'axios';
33
import { waitForError, waitForTransaction } from '../event-proxy-server';
44

0 commit comments

Comments
 (0)