Skip to content

feat(v8): Remove deprecated configureScope call #10565

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,20 @@ The `enableAnrDetection` and `Anr` class have been removed. See the
[docs](https://docs.sentry.io/platforms/node/configuration/application-not-responding/) for more details how to migrate
to `anrIntegration`, the new integration for ANR detection.

## Other changes
## Removal of `Sentry.configureScope` (#10565)

The top level `Sentry.configureScope` function has been removed. Instead, you should use the `Sentry.getCurrentScope()`
to access and mutate the current scope.

## Deletion of `@sentry/hub` package (#10530)

`@sentry/hub` has been removed. All exports from `@sentry.hub` should be available in `@sentry/core`.

## General API Changes

- Remove `spanStatusfromHttpCode` in favour of `getSpanStatusFromHttpCode` (#10361)
- Remove deprecated `deepReadDirSync` export from `@sentry/node` (#10564)
- Remove `_eventFromIncompleteOnError` usage (#10553)

# Deprecations in 7.x

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ document.getElementById('go-background').addEventListener('click', () => {

document.getElementById('start-transaction').addEventListener('click', () => {
window.transaction = Sentry.startTransaction({ name: 'test-transaction' });
Sentry.getCurrentHub().configureScope(scope => scope.setSpan(window.transaction));
Sentry.getCurrentScope().setSpan(window.transaction);
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ document.getElementById('go-background').addEventListener('click', () => {

document.getElementById('start-transaction').addEventListener('click', () => {
window.transaction = Sentry.startTransaction({ name: 'test-transaction' });
Sentry.getCurrentHub().configureScope(scope => scope.setSpan(window.transaction));
Sentry.getCurrentScope().setSpan(window.transaction);
});
2 changes: 0 additions & 2 deletions packages/astro/src/index.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ export {
captureMessage,
captureCheckIn,
withMonitor,
// eslint-disable-next-line deprecation/deprecation
configureScope,
createTransport,
// eslint-disable-next-line deprecation/deprecation
extractTraceparentData,
Expand Down
9 changes: 3 additions & 6 deletions packages/browser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,9 @@ functions will not perform any action before you have called `Sentry.init()`:
import * as Sentry from '@sentry/browser';

// Set user information, as well as tags and further extras
Sentry.configureScope(scope => {
scope.setExtra('battery', 0.7);
scope.setTag('user_mode', 'admin');
scope.setUser({ id: '4711' });
// scope.clear();
});
Sentry.setExtra('battery', 0.7);
Sentry.setTag('user_mode', 'admin');
Sentry.setUser({ id: '4711' });

// Add a breadcrumb for future events
Sentry.addBreadcrumb({
Expand Down
2 changes: 0 additions & 2 deletions packages/browser/src/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ export {
captureEvent,
captureMessage,
close,
// eslint-disable-next-line deprecation/deprecation
configureScope,
createTransport,
flush,
getHubFromCarrier,
Expand Down
1 change: 1 addition & 0 deletions packages/browser/src/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
'captureMessage',
'captureException',
'captureEvent',
// TODO: Remove configureScope from loader
'configureScope',
'withScope',
'showReportDialog'
Expand Down
11 changes: 0 additions & 11 deletions packages/browser/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,6 @@ declare const __SENTRY_RELEASE__: string | undefined;
* @example
* ```
*
* import { configureScope } from '@sentry/browser';
* configureScope((scope: Scope) => {
* scope.setExtra({ battery: 0.7 });
* scope.setTag({ user_mode: 'admin' });
* scope.setUser({ id: '4711' });
* });
* ```
*
* @example
* ```
*
* import { addBreadcrumb } from '@sentry/browser';
* addBreadcrumb({
* message: 'My Breadcrumb',
Expand Down
13 changes: 6 additions & 7 deletions packages/browser/test/package/test-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ Sentry.init({
});

// Configure
Sentry.configureScope(scope => {
scope.setExtra('foo', 'bar');
scope.setFingerprint('foo');
scope.setLevel('warning');
scope.setTag('foo', 'bar');
scope.setUser('foo', 'bar');
});
const scope = Sentry.getCurrentScope();
scope.setExtra('foo', 'bar');
scope.setFingerprint('foo');
scope.setLevel('warning');
scope.setTag('foo', 'bar');
scope.setUser('foo', 'bar');

// Breadcrumbs integration
window.console.log('Console', 'Breadcrumb');
Expand Down
9 changes: 3 additions & 6 deletions packages/bun/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,9 @@ functions will not perform any action before you have called `init()`:

```javascript
// Set user information, as well as tags and further extras
Sentry.configureScope(scope => {
scope.setExtra('battery', 0.7);
scope.setTag('user_mode', 'admin');
scope.setUser({ id: '4711' });
// scope.clear();
});
Sentry.setExtra('battery', 0.7);
Sentry.setTag('user_mode', 'admin');
Sentry.setUser({ id: '4711' });

// Add a breadcrumb for future events
Sentry.addBreadcrumb({
Expand Down
2 changes: 0 additions & 2 deletions packages/bun/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ export {
captureEvent,
captureMessage,
close,
// eslint-disable-next-line deprecation/deprecation
configureScope,
createTransport,
// eslint-disable-next-line deprecation/deprecation
extractTraceparentData,
Expand Down
11 changes: 0 additions & 11 deletions packages/bun/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,6 @@ export function getDefaultIntegrations(_options: Options): Integration[] {
* @example
* ```
*
* const { configureScope } = require('@sentry/node');
* configureScope((scope: Scope) => {
* scope.setExtra({ battery: 0.7 });
* scope.setTag({ user_mode: 'admin' });
* scope.setUser({ id: '4711' });
* });
* ```
*
* @example
* ```
*
* const { addBreadcrumb } = require('@sentry/node');
* addBreadcrumb({
* message: 'My Breadcrumb',
Expand Down
11 changes: 0 additions & 11 deletions packages/core/src/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,6 @@ export function captureEvent(event: Event, hint?: EventHint): string {
return getCurrentHub().captureEvent(event, hint);
}

/**
* Callback to set context information onto the scope.
* @param callback Callback function that receives Scope.
*
* @deprecated Use getCurrentScope() directly.
*/
export function configureScope(callback: (scope: Scope) => void): ReturnType<Hub['configureScope']> {
// eslint-disable-next-line deprecation/deprecation
getCurrentHub().configureScope(callback);
}

/**
* Records a new breadcrumb which will be attached to future events.
*
Expand Down
13 changes: 0 additions & 13 deletions packages/core/src/hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,19 +507,6 @@ export class Hub implements HubInterface {
this.getIsolationScope().setContext(name, context);
}

/**
* @inheritDoc
*
* @deprecated Use `getScope()` directly.
*/
public configureScope(callback: (scope: Scope) => void): void {
// eslint-disable-next-line deprecation/deprecation
const { scope, client } = this.getStackTop();
if (client) {
callback(scope);
}
}

/**
* @inheritDoc
*/
Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ export {
captureEvent,
captureMessage,
close,
// eslint-disable-next-line deprecation/deprecation
configureScope,
flush,
// eslint-disable-next-line deprecation/deprecation
startTransaction,
Expand Down
9 changes: 3 additions & 6 deletions packages/deno/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,9 @@ functions will not perform any action before you have called `init()`:

```javascript
// Set user information, as well as tags and further extras
Sentry.configureScope(scope => {
scope.setExtra('battery', 0.7);
scope.setTag('user_mode', 'admin');
scope.setUser({ id: '4711' });
// scope.clear();
});
Sentry.setExtra('battery', 0.7);
Sentry.setTag('user_mode', 'admin');
Sentry.setUser({ id: '4711' });

// Add a breadcrumb for future events
Sentry.addBreadcrumb({
Expand Down
2 changes: 0 additions & 2 deletions packages/deno/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ export {
captureEvent,
captureMessage,
close,
// eslint-disable-next-line deprecation/deprecation
configureScope,
createTransport,
// eslint-disable-next-line deprecation/deprecation
extractTraceparentData,
Expand Down
11 changes: 0 additions & 11 deletions packages/deno/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,6 @@ const defaultStackParser: StackParser = createStackParser(nodeStackLineParser())
* @example
* ```
*
* import { configureScope } from 'npm:@sentry/deno';
* configureScope((scope: Scope) => {
* scope.setExtra({ battery: 0.7 });
* scope.setTag({ user_mode: 'admin' });
* scope.setUser({ id: '4711' });
* });
* ```
*
* @example
* ```
*
* import { addBreadcrumb } from 'npm:@sentry/deno';
* addBreadcrumb({
* message: 'My Breadcrumb',
Expand Down
9 changes: 3 additions & 6 deletions packages/nextjs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,9 @@ To set context information or send manual events, use the exported functions of
import * as Sentry from '@sentry/nextjs';

// Set user information, as well as tags and further extras
Sentry.configureScope(scope => {
scope.setExtra('battery', 0.7);
scope.setTag('user_mode', 'admin');
scope.setUser({ id: '4711' });
// scope.clear();
});
Sentry.setExtra('battery', 0.7);
Sentry.setTag('user_mode', 'admin');
Sentry.setUser({ id: '4711' });

// Add a breadcrumb for future events
Sentry.addBreadcrumb({
Expand Down
14 changes: 6 additions & 8 deletions packages/nextjs/vercel/install-sentry-from-branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,12 @@ Error.stackTraceLimit = Infinity;

SDK_COMMIT_MESSAGE=$(cd sentry-javascript && git log --format="%C(auto)%s" | head -n 1)
CONFIGURE_SCOPE_CODE="
Sentry.configureScope(scope => {
if (process.env.VERCEL) {
scope.setTag('vercel', true);
}
scope.setTag('commitMessage', process.env.VERCEL_GIT_COMMIT_MESSAGE);
scope.setTag('sdkCommitMessage', \"$SDK_COMMIT_MESSAGE\");
});
"
if (process.env.VERCEL) {
Sentry.setTag('vercel', true);
}
Sentry.setTag('commitMessage', process.env.VERCEL_GIT_COMMIT_MESSAGE);
Sentry.setTag('sdkCommitMessage', \"$SDK_COMMIT_MESSAGE\");
"

echo "$INFINITE_STACKTRACE_CODE" "$CONFIGURE_SCOPE_CODE" >>sentry.server.config.js
echo "$INFINITE_STACKTRACE_CODE" "$CONFIGURE_SCOPE_CODE" >>sentry.client.config.js
Expand Down
2 changes: 0 additions & 2 deletions packages/node-experimental/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ export {
withScope,
withIsolationScope,
withActiveSpan,
// eslint-disable-next-line deprecation/deprecation
configureScope,
getCurrentScope,
getGlobalScope,
getIsolationScope,
Expand Down
8 changes: 0 additions & 8 deletions packages/node-experimental/src/sdk/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,6 @@ export function withIsolationScope<T>(callback: (isolationScope: Scope) => T): T
});
}

/**
* Configure the current scope.
* @deprecated Use `getCurrentScope()` instead.
*/
export function configureScope(callback: (scope: Scope) => void): void {
callback(getCurrentScope());
}

/** Record an exception and send it to Sentry. */
export function captureException(exception: unknown, hint?: ExclusiveEventHintOrCaptureContext): string {
return getCurrentScope().captureException(exception, parseEventHintOrCaptureContext(hint));
Expand Down
3 changes: 0 additions & 3 deletions packages/node-experimental/src/sdk/hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { endSession, startSession } from '@sentry/core';
import {
addBreadcrumb,
captureEvent,
configureScope,
getClient,
getCurrentScope,
setContext,
Expand Down Expand Up @@ -77,8 +76,6 @@ export function getCurrentHub(): Hub {
setExtra,
setExtras,
setContext,
// eslint-disable-next-line deprecation/deprecation
configureScope: configureScope,

run(callback: (hub: Hub) => void): void {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
Loading