diff --git a/packages/astro/src/index.server.ts b/packages/astro/src/index.server.ts index 5d57783d8b74..d6baea9b4394 100644 --- a/packages/astro/src/index.server.ts +++ b/packages/astro/src/index.server.ts @@ -32,6 +32,7 @@ export { getCurrentScope, getGlobalScope, getIsolationScope, + // eslint-disable-next-line deprecation/deprecation Hub, // eslint-disable-next-line deprecation/deprecation makeMain, diff --git a/packages/browser/src/exports.ts b/packages/browser/src/exports.ts index ae16b565879e..1ce59d127fb8 100644 --- a/packages/browser/src/exports.ts +++ b/packages/browser/src/exports.ts @@ -42,6 +42,7 @@ export { getClient, isInitialized, getCurrentScope, + // eslint-disable-next-line deprecation/deprecation Hub, // eslint-disable-next-line deprecation/deprecation lastEventId, diff --git a/packages/bun/src/index.ts b/packages/bun/src/index.ts index 556f86e0d18e..cc49f6b2f71c 100644 --- a/packages/bun/src/index.ts +++ b/packages/bun/src/index.ts @@ -49,6 +49,7 @@ export { getCurrentScope, getGlobalScope, getIsolationScope, + // eslint-disable-next-line deprecation/deprecation Hub, // eslint-disable-next-line deprecation/deprecation lastEventId, diff --git a/packages/bun/test/integrations/bunserver.test.ts b/packages/bun/test/integrations/bunserver.test.ts index fd55e56ff50f..e1695b7271ae 100644 --- a/packages/bun/test/integrations/bunserver.test.ts +++ b/packages/bun/test/integrations/bunserver.test.ts @@ -9,6 +9,7 @@ import { getDefaultBunClientOptions } from '../helpers'; const DEFAULT_PORT = 22114; describe('Bun Serve Integration', () => { + // eslint-disable-next-line deprecation/deprecation let hub: Hub; let client: BunClient; diff --git a/packages/core/src/exports.ts b/packages/core/src/exports.ts index e1fc9a6102ac..80e602968d0a 100644 --- a/packages/core/src/exports.ts +++ b/packages/core/src/exports.ts @@ -87,6 +87,7 @@ export function captureEvent(event: Event, hint?: EventHint): string { * * @deprecated Use getCurrentScope() directly. */ +// eslint-disable-next-line deprecation/deprecation export function configureScope(callback: (scope: Scope) => void): ReturnType { // eslint-disable-next-line deprecation/deprecation getCurrentHub().configureScope(callback); @@ -100,6 +101,7 @@ export function configureScope(callback: (scope: Scope) => void): ReturnType { // eslint-disable-next-line deprecation/deprecation getCurrentHub().addBreadcrumb(breadcrumb, hint); @@ -110,7 +112,7 @@ export function addBreadcrumb(breadcrumb: Breadcrumb, hint?: BreadcrumbHint): Re * @param name of the context * @param context Any kind of data. This data will be normalized. */ -// eslint-disable-next-line @typescript-eslint/no-explicit-any +// eslint-disable-next-line @typescript-eslint/no-explicit-any, deprecation/deprecation export function setContext(name: string, context: { [key: string]: any } | null): ReturnType { // eslint-disable-next-line deprecation/deprecation getCurrentHub().setContext(name, context); @@ -120,6 +122,7 @@ export function setContext(name: string, context: { [key: string]: any } | null) * Set an object that will be merged sent as extra data with the event. * @param extras Extras object to merge into current context. */ +// eslint-disable-next-line deprecation/deprecation export function setExtras(extras: Extras): ReturnType { // eslint-disable-next-line deprecation/deprecation getCurrentHub().setExtras(extras); @@ -130,6 +133,7 @@ export function setExtras(extras: Extras): ReturnType { * @param key String of extra * @param extra Any kind of data. This data will be normalized. */ +// eslint-disable-next-line deprecation/deprecation export function setExtra(key: string, extra: Extra): ReturnType { // eslint-disable-next-line deprecation/deprecation getCurrentHub().setExtra(key, extra); @@ -139,6 +143,7 @@ export function setExtra(key: string, extra: Extra): ReturnType * Set an object that will be merged sent as tags data with the event. * @param tags Tags context object to merge into current context. */ +// eslint-disable-next-line deprecation/deprecation export function setTags(tags: { [key: string]: Primitive }): ReturnType { // eslint-disable-next-line deprecation/deprecation getCurrentHub().setTags(tags); @@ -152,6 +157,7 @@ export function setTags(tags: { [key: string]: Primitive }): ReturnType { // eslint-disable-next-line deprecation/deprecation getCurrentHub().setTag(key, value); @@ -162,6 +168,7 @@ export function setTag(key: string, value: Primitive): ReturnType * * @param user User context object to be set in the current context. Pass `null` to unset the user. */ +// eslint-disable-next-line deprecation/deprecation export function setUser(user: User | null): ReturnType { // eslint-disable-next-line deprecation/deprecation getCurrentHub().setUser(user); @@ -272,6 +279,7 @@ export function withActiveSpan(span: Span, callback: (scope: Scope) => T): T export function startTransaction( context: TransactionContext, customSamplingContext?: CustomSamplingContext, + // eslint-disable-next-line deprecation/deprecation ): ReturnType { // eslint-disable-next-line deprecation/deprecation return getCurrentHub().startTransaction({ ...context }, customSamplingContext); diff --git a/packages/core/src/hub.ts b/packages/core/src/hub.ts index 3785ab61fec3..a35b69b83e8e 100644 --- a/packages/core/src/hub.ts +++ b/packages/core/src/hub.ts @@ -66,6 +66,7 @@ export interface AsyncContextStrategy { /** * Gets the current async context. Returns undefined if there is no current async context. */ + // eslint-disable-next-line deprecation/deprecation getCurrentHub: () => Hub | undefined; /** * Runs the supplied callback in its own async context. @@ -88,6 +89,7 @@ export interface Layer { */ export interface Carrier { __SENTRY__?: { + // eslint-disable-next-line deprecation/deprecation hub?: Hub; acs?: AsyncContextStrategy; /** @@ -103,7 +105,15 @@ export interface Carrier { } /** - * @inheritDoc + * @deprecated The `Hub` class will be removed in version 8 of the SDK in favour of `Scope` and `Client` objects. + * + * If you previously used the `Hub` class directly, replace it with `Scope` and `Client` objects. More information: + * - [Multiple Sentry Instances](https://docs.sentry.io/platforms/javascript/best-practices/multiple-sentry-instances/) + * - [Browser Extensions](https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/) + * + * Some of our APIs are typed with the Hub class instead of the interface (e.g. `getCurrentHub`). Most of them are deprecated + * themselves and will also be removed in version 8. More information: + * - [Migration Guide](https://github.com/getsentry/sentry-javascript/blob/develop/MIGRATION.md#deprecate-hub) */ export class Hub implements HubInterface { /** Is a {@link Layer}[] containing the client and scope */ @@ -531,6 +541,7 @@ export class Hub implements HubInterface { /** * @inheritDoc */ + // eslint-disable-next-line deprecation/deprecation public run(callback: (hub: Hub) => void): void { // eslint-disable-next-line deprecation/deprecation const oldHub = makeMain(this); @@ -739,6 +750,7 @@ export function getMainCarrier(): Carrier { * * @deprecated Use `setCurrentClient()` instead. */ +// eslint-disable-next-line deprecation/deprecation export function makeMain(hub: Hub): Hub { const registry = getMainCarrier(); const oldHub = getHubFromCarrier(registry); @@ -755,6 +767,7 @@ export function makeMain(hub: Hub): Hub { * * @deprecated Use the respective replacement method directly instead. */ +// eslint-disable-next-line deprecation/deprecation export function getCurrentHub(): Hub { // Get main carrier (global for every environment) const registry = getMainCarrier(); @@ -781,6 +794,7 @@ export function getIsolationScope(): Scope { return getCurrentHub().getIsolationScope(); } +// eslint-disable-next-line deprecation/deprecation function getGlobalHub(registry: Carrier = getMainCarrier()): Hub { // If there's no hub, or its an old API, assign a new one @@ -802,6 +816,7 @@ function getGlobalHub(registry: Carrier = getMainCarrier()): Hub { * * If the carrier does not contain a hub, a new hub is created with the global hub client and scope. */ +// eslint-disable-next-line deprecation/deprecation export function ensureHubOnCarrier(carrier: Carrier, parent: Hub = getGlobalHub()): void { // If there's no hub on current domain, or it's an old API, assign a new one if ( @@ -864,6 +879,7 @@ function hasHubOnCarrier(carrier: Carrier): boolean { * @param carrier object * @hidden */ +// eslint-disable-next-line deprecation/deprecation export function getHubFromCarrier(carrier: Carrier): Hub { // eslint-disable-next-line deprecation/deprecation return getGlobalSingleton('hub', () => new Hub(), carrier); @@ -875,6 +891,7 @@ export function getHubFromCarrier(carrier: Carrier): Hub { * @param hub Hub * @returns A boolean indicating success or failure */ +// eslint-disable-next-line deprecation/deprecation export function setHubOnCarrier(carrier: Carrier, hub: Hub): boolean { if (!carrier) return false; const __SENTRY__ = (carrier.__SENTRY__ = carrier.__SENTRY__ || {}); diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 53db1e1743fe..7105af28257e 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -44,6 +44,7 @@ export { getCurrentHub, getIsolationScope, getHubFromCarrier, + // eslint-disable-next-line deprecation/deprecation Hub, // eslint-disable-next-line deprecation/deprecation makeMain, @@ -84,12 +85,7 @@ export { hasTracingEnabled } from './utils/hasTracingEnabled'; export { isSentryRequestUrl } from './utils/isSentryRequestUrl'; export { handleCallbackErrors } from './utils/handleCallbackErrors'; export { parameterize } from './utils/parameterize'; -export { - spanToTraceHeader, - spanToJSON, - spanIsSampled, - spanToTraceContext, -} from './utils/spanUtils'; +export { spanToTraceHeader, spanToJSON, spanIsSampled, spanToTraceContext } from './utils/spanUtils'; export { getRootSpan } from './utils/getRootSpan'; export { applySdkMetadata } from './utils/sdkMetadata'; export { DEFAULT_ENVIRONMENT } from './constants'; diff --git a/packages/core/src/tracing/hubextensions.ts b/packages/core/src/tracing/hubextensions.ts index 51748ea72351..c5474a963d07 100644 --- a/packages/core/src/tracing/hubextensions.ts +++ b/packages/core/src/tracing/hubextensions.ts @@ -11,6 +11,7 @@ import { sampleTransaction } from './sampling'; import { Transaction } from './transaction'; /** Returns all trace headers that are currently on the top scope. */ +// eslint-disable-next-line deprecation/deprecation function traceHeaders(this: Hub): { [key: string]: string } { // eslint-disable-next-line deprecation/deprecation const scope = this.getScope(); @@ -40,6 +41,7 @@ function traceHeaders(this: Hub): { [key: string]: string } { * @see {@link Hub.startTransaction} */ function _startTransaction( + // eslint-disable-next-line deprecation/deprecation this: Hub, transactionContext: TransactionContext, customSamplingContext?: CustomSamplingContext, @@ -88,6 +90,7 @@ The transaction will not be sampled. Please use the ${configInstrumenter} instru * Create new idle transaction. */ export function startIdleTransaction( + // eslint-disable-next-line deprecation/deprecation hub: Hub, transactionContext: TransactionContext, idleTimeout: number, diff --git a/packages/core/src/tracing/idletransaction.ts b/packages/core/src/tracing/idletransaction.ts index fed962898d71..6476b5c8e2c3 100644 --- a/packages/core/src/tracing/idletransaction.ts +++ b/packages/core/src/tracing/idletransaction.ts @@ -102,6 +102,7 @@ export class IdleTransaction extends Transaction { */ public constructor( transactionContext: TransactionContext, + // eslint-disable-next-line deprecation/deprecation private readonly _idleHub: Hub, /** * The time to wait in ms until the idle transaction will be finished. This timer is started each time diff --git a/packages/core/src/tracing/trace.ts b/packages/core/src/tracing/trace.ts index 44171e934c7d..cf37337e68d1 100644 --- a/packages/core/src/tracing/trace.ts +++ b/packages/core/src/tracing/trace.ts @@ -330,6 +330,7 @@ export const continueTrace: ContinueTrace = ( }; function createChildSpanOrTransaction( + // eslint-disable-next-line deprecation/deprecation hub: Hub, { parentSpan, diff --git a/packages/core/src/tracing/transaction.ts b/packages/core/src/tracing/transaction.ts index e30eec8d8249..8d5c3f78f5de 100644 --- a/packages/core/src/tracing/transaction.ts +++ b/packages/core/src/tracing/transaction.ts @@ -26,6 +26,7 @@ export class Transaction extends SpanClass implements TransactionInterface { /** * The reference to the current hub. */ + // eslint-disable-next-line deprecation/deprecation public _hub: Hub; protected _name: string; @@ -48,6 +49,7 @@ export class Transaction extends SpanClass implements TransactionInterface { * * @deprecated Transactions will be removed in v8. Use spans instead. */ + // eslint-disable-next-line deprecation/deprecation public constructor(transactionContext: TransactionContext, hub?: Hub) { super(transactionContext); this._contexts = {}; @@ -250,6 +252,7 @@ export class Transaction extends SpanClass implements TransactionInterface { * * @internal */ + // eslint-disable-next-line deprecation/deprecation public setHub(hub: Hub): void { this._hub = hub; } diff --git a/packages/core/src/tracing/utils.ts b/packages/core/src/tracing/utils.ts index cab0eead61f2..b2884cbbce49 100644 --- a/packages/core/src/tracing/utils.ts +++ b/packages/core/src/tracing/utils.ts @@ -9,6 +9,7 @@ import { getCurrentHub } from '../hub'; * * @deprecated You should not rely on the transaction, but just use `startSpan()` APIs instead. */ +// eslint-disable-next-line deprecation/deprecation export function getActiveTransaction(maybeHub?: Hub): T | undefined { // eslint-disable-next-line deprecation/deprecation const hub = maybeHub || getCurrentHub(); diff --git a/packages/core/test/lib/tracing/dynamicSamplingContext.test.ts b/packages/core/test/lib/tracing/dynamicSamplingContext.test.ts index db79c8850200..b24b518070df 100644 --- a/packages/core/test/lib/tracing/dynamicSamplingContext.test.ts +++ b/packages/core/test/lib/tracing/dynamicSamplingContext.test.ts @@ -5,6 +5,7 @@ import { addTracingExtensions } from '../../../src/tracing'; import { TestClient, getDefaultTestClientOptions } from '../../mocks/client'; describe('getDynamicSamplingContextFromSpan', () => { + // eslint-disable-next-line deprecation/deprecation let hub: Hub; beforeEach(() => { const options = getDefaultTestClientOptions({ tracesSampleRate: 1.0, release: '1.0.1' }); diff --git a/packages/core/test/lib/tracing/trace.test.ts b/packages/core/test/lib/tracing/trace.test.ts index 8dbc440d1b76..dad2d48014d9 100644 --- a/packages/core/test/lib/tracing/trace.test.ts +++ b/packages/core/test/lib/tracing/trace.test.ts @@ -29,6 +29,7 @@ const enum Type { Async = 'async', } +// eslint-disable-next-line deprecation/deprecation let hub: Hub; let client: TestClient; diff --git a/packages/deno/src/index.ts b/packages/deno/src/index.ts index 64082a4f24ca..781b7f65fdd8 100644 --- a/packages/deno/src/index.ts +++ b/packages/deno/src/index.ts @@ -48,6 +48,7 @@ export { getCurrentScope, getGlobalScope, getIsolationScope, + // eslint-disable-next-line deprecation/deprecation Hub, // eslint-disable-next-line deprecation/deprecation lastEventId, diff --git a/packages/deno/test/__snapshots__/mod.test.ts.snap b/packages/deno/test/__snapshots__/mod.test.ts.snap index d728072d38d6..735cc53a9b43 100644 --- a/packages/deno/test/__snapshots__/mod.test.ts.snap +++ b/packages/deno/test/__snapshots__/mod.test.ts.snap @@ -42,47 +42,47 @@ snapshot[`captureException 1`] = ` stacktrace: { frames: [ { - colno: 20, + colno: "{{colno}}", filename: "ext:cli/40_testing.js", function: "outerWrapped", in_app: false, - lineno: 472, + lineno: "{{lineno}}", }, { - colno: 33, + colno: "{{colno}}", filename: "ext:cli/40_testing.js", function: "exitSanitizer", in_app: false, - lineno: 458, + lineno: "{{lineno}}", }, { - colno: 31, + colno: "{{colno}}", filename: "ext:cli/40_testing.js", function: "resourceSanitizer", in_app: false, - lineno: 410, + lineno: "{{lineno}}", }, { - colno: 33, + colno: "{{colno}}", filename: "ext:cli/40_testing.js", function: "asyncOpSanitizer", in_app: false, - lineno: 177, + lineno: "{{lineno}}", }, { - colno: 11, + colno: "{{colno}}", filename: "ext:cli/40_testing.js", function: "innerWrapped", in_app: false, - lineno: 526, + lineno: "{{lineno}}", }, { - colno: 27, + colno: "{{colno}}", context_line: " client.captureException(something());", filename: "app:///test/mod.test.ts", function: "", in_app: true, - lineno: 47, + lineno: "{{lineno}}", post_context: [ "", " await delay(200);", @@ -103,12 +103,12 @@ snapshot[`captureException 1`] = ` ], }, { - colno: 12, + colno: "{{colno}}", context_line: " return new Error('Some unhandled error');", filename: "app:///test/mod.test.ts", function: "something", in_app: true, - lineno: 44, + lineno: "{{lineno}}", post_context: [ " }", "", diff --git a/packages/deno/test/mod.test.ts b/packages/deno/test/mod.test.ts index aae0963b8da5..b6ca5a04f35f 100644 --- a/packages/deno/test/mod.test.ts +++ b/packages/deno/test/mod.test.ts @@ -10,6 +10,7 @@ import { makeTestTransport } from './transport.ts'; function getTestClient( callback: (event?: sentryTypes.Event) => void, integrations: sentryTypes.Integration[] = [], + // eslint-disable-next-line deprecation/deprecation ): [Hub, DenoClient] { const client = new DenoClient({ dsn: 'https://233a45e5efe34c47a3536797ce15dafa@nothing.here/5650507', diff --git a/packages/deno/test/normalize.ts b/packages/deno/test/normalize.ts index 64295932e00d..f6988ff7cd7e 100644 --- a/packages/deno/test/normalize.ts +++ b/packages/deno/test/normalize.ts @@ -156,6 +156,13 @@ function normalizeEvent(event: sentryTypes.Event): sentryTypes.Event { event.exception.values[0].stacktrace.frames = event.exception.values[0].stacktrace.frames.filter( frame => !frame.filename?.includes('deno:'), ); + + // @ts-expect-error - we're setting a string as lineno/colno for normalization + event.exception.values[0].stacktrace.frames = event.exception.values[0].stacktrace.frames.map(frame => ({ + ...frame, + lineno: '{{lineno}}', + colno: '{{colno}}', + })); } event.timestamp = 0; diff --git a/packages/hub/src/index.ts b/packages/hub/src/index.ts index f865df997d29..a0d62656089c 100644 --- a/packages/hub/src/index.ts +++ b/packages/hub/src/index.ts @@ -31,6 +31,7 @@ import { /** * @deprecated This export has moved to @sentry/core. The @sentry/hub package will be removed in v8 */ +// eslint-disable-next-line deprecation/deprecation export class Hub extends HubCore {} /** diff --git a/packages/node-experimental/src/index.ts b/packages/node-experimental/src/index.ts index ce3f4f85a214..b0edef9afbc7 100644 --- a/packages/node-experimental/src/index.ts +++ b/packages/node-experimental/src/index.ts @@ -75,6 +75,7 @@ export { // eslint-disable-next-line deprecation/deprecation extractTraceparentData, flush, + // eslint-disable-next-line deprecation/deprecation Hub, runWithAsyncContext, SDK_VERSION, diff --git a/packages/node/src/async/domain.ts b/packages/node/src/async/domain.ts index 345cfc06baea..c7c9d2d74bf9 100644 --- a/packages/node/src/async/domain.ts +++ b/packages/node/src/async/domain.ts @@ -7,6 +7,7 @@ function getActiveDomain(): T | undefined { return (domain as any).active as T | undefined; } +// eslint-disable-next-line deprecation/deprecation function getCurrentHub(): Hub | undefined { const activeDomain = getActiveDomain(); @@ -20,6 +21,7 @@ function getCurrentHub(): Hub | undefined { return getHubFromCarrier(activeDomain); } +// eslint-disable-next-line deprecation/deprecation function createNewHub(parent: Hub | undefined): Hub { const carrier: Carrier = {}; ensureHubOnCarrier(carrier, parent); diff --git a/packages/node/src/async/hooks.ts b/packages/node/src/async/hooks.ts index 151b699c70d6..0ed5f6e6208a 100644 --- a/packages/node/src/async/hooks.ts +++ b/packages/node/src/async/hooks.ts @@ -12,6 +12,7 @@ type AsyncLocalStorageConstructor = { new (): AsyncLocalStorage }; // AsyncLocalStorage only exists in async_hook after Node v12.17.0 or v13.10.0 type NewerAsyncHooks = typeof async_hooks & { AsyncLocalStorage: AsyncLocalStorageConstructor }; +// eslint-disable-next-line deprecation/deprecation let asyncStorage: AsyncLocalStorage; /** @@ -19,13 +20,16 @@ let asyncStorage: AsyncLocalStorage; */ export function setHooksAsyncContextStrategy(): void { if (!asyncStorage) { + // eslint-disable-next-line deprecation/deprecation asyncStorage = new (async_hooks as NewerAsyncHooks).AsyncLocalStorage(); } + // eslint-disable-next-line deprecation/deprecation function getCurrentHub(): Hub | undefined { return asyncStorage.getStore(); } + // eslint-disable-next-line deprecation/deprecation function createNewHub(parent: Hub | undefined): Hub { const carrier: Carrier = {}; ensureHubOnCarrier(carrier, parent); diff --git a/packages/node/src/index.ts b/packages/node/src/index.ts index 9f10251aa9e3..b24932f93813 100644 --- a/packages/node/src/index.ts +++ b/packages/node/src/index.ts @@ -48,6 +48,7 @@ export { getCurrentScope, getGlobalScope, getIsolationScope, + // eslint-disable-next-line deprecation/deprecation Hub, // eslint-disable-next-line deprecation/deprecation lastEventId, diff --git a/packages/node/src/integrations/http.ts b/packages/node/src/integrations/http.ts index f572fcc160f2..37d91a492b76 100644 --- a/packages/node/src/integrations/http.ts +++ b/packages/node/src/integrations/http.ts @@ -171,6 +171,7 @@ export class Http implements Integration { */ public setupOnce( _addGlobalEventProcessor: (callback: EventProcessor) => void, + // eslint-disable-next-line deprecation/deprecation setupOnceGetCurrentHub: () => Hub, ): void { // eslint-disable-next-line deprecation/deprecation diff --git a/packages/node/test/handlers.test.ts b/packages/node/test/handlers.test.ts index 34e00f06b9c6..f3114442016e 100644 --- a/packages/node/test/handlers.test.ts +++ b/packages/node/test/handlers.test.ts @@ -17,11 +17,14 @@ import { NodeClient } from '../src/client'; import { errorHandler, requestHandler, tracingHandler } from '../src/handlers'; import { getDefaultNodeClientOptions } from './helper/node-client-options'; +// eslint-disable-next-line deprecation/deprecation function mockAsyncContextStrategy(getHub: () => Hub): void { + // eslint-disable-next-line deprecation/deprecation function getCurrentHub(): Hub | undefined { return getHub(); } + // eslint-disable-next-line deprecation/deprecation function runWithAsyncContext(fn: (hub: Hub) => T): T { return fn(getHub()); } @@ -195,6 +198,7 @@ describe('tracingHandler', () => { const sentryTracingMiddleware = tracingHandler(); + // eslint-disable-next-line deprecation/deprecation let hub: Hub, req: http.IncomingMessage, res: http.ServerResponse, next: () => undefined; function createNoOpSpy() { diff --git a/packages/node/test/integrations/undici.test.ts b/packages/node/test/integrations/undici.test.ts index 27d6d9ed5ca8..bb89d6296983 100644 --- a/packages/node/test/integrations/undici.test.ts +++ b/packages/node/test/integrations/undici.test.ts @@ -12,6 +12,7 @@ import { conditionalTest } from '../utils'; const SENTRY_DSN = 'https://0@0.ingest.sentry.io/0'; +// eslint-disable-next-line deprecation/deprecation let hub: Hub; let fetch: typeof FetchType; diff --git a/packages/node/test/onunhandledrejection.test.ts b/packages/node/test/onunhandledrejection.test.ts index b62da7c02fe0..6cb57f8b8de7 100644 --- a/packages/node/test/onunhandledrejection.test.ts +++ b/packages/node/test/onunhandledrejection.test.ts @@ -36,6 +36,7 @@ describe('unhandled promises', () => { }, }; + // eslint-disable-next-line deprecation/deprecation const captureException = jest.spyOn(Hub.prototype, 'captureException'); const handler = makeUnhandledPromiseHandler(client, { diff --git a/packages/opentelemetry-node/test/spanprocessor.test.ts b/packages/opentelemetry-node/test/spanprocessor.test.ts index 072ba35881f8..586059810efb 100644 --- a/packages/opentelemetry-node/test/spanprocessor.test.ts +++ b/packages/opentelemetry-node/test/spanprocessor.test.ts @@ -36,6 +36,7 @@ beforeAll(() => { }); describe('SentrySpanProcessor', () => { + // eslint-disable-next-line deprecation/deprecation let hub: Hub; let client: NodeClient; let provider: NodeTracerProvider; diff --git a/packages/opentelemetry/src/asyncContextStrategy.ts b/packages/opentelemetry/src/asyncContextStrategy.ts index c4cc48c1cfb5..2d6a786599bc 100644 --- a/packages/opentelemetry/src/asyncContextStrategy.ts +++ b/packages/opentelemetry/src/asyncContextStrategy.ts @@ -9,11 +9,13 @@ import { getHubFromContext } from './utils/contextData'; * We handle forking a hub inside of our custom OTEL Context Manager (./otelContextManager.ts) */ export function setOpenTelemetryContextAsyncContextStrategy(): void { + // eslint-disable-next-line deprecation/deprecation function getCurrentHub(): Hub | undefined { const ctx = api.context.active(); // Returning undefined means the global hub will be used // Need to cast from @sentry/type's `Hub` to @sentry/core's `Hub` + // eslint-disable-next-line deprecation/deprecation return getHubFromContext(ctx) as Hub | undefined; } diff --git a/packages/opentelemetry/src/contextManager.ts b/packages/opentelemetry/src/contextManager.ts index 3b3a6a280928..614616f90280 100644 --- a/packages/opentelemetry/src/contextManager.ts +++ b/packages/opentelemetry/src/contextManager.ts @@ -5,6 +5,7 @@ import { ensureHubOnCarrier } from '@sentry/core'; import { getCurrentHub, getHubFromCarrier } from './custom/hub'; import { setHubOnContext } from './utils/contextData'; +// eslint-disable-next-line deprecation/deprecation function createNewHub(parent: Hub | undefined): Hub { const carrier: Carrier = {}; ensureHubOnCarrier(carrier, parent); diff --git a/packages/opentelemetry/src/custom/hub.ts b/packages/opentelemetry/src/custom/hub.ts index 2e0d120486dd..2416232bc0c7 100644 --- a/packages/opentelemetry/src/custom/hub.ts +++ b/packages/opentelemetry/src/custom/hub.ts @@ -9,6 +9,7 @@ import { OpenTelemetryScope } from './scope'; * A custom hub that ensures we always creat an OTEL scope. * Exported only for testing */ +// eslint-disable-next-line deprecation/deprecation export class OpenTelemetryHub extends Hub { public constructor(client?: Client, scope: Scope = new OpenTelemetryScope()) { super(client, scope); @@ -49,6 +50,7 @@ const API_VERSION = 4; * contains a more recent version, it replaces the registered version. * Otherwise, the currently registered hub will be returned. */ +// eslint-disable-next-line deprecation/deprecation export function getCurrentHub(): Hub { // Get main carrier (global for every environment) const registry = getMainCarrier(); @@ -85,7 +87,9 @@ export function setupGlobalHub(): void { * @param carrier object * @hidden */ +// eslint-disable-next-line deprecation/deprecation export function getHubFromCarrier(carrier: Carrier): Hub { + // eslint-disable-next-line deprecation/deprecation return getGlobalSingleton('hub', () => new OpenTelemetryHub(), carrier); } @@ -94,6 +98,7 @@ export function getHubFromCarrier(carrier: Carrier): Hub { * * If the carrier does not contain a hub, a new hub is created with the global hub client and scope. */ +// eslint-disable-next-line deprecation/deprecation export function ensureHubOnCarrier(carrier: Carrier, parent: Hub = getGlobalHub()): void { // If there's no hub on current domain, or it's an old API, assign a new one if ( @@ -107,6 +112,7 @@ export function ensureHubOnCarrier(carrier: Carrier, parent: Hub = getGlobalHub( } } +// eslint-disable-next-line deprecation/deprecation function getGlobalHub(registry: Carrier = getMainCarrier()): Hub { // If there's no hub, or its an old API, assign a new one if ( @@ -150,6 +156,7 @@ function getMainCarrier(): Carrier { * @param hub Hub * @returns A boolean indicating success or failure */ +// eslint-disable-next-line deprecation/deprecation function setHubOnCarrier(carrier: Carrier, hub: Hub): boolean { if (!carrier) return false; const __SENTRY__ = (carrier.__SENTRY__ = carrier.__SENTRY__ || {}); diff --git a/packages/opentelemetry/test/asyncContextStrategy.test.ts b/packages/opentelemetry/test/asyncContextStrategy.test.ts index 92856234bf80..17d9f7d30917 100644 --- a/packages/opentelemetry/test/asyncContextStrategy.test.ts +++ b/packages/opentelemetry/test/asyncContextStrategy.test.ts @@ -53,6 +53,7 @@ describe('asyncContextStrategy', () => { }); test('async hub scope inheritance', async () => { + // eslint-disable-next-line deprecation/deprecation async function addRandomExtra(hub: Hub, key: string): Promise { return new Promise(resolve => { setTimeout(() => { diff --git a/packages/remix/src/index.server.ts b/packages/remix/src/index.server.ts index e5386471f3d9..1a2b58ddb25a 100644 --- a/packages/remix/src/index.server.ts +++ b/packages/remix/src/index.server.ts @@ -35,6 +35,7 @@ export { getCurrentScope, getGlobalScope, getIsolationScope, + // eslint-disable-next-line deprecation/deprecation Hub, // eslint-disable-next-line deprecation/deprecation makeMain, diff --git a/packages/remix/src/utils/instrumentServer.ts b/packages/remix/src/utils/instrumentServer.ts index f51e857c59d0..02dc61913fa0 100644 --- a/packages/remix/src/utils/instrumentServer.ts +++ b/packages/remix/src/utils/instrumentServer.ts @@ -385,6 +385,7 @@ export function createRoutes(manifest: ServerRouteManifest, parentId?: string): * Starts a new transaction for the given request to be used by different `RequestHandler` wrappers. */ export function startRequestHandlerTransaction( + // eslint-disable-next-line deprecation/deprecation hub: Hub, name: string, source: TransactionSource, diff --git a/packages/remix/src/utils/serverAdapters/express.ts b/packages/remix/src/utils/serverAdapters/express.ts index c2f3ad3a7f73..0b1b26994056 100644 --- a/packages/remix/src/utils/serverAdapters/express.ts +++ b/packages/remix/src/utils/serverAdapters/express.ts @@ -95,6 +95,7 @@ function startRequestHandlerTransactionWithRoutes( req: ExpressRequest, res: ExpressResponse, next: ExpressNextFunction, + // eslint-disable-next-line deprecation/deprecation hub: Hub, url: URL, ): Transaction | undefined { diff --git a/packages/replay/test/unit/session/createSession.test.ts b/packages/replay/test/unit/session/createSession.test.ts index 2fc8779a5acb..5fb71c5eb70c 100644 --- a/packages/replay/test/unit/session/createSession.test.ts +++ b/packages/replay/test/unit/session/createSession.test.ts @@ -24,6 +24,7 @@ describe('Unit | session | createSession', () => { jest.spyOn(Sentry, 'getCurrentHub').mockImplementation(() => { return { captureEvent: captureEventMock, + // eslint-disable-next-line deprecation/deprecation } as unknown as Hub; }); }); diff --git a/packages/serverless/src/index.ts b/packages/serverless/src/index.ts index ccd39fb159bd..44f7a3a72266 100644 --- a/packages/serverless/src/index.ts +++ b/packages/serverless/src/index.ts @@ -11,6 +11,7 @@ export { AWSServices, awsServicesIntegration } from './awsservices'; // work with Node native esm while we also have namespace exports in a package. // What we should do is get rid of the namespace exports. export { + // eslint-disable-next-line deprecation/deprecation Hub, SDK_VERSION, Scope, diff --git a/packages/sveltekit/src/server/index.ts b/packages/sveltekit/src/server/index.ts index 167c4907099a..a01368f752c6 100644 --- a/packages/sveltekit/src/server/index.ts +++ b/packages/sveltekit/src/server/index.ts @@ -29,6 +29,7 @@ export { getCurrentScope, getGlobalScope, getIsolationScope, + // eslint-disable-next-line deprecation/deprecation Hub, NodeClient, // eslint-disable-next-line deprecation/deprecation diff --git a/packages/sveltekit/test/server/handle.test.ts b/packages/sveltekit/test/server/handle.test.ts index 5498d80ea0ed..9874c4a679d3 100644 --- a/packages/sveltekit/test/server/handle.test.ts +++ b/packages/sveltekit/test/server/handle.test.ts @@ -81,6 +81,7 @@ function resolve( }; } +// eslint-disable-next-line deprecation/deprecation let hub: Hub; let client: NodeClient; diff --git a/packages/tracing-internal/src/browser/browsertracing.ts b/packages/tracing-internal/src/browser/browsertracing.ts index ce75636cc60b..28e1e35aba2f 100644 --- a/packages/tracing-internal/src/browser/browsertracing.ts +++ b/packages/tracing-internal/src/browser/browsertracing.ts @@ -132,6 +132,7 @@ export interface BrowserTracingOptions extends RequestInstrumentationOptions { _experiments: Partial<{ enableLongTask: boolean; enableInteractions: boolean; + // eslint-disable-next-line deprecation/deprecation onStartRouteTransaction: (t: Transaction | undefined, ctx: TransactionContext, getCurrentHub: () => Hub) => void; }>; @@ -198,6 +199,7 @@ export class BrowserTracing implements Integration { */ public name: string; + // eslint-disable-next-line deprecation/deprecation private _getCurrentHub?: () => Hub; private _collectWebVitals: () => void; @@ -266,6 +268,7 @@ export class BrowserTracing implements Integration { /** * @inheritDoc */ + // eslint-disable-next-line deprecation/deprecation public setupOnce(_: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void { this._getCurrentHub = getCurrentHub; const hub = getCurrentHub(); diff --git a/packages/tracing-internal/src/node/integrations/apollo.ts b/packages/tracing-internal/src/node/integrations/apollo.ts index 280d958126f7..6cb5b75a8c08 100644 --- a/packages/tracing-internal/src/node/integrations/apollo.ts +++ b/packages/tracing-internal/src/node/integrations/apollo.ts @@ -76,6 +76,7 @@ export class Apollo implements LazyLoadedIntegration void, getCurrentHub: () => Hub): void { if (shouldDisableAutoInstrumentation(getCurrentHub)) { DEBUG_BUILD && logger.log('Apollo Integration is skipped because of instrumenter configuration.'); @@ -161,6 +162,7 @@ export class Apollo implements LazyLoadedIntegration Hub): ApolloModelResolvers[] { return resolvers.map(model => { Object.keys(model).forEach(resolverGroupName => { @@ -184,6 +186,7 @@ function wrapResolver( model: ApolloModelResolvers, resolverGroupName: string, resolverName: string, + // eslint-disable-next-line deprecation/deprecation getCurrentHub: () => Hub, ): void { fill(model[resolverGroupName], resolverName, function (orig: () => unknown | Promise) { diff --git a/packages/tracing-internal/src/node/integrations/graphql.ts b/packages/tracing-internal/src/node/integrations/graphql.ts index 148329dbd86d..b326f1421bf1 100644 --- a/packages/tracing-internal/src/node/integrations/graphql.ts +++ b/packages/tracing-internal/src/node/integrations/graphql.ts @@ -36,6 +36,7 @@ export class GraphQL implements LazyLoadedIntegration { /** * @inheritDoc */ + // eslint-disable-next-line deprecation/deprecation public setupOnce(_: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void { if (shouldDisableAutoInstrumentation(getCurrentHub)) { DEBUG_BUILD && logger.log('GraphQL Integration is skipped because of instrumenter configuration.'); diff --git a/packages/tracing-internal/src/node/integrations/mongo.ts b/packages/tracing-internal/src/node/integrations/mongo.ts index 27646e12b6bf..4945e1c0fe90 100644 --- a/packages/tracing-internal/src/node/integrations/mongo.ts +++ b/packages/tracing-internal/src/node/integrations/mongo.ts @@ -139,6 +139,7 @@ export class Mongo implements LazyLoadedIntegration { /** * @inheritDoc */ + // eslint-disable-next-line deprecation/deprecation public setupOnce(_: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void { if (shouldDisableAutoInstrumentation(getCurrentHub)) { DEBUG_BUILD && logger.log('Mongo Integration is skipped because of instrumenter configuration.'); @@ -159,6 +160,7 @@ export class Mongo implements LazyLoadedIntegration { /** * Patches original collection methods */ + // eslint-disable-next-line deprecation/deprecation private _instrumentOperations(collection: MongoCollection, operations: Operation[], getCurrentHub: () => Hub): void { operations.forEach((operation: Operation) => this._patchOperation(collection, operation, getCurrentHub)); } @@ -166,6 +168,7 @@ export class Mongo implements LazyLoadedIntegration { /** * Patches original collection to utilize our tracing functionality */ + // eslint-disable-next-line deprecation/deprecation private _patchOperation(collection: MongoCollection, operation: Operation, getCurrentHub: () => Hub): void { if (!(operation in collection.prototype)) return; diff --git a/packages/tracing-internal/src/node/integrations/mysql.ts b/packages/tracing-internal/src/node/integrations/mysql.ts index c7bf5451e5f5..858933403734 100644 --- a/packages/tracing-internal/src/node/integrations/mysql.ts +++ b/packages/tracing-internal/src/node/integrations/mysql.ts @@ -45,6 +45,7 @@ export class Mysql implements LazyLoadedIntegration { /** * @inheritDoc */ + // eslint-disable-next-line deprecation/deprecation public setupOnce(_: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void { if (shouldDisableAutoInstrumentation(getCurrentHub)) { DEBUG_BUILD && logger.log('Mysql Integration is skipped because of instrumenter configuration.'); diff --git a/packages/tracing-internal/src/node/integrations/postgres.ts b/packages/tracing-internal/src/node/integrations/postgres.ts index 086cebf84ee5..bc318e5aa70e 100644 --- a/packages/tracing-internal/src/node/integrations/postgres.ts +++ b/packages/tracing-internal/src/node/integrations/postgres.ts @@ -75,6 +75,7 @@ export class Postgres implements LazyLoadedIntegration { /** * @inheritDoc */ + // eslint-disable-next-line deprecation/deprecation public setupOnce(_: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void { if (shouldDisableAutoInstrumentation(getCurrentHub)) { DEBUG_BUILD && logger.log('Postgres Integration is skipped because of instrumenter configuration.'); diff --git a/packages/tracing-internal/test/browser/backgroundtab.test.ts b/packages/tracing-internal/test/browser/backgroundtab.test.ts index 8eae89eb3a65..49afce6b67b3 100644 --- a/packages/tracing-internal/test/browser/backgroundtab.test.ts +++ b/packages/tracing-internal/test/browser/backgroundtab.test.ts @@ -8,6 +8,7 @@ import { TestClient } from '../utils/TestClient'; conditionalTest({ min: 10 })('registerBackgroundTabDetection', () => { let events: Record = {}; + // eslint-disable-next-line deprecation/deprecation let hub: Hub; beforeEach(() => { const dom = new JSDOM(); diff --git a/packages/vercel-edge/src/async.ts b/packages/vercel-edge/src/async.ts index 336494dfbf3e..b7a29a070f18 100644 --- a/packages/vercel-edge/src/async.ts +++ b/packages/vercel-edge/src/async.ts @@ -13,6 +13,7 @@ interface AsyncLocalStorage { // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any const MaybeGlobalAsyncLocalStorage = (GLOBAL_OBJ as any).AsyncLocalStorage; +// eslint-disable-next-line deprecation/deprecation let asyncStorage: AsyncLocalStorage; /** @@ -31,10 +32,12 @@ export function setAsyncLocalStorageAsyncContextStrategy(): void { asyncStorage = new MaybeGlobalAsyncLocalStorage(); } + // eslint-disable-next-line deprecation/deprecation function getCurrentHub(): Hub | undefined { return asyncStorage.getStore(); } + // eslint-disable-next-line deprecation/deprecation function createNewHub(parent: Hub | undefined): Hub { const carrier: Carrier = {}; ensureHubOnCarrier(carrier, parent); diff --git a/packages/vercel-edge/src/index.ts b/packages/vercel-edge/src/index.ts index cb20844ffd93..63af334439b7 100644 --- a/packages/vercel-edge/src/index.ts +++ b/packages/vercel-edge/src/index.ts @@ -48,6 +48,7 @@ export { getCurrentScope, getGlobalScope, getIsolationScope, + // eslint-disable-next-line deprecation/deprecation Hub, // eslint-disable-next-line deprecation/deprecation lastEventId,