diff --git a/packages/core/src/tracing/trace.ts b/packages/core/src/tracing/trace.ts index 2548d94fd60e..738b7ab601a3 100644 --- a/packages/core/src/tracing/trace.ts +++ b/packages/core/src/tracing/trace.ts @@ -1,12 +1,4 @@ -import type { - ClientOptions, - Hub, - Scope, - Span, - SpanTimeInput, - StartSpanOptions, - TransactionContext, -} from '@sentry/types'; +import type { ClientOptions, Scope, Span, SpanTimeInput, StartSpanOptions, TransactionContext } from '@sentry/types'; import { propagationContextFromHeaders } from '@sentry/utils'; import type { AsyncContextStrategy } from '../asyncContext'; @@ -51,15 +43,13 @@ export function startSpan(context: StartSpanOptions, callback: (span: Span) = const spanContext = normalizeContext(context); return withScope(context.scope, scope => { - // eslint-disable-next-line deprecation/deprecation - const hub = getCurrentHub(); // eslint-disable-next-line deprecation/deprecation const parentSpan = scope.getSpan() as SentrySpan | undefined; const shouldSkipSpan = context.onlyIfParent && !parentSpan; const activeSpan = shouldSkipSpan ? new SentryNonRecordingSpan() - : createChildSpanOrTransaction(hub, { + : createChildSpanOrTransaction({ parentSpan, spanContext, forceTransaction: context.forceTransaction, @@ -103,15 +93,13 @@ export function startSpanManual(context: StartSpanOptions, callback: (span: S const spanContext = normalizeContext(context); return withScope(context.scope, scope => { - // eslint-disable-next-line deprecation/deprecation - const hub = getCurrentHub(); // eslint-disable-next-line deprecation/deprecation const parentSpan = scope.getSpan() as SentrySpan | undefined; const shouldSkipSpan = context.onlyIfParent && !parentSpan; const activeSpan = shouldSkipSpan ? new SentryNonRecordingSpan() - : createChildSpanOrTransaction(hub, { + : createChildSpanOrTransaction({ parentSpan, spanContext, forceTransaction: context.forceTransaction, @@ -155,8 +143,6 @@ export function startInactiveSpan(context: StartSpanOptions): Span { } const spanContext = normalizeContext(context); - // eslint-disable-next-line deprecation/deprecation - const hub = getCurrentHub(); const parentSpan = context.scope ? // eslint-disable-next-line deprecation/deprecation (context.scope.getSpan() as SentrySpan | undefined) @@ -170,7 +156,7 @@ export function startInactiveSpan(context: StartSpanOptions): Span { const scope = context.scope || getCurrentScope(); - return createChildSpanOrTransaction(hub, { + return createChildSpanOrTransaction({ parentSpan, spanContext, forceTransaction: context.forceTransaction, @@ -225,20 +211,17 @@ export function withActiveSpan(span: Span | null, callback: (scope: Scope) => }); } -function createChildSpanOrTransaction( - hub: Hub, - { - parentSpan, - spanContext, - forceTransaction, - scope, - }: { - parentSpan: SentrySpan | undefined; - spanContext: TransactionContext; - forceTransaction?: boolean; - scope: Scope; - }, -): Span { +function createChildSpanOrTransaction({ + parentSpan, + spanContext, + forceTransaction, + scope, +}: { + parentSpan: SentrySpan | undefined; + spanContext: TransactionContext; + forceTransaction?: boolean; + scope: Scope; +}): Span { if (!hasTracingEnabled()) { return new SentryNonRecordingSpan(); } diff --git a/packages/node/src/integrations/http.ts b/packages/node/src/integrations/http.ts index bc4571f35af0..9eb7deab5318 100644 --- a/packages/node/src/integrations/http.ts +++ b/packages/node/src/integrations/http.ts @@ -6,7 +6,6 @@ import { defineIntegration, getIsolationScope, hasTracingEnabled } from '@sentry import { addBreadcrumb, getClient, - getCurrentHub, getCurrentScope, getDynamicSamplingContextFromClient, getDynamicSamplingContextFromSpan, @@ -166,8 +165,7 @@ export class Http implements Integration { * @inheritDoc */ public setupOnce(): void { - // eslint-disable-next-line deprecation/deprecation - const clientOptions = getCurrentHub().getClient()?.getOptions(); + const clientOptions = getClient()?.getOptions(); // If `tracing` is not explicitly set, we default this based on whether or not tracing is enabled. // But for compatibility, we only do that if `enableIfHasTracingEnabled` is set. @@ -275,8 +273,7 @@ function _createWrappedRequestMethodFactory( req: http.ClientRequest, res?: http.IncomingMessage, ): void { - // eslint-disable-next-line deprecation/deprecation - if (!getCurrentHub().getIntegration(Http)) { + if (!getClient()?.getIntegrationByName('Http')) { return; } diff --git a/packages/remix/src/utils/serverAdapters/express.ts b/packages/remix/src/utils/serverAdapters/express.ts index 51e3b40e0019..7bf02700aedc 100644 --- a/packages/remix/src/utils/serverAdapters/express.ts +++ b/packages/remix/src/utils/serverAdapters/express.ts @@ -1,6 +1,6 @@ -import { getClient, getCurrentHub, hasTracingEnabled, setHttpStatus, withIsolationScope } from '@sentry/core'; +import { getClient, hasTracingEnabled, setHttpStatus, withIsolationScope } from '@sentry/core'; import { flush } from '@sentry/node'; -import type { Hub, Span } from '@sentry/types'; +import type { Span } from '@sentry/types'; import { extractRequestData, fill, isString, logger } from '@sentry/utils'; import { DEBUG_BUILD } from '../debug-build'; @@ -35,8 +35,6 @@ function wrapExpressRequestHandler( res.end = wrapEndMethod(res.end); const request = extractRequestData(req); - // eslint-disable-next-line deprecation/deprecation - const hub = getCurrentHub(); const options = getClient()?.getOptions(); isolationScope.setSDKProcessingMetadata({ request }); @@ -55,27 +53,18 @@ function wrapExpressRequestHandler( return resolvedBuild.then(resolved => { routes = createRoutes(resolved.routes); - startRequestHandlerTransactionWithRoutes.call(this, origRequestHandler, routes, req, res, next, hub, url); + startRequestHandlerTransactionWithRoutes.call(this, origRequestHandler, routes, req, res, next, url); }); } else { routes = createRoutes(resolvedBuild.routes); - return startRequestHandlerTransactionWithRoutes.call( - this, - origRequestHandler, - routes, - req, - res, - next, - hub, - url, - ); + return startRequestHandlerTransactionWithRoutes.call(this, origRequestHandler, routes, req, res, next, url); } } else { routes = createRoutes(build.routes); } - return startRequestHandlerTransactionWithRoutes.call(this, origRequestHandler, routes, req, res, next, hub, url); + return startRequestHandlerTransactionWithRoutes.call(this, origRequestHandler, routes, req, res, next, url); }); }; } @@ -87,7 +76,6 @@ function startRequestHandlerTransactionWithRoutes( req: ExpressRequest, res: ExpressResponse, next: ExpressNextFunction, - hub: Hub, url: URL, ): unknown { const [name, source] = getTransactionName(routes, url); @@ -154,7 +142,6 @@ export function wrapExpressCreateRequestHandler( origCreateRequestHandler: ExpressCreateRequestHandler, // eslint-disable-next-line @typescript-eslint/no-explicit-any ): (options: any) => ExpressRequestHandler { - // eslint-disable-next-line @typescript-eslint/no-explicit-any return function (this: unknown, options: ExpressCreateRequestHandlerOptions): ExpressRequestHandler { if (!('getLoadContext' in options)) { options['getLoadContext'] = () => ({}); diff --git a/packages/replay-internal/README.md b/packages/replay-internal/README.md index 9533593acead..bcb025101006 100644 --- a/packages/replay-internal/README.md +++ b/packages/replay-internal/README.md @@ -72,7 +72,7 @@ Sentry.init({ // Sometime later const { Replay } = await import('@sentry/browser'); -const client = Sentry.getCurrentHub().getClient(); +const client = Sentry.getClient(); // Client can be undefined client?.addIntegration(Sentry.replayIntegration()); @@ -105,7 +105,7 @@ Sentry.init({ integrations: [replay] }); -const client = Sentry.getCurrentHub().getClient(); +const client = Sentry.getClient(); // Add replay integration, will start recoring client?.addIntegration(replay); diff --git a/packages/sveltekit/src/index.types.ts b/packages/sveltekit/src/index.types.ts index 69ec5bb35597..18e734d01677 100644 --- a/packages/sveltekit/src/index.types.ts +++ b/packages/sveltekit/src/index.types.ts @@ -45,7 +45,7 @@ export declare const defaultStackParser: StackParser; export declare const getClient: typeof clientSdk.getClient; // eslint-disable-next-line deprecation/deprecation export declare const getCurrentHub: typeof clientSdk.getCurrentHub; -// eslint-disable-next-line deprecation/deprecation + export declare function close(timeout?: number | undefined): PromiseLike; export declare function flush(timeout?: number | undefined): PromiseLike;