diff --git a/packages/browser/test/unit/sdk.test.ts b/packages/browser/test/unit/sdk.test.ts index a2df869fe90d..5d03d26d3312 100644 --- a/packages/browser/test/unit/sdk.test.ts +++ b/packages/browser/test/unit/sdk.test.ts @@ -21,8 +21,8 @@ function getDefaultBrowserOptions(options: Partial = {}): Browse }; } -jest.mock('@sentry/hub', () => { - const original = jest.requireActual('@sentry/hub'); +jest.mock('@sentry/core', () => { + const original = jest.requireActual('@sentry/core'); return { ...original, getCurrentHub(): { diff --git a/packages/core/package.json b/packages/core/package.json index e45fed177a56..89ce146be17e 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -16,7 +16,6 @@ "access": "public" }, "dependencies": { - "@sentry/hub": "7.14.2", "@sentry/types": "7.14.2", "@sentry/utils": "7.14.2", "tslib": "^1.9.3" diff --git a/packages/core/src/baseclient.ts b/packages/core/src/baseclient.ts index b8ab5f82fcd7..cfa46af6a058 100644 --- a/packages/core/src/baseclient.ts +++ b/packages/core/src/baseclient.ts @@ -1,5 +1,4 @@ /* eslint-disable max-lines */ -import { Scope, updateSession } from '@sentry/hub'; import { Client, ClientOptions, @@ -40,6 +39,8 @@ import { import { getEnvelopeEndpointWithUrlEncodedAuth } from './api'; import { createEventEnvelope, createSessionEnvelope } from './envelope'; import { IntegrationIndex, setupIntegrations } from './integration'; +import { Scope } from './scope'; +import { updateSession } from './session'; const ALREADY_SEEN_ERROR = "Not capturing exception because it's already been captured."; diff --git a/packages/hub/src/exports.ts b/packages/core/src/exports.ts similarity index 100% rename from packages/hub/src/exports.ts rename to packages/core/src/exports.ts diff --git a/packages/hub/src/hub.ts b/packages/core/src/hub.ts similarity index 100% rename from packages/hub/src/hub.ts rename to packages/core/src/hub.ts diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 0d1a686b8e5e..ad1948ce84fb 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -1,4 +1,5 @@ export type { ClientClass } from './sdk'; +export type { Carrier, Layer } from './hub'; export { addBreadcrumb, @@ -14,13 +15,11 @@ export { setTags, setUser, withScope, - addGlobalEventProcessor, - getCurrentHub, - getHubFromCarrier, - Hub, - makeMain, - Scope, -} from '@sentry/hub'; +} from './exports'; +export { getCurrentHub, getHubFromCarrier, Hub, makeMain, getMainCarrier, setHubOnCarrier } from './hub'; +export { makeSession, closeSession, updateSession } from './session'; +export { SessionFlusher } from './sessionflusher'; +export { addGlobalEventProcessor, Scope } from './scope'; export { getEnvelopeEndpointWithUrlEncodedAuth, getReportDialogEndpoint } from './api'; export { BaseClient } from './baseclient'; export { initAndBind } from './sdk'; diff --git a/packages/core/src/integration.ts b/packages/core/src/integration.ts index 153bb0cd0d65..d00aa04e50c7 100644 --- a/packages/core/src/integration.ts +++ b/packages/core/src/integration.ts @@ -1,7 +1,9 @@ -import { addGlobalEventProcessor, getCurrentHub } from '@sentry/hub'; import { Integration, Options } from '@sentry/types'; import { arrayify, logger } from '@sentry/utils'; +import { getCurrentHub } from './hub'; +import { addGlobalEventProcessor } from './scope'; + declare module '@sentry/types' { interface Integration { isDefaultInstance?: boolean; diff --git a/packages/hub/src/scope.ts b/packages/core/src/scope.ts similarity index 100% rename from packages/hub/src/scope.ts rename to packages/core/src/scope.ts diff --git a/packages/core/src/sdk.ts b/packages/core/src/sdk.ts index 3f8aa203f051..16a64520ff48 100644 --- a/packages/core/src/sdk.ts +++ b/packages/core/src/sdk.ts @@ -1,7 +1,8 @@ -import { getCurrentHub } from '@sentry/hub'; import { Client, ClientOptions } from '@sentry/types'; import { logger } from '@sentry/utils'; +import { getCurrentHub } from './hub'; + /** A class object that can instantiate Client objects. */ export type ClientClass = new (options: O) => F; diff --git a/packages/hub/src/session.ts b/packages/core/src/session.ts similarity index 100% rename from packages/hub/src/session.ts rename to packages/core/src/session.ts diff --git a/packages/hub/src/sessionflusher.ts b/packages/core/src/sessionflusher.ts similarity index 100% rename from packages/hub/src/sessionflusher.ts rename to packages/core/src/sessionflusher.ts diff --git a/packages/core/test/lib/base.test.ts b/packages/core/test/lib/base.test.ts index 4d0bf265af46..a29bf4f726ac 100644 --- a/packages/core/test/lib/base.test.ts +++ b/packages/core/test/lib/base.test.ts @@ -1,7 +1,7 @@ -import { Hub, makeSession, Scope } from '@sentry/hub'; import { Event, Span } from '@sentry/types'; import { dsnToString, logger, SentryError, SyncPromise } from '@sentry/utils'; +import { Hub, makeSession, Scope } from '../../src'; import * as integrationModule from '../../src/integration'; import { getDefaultTestClientOptions, TestClient } from '../mocks/client'; import { TestIntegration } from '../mocks/integration'; diff --git a/packages/core/test/lib/hint.test.ts b/packages/core/test/lib/hint.test.ts index 03b755a63c71..72748192eb8d 100644 --- a/packages/core/test/lib/hint.test.ts +++ b/packages/core/test/lib/hint.test.ts @@ -1,4 +1,4 @@ -import { captureEvent, configureScope } from '@sentry/hub'; +import { captureEvent, configureScope } from '@sentry/core'; import { getGlobalObject } from '@sentry/utils'; import { initAndBind } from '../../src/sdk'; diff --git a/packages/core/test/lib/sdk.test.ts b/packages/core/test/lib/sdk.test.ts index d2857a2d83bd..84dc75fbc3a2 100644 --- a/packages/core/test/lib/sdk.test.ts +++ b/packages/core/test/lib/sdk.test.ts @@ -1,4 +1,4 @@ -import { Scope } from '@sentry/hub'; +import { Scope } from '@sentry/core'; import { Client, Integration } from '@sentry/types'; import { installedIntegrations } from '../../src/integration'; @@ -10,8 +10,8 @@ declare var global: any; const PUBLIC_DSN = 'https://username@domain/123'; -jest.mock('@sentry/hub', () => { - const original = jest.requireActual('@sentry/hub'); +jest.mock('@sentry/core', () => { + const original = jest.requireActual('@sentry/core'); return { ...original, getCurrentHub(): { diff --git a/packages/core/test/mocks/integration.ts b/packages/core/test/mocks/integration.ts index 868446665949..ff15be3f2c4d 100644 --- a/packages/core/test/mocks/integration.ts +++ b/packages/core/test/mocks/integration.ts @@ -1,6 +1,7 @@ -import { configureScope, getCurrentHub } from '@sentry/hub'; import { Event, EventProcessor, Integration } from '@sentry/types'; +import { configureScope, getCurrentHub } from '../../src'; + export class TestIntegration implements Integration { public static id: string = 'TestIntegration'; diff --git a/packages/hub/package.json b/packages/hub/package.json index 4856d8c8ea2a..0289f6fe9528 100644 --- a/packages/hub/package.json +++ b/packages/hub/package.json @@ -16,6 +16,7 @@ "access": "public" }, "dependencies": { + "@sentry/core": "7.14.2", "@sentry/types": "7.14.2", "@sentry/utils": "7.14.2", "tslib": "^1.9.3" diff --git a/packages/hub/src/index.ts b/packages/hub/src/index.ts index 16c4f3680dd8..deec8a597632 100644 --- a/packages/hub/src/index.ts +++ b/packages/hub/src/index.ts @@ -1,21 +1,154 @@ -export type { Carrier, Layer } from './hub'; - -export { addGlobalEventProcessor, Scope } from './scope'; -export { closeSession, makeSession, updateSession } from './session'; -export { SessionFlusher } from './sessionflusher'; -export { getCurrentHub, getHubFromCarrier, getMainCarrier, Hub, makeMain, setHubOnCarrier } from './hub'; -export { - addBreadcrumb, - captureException, - captureEvent, - captureMessage, - configureScope, - startTransaction, - setContext, - setExtra, - setExtras, - setTag, - setTags, - setUser, - withScope, -} from './exports'; +export type { Carrier, Layer } from '@sentry/core'; + +import { + addBreadcrumb as addBreadcrumbCore, + addGlobalEventProcessor as addGlobalEventProcessorCore, + captureEvent as captureEventCore, + captureException as captureExceptionCore, + captureMessage as captureMessageCore, + closeSession as closeSessionCore, + configureScope as configureScopeCore, + getCurrentHub as getCurrentHubCore, + getHubFromCarrier as getHubFromCarrierCore, + getMainCarrier as getMainCarrierCore, + Hub as HubCore, + makeMain as makeMainCore, + makeSession as makeSessionCore, + Scope as ScopeCore, + SessionFlusher as SessionFlusherCore, + setContext as setContextCore, + setExtra as setExtraCore, + setExtras as setExtrasCore, + setHubOnCarrier as setHubOnCarrierCore, + setTag as setTagCore, + setTags as setTagsCore, + setUser as setUserCore, + startTransaction as startTransactionCore, + updateSession as updateSessionCore, + withScope as withScopeCore, +} from '@sentry/core'; + +/** + * @deprecated This export has moved to @sentry/core. The @sentry/hub package will be removed in v8 + */ +export class Hub extends HubCore {} + +/** + * @deprecated This export has moved to @sentry/core. The @sentry/hub package will be removed in v8 + */ +export class Scope extends ScopeCore {} + +/** + * @deprecated This export has moved to @sentry/core. The @sentry/hub package will be removed in v8. + */ +export const getCurrentHub = getCurrentHubCore; + +/** + * @deprecated This export has moved to @sentry/core. The @sentry/hub package will be removed in v8. + */ +export const addGlobalEventProcessor = addGlobalEventProcessorCore; + +/** + * @deprecated This export has moved to @sentry/core. The @sentry/hub package will be removed in v8. + */ +export const getHubFromCarrier = getHubFromCarrierCore; + +/** + * @deprecated This export has moved to @sentry/core. The @sentry/hub package will be removed in v8. + */ +export const getMainCarrier = getMainCarrierCore; + +/** + * @deprecated This export has moved to @sentry/core. The @sentry/hub package will be removed in v8. + */ +export const makeMain = makeMainCore; + +/** + * @deprecated This export has moved to @sentry/core. The @sentry/hub package will be removed in v8. + */ +export const setHubOnCarrier = setHubOnCarrierCore; + +/** + * @deprecated This export has moved to @sentry/core. The @sentry/hub package will be removed in v8. + */ +export const SessionFlusher = SessionFlusherCore; + +/** + * @deprecated This export has moved to @sentry/core. The @sentry/hub package will be removed in v8. + */ +export const closeSession = closeSessionCore; + +/** + * @deprecated This export has moved to @sentry/core. The @sentry/hub package will be removed in v8. + */ +export const makeSession = makeSessionCore; + +/** + * @deprecated This export has moved to @sentry/core. The @sentry/hub package will be removed in v8. + */ +export const updateSession = updateSessionCore; + +/** + * @deprecated This export has moved to @sentry/core. The @sentry/hub package will be removed in v8. + */ +export const addBreadcrumb = addBreadcrumbCore; + +/** + * @deprecated This export has moved to @sentry/core. The @sentry/hub package will be removed in v8. + */ +export const captureException = captureExceptionCore; + +/** + * @deprecated This export has moved to @sentry/core. The @sentry/hub package will be removed in v8. + */ +export const captureEvent = captureEventCore; + +/** + * @deprecated This export has moved to @sentry/core. The @sentry/hub package will be removed in v8. + */ +export const captureMessage = captureMessageCore; + +/** + * @deprecated This export has moved to @sentry/core. The @sentry/hub package will be removed in v8. + */ +export const configureScope = configureScopeCore; + +/** + * @deprecated This export has moved to @sentry/core. The @sentry/hub package will be removed in v8. + */ +export const startTransaction = startTransactionCore; + +/** + * @deprecated This export has moved to @sentry/core. The @sentry/hub package will be removed in v8. + */ +export const setContext = setContextCore; + +/** + * @deprecated This export has moved to @sentry/core. The @sentry/hub package will be removed in v8. + */ +export const setExtra = setExtraCore; + +/** + * @deprecated This export has moved to @sentry/core. The @sentry/hub package will be removed in v8. + */ +export const setExtras = setExtrasCore; + +/** + * @deprecated This export has moved to @sentry/core. The @sentry/hub package will be removed in v8. + */ +export const setTag = setTagCore; + +/** + * @deprecated This export has moved to @sentry/core. The @sentry/hub package will be removed in v8. + */ +export const setTags = setTagsCore; + +/** + * @deprecated This export has moved to @sentry/core. The @sentry/hub package will be removed in v8. + */ +export const setUser = setUserCore; + +/** + * @deprecated This export has moved to @sentry/core. The @sentry/hub package will be removed in v8. + */ +export const withScope = withScopeCore; diff --git a/packages/hub/test/exports.test.ts b/packages/hub/test/exports.test.ts index af24b4623a43..a0fabf8061f6 100644 --- a/packages/hub/test/exports.test.ts +++ b/packages/hub/test/exports.test.ts @@ -1,9 +1,13 @@ -import { getCurrentHub, getHubFromCarrier, Scope } from '../src'; +/* eslint-disable deprecation/deprecation */ + import { captureEvent, captureException, captureMessage, configureScope, + getCurrentHub, + getHubFromCarrier, + Scope, setContext, setExtra, setExtras, @@ -11,7 +15,7 @@ import { setTags, setUser, withScope, -} from '../src/exports'; +} from '../src'; export class TestClient { public static instance?: TestClient; diff --git a/packages/hub/test/global.test.ts b/packages/hub/test/global.test.ts index 8dc32acb7fc7..66383af45c52 100644 --- a/packages/hub/test/global.test.ts +++ b/packages/hub/test/global.test.ts @@ -1,3 +1,5 @@ +/* eslint-disable deprecation/deprecation */ + import { getGlobalObject } from '@sentry/utils'; import { getCurrentHub, getHubFromCarrier, Hub } from '../src'; diff --git a/packages/hub/test/hub.test.ts b/packages/hub/test/hub.test.ts index 4513c92aaa94..5ce521ead4c4 100644 --- a/packages/hub/test/hub.test.ts +++ b/packages/hub/test/hub.test.ts @@ -1,4 +1,6 @@ /* eslint-disable @typescript-eslint/unbound-method */ +/* eslint-disable deprecation/deprecation */ + import { Client, Event } from '@sentry/types'; import { getCurrentHub, Hub, Scope } from '../src'; diff --git a/packages/hub/test/scope.test.ts b/packages/hub/test/scope.test.ts index d5584f38e596..7a65c436dcc3 100644 --- a/packages/hub/test/scope.test.ts +++ b/packages/hub/test/scope.test.ts @@ -1,3 +1,5 @@ +/* eslint-disable deprecation/deprecation */ + import { Event, EventHint, RequestSessionStatus } from '@sentry/types'; import { getGlobalObject } from '@sentry/utils'; diff --git a/packages/hub/test/session.test.ts b/packages/hub/test/session.test.ts index f57267fd11c0..9de03fa34940 100644 --- a/packages/hub/test/session.test.ts +++ b/packages/hub/test/session.test.ts @@ -1,7 +1,9 @@ +/* eslint-disable deprecation/deprecation */ + import { SessionContext } from '@sentry/types'; import { timestampInSeconds } from '@sentry/utils'; -import { closeSession, makeSession, updateSession } from '../src/session'; +import { closeSession, makeSession, updateSession } from '../src'; describe('Session', () => { it('initializes with the proper defaults', () => { diff --git a/packages/hub/test/sessionflusher.test.ts b/packages/hub/test/sessionflusher.test.ts index 58ce3ee374ce..b743eeca1e70 100644 --- a/packages/hub/test/sessionflusher.test.ts +++ b/packages/hub/test/sessionflusher.test.ts @@ -1,6 +1,8 @@ +/* eslint-disable deprecation/deprecation */ + import { Client } from '@sentry/types'; -import { SessionFlusher } from '../src/sessionflusher'; +import { SessionFlusher } from '../src'; describe('Session Flusher', () => { let sendSession: jest.Mock; diff --git a/packages/nextjs/package.json b/packages/nextjs/package.json index d4a4f6c2ba5d..d9a80a468d37 100644 --- a/packages/nextjs/package.json +++ b/packages/nextjs/package.json @@ -19,7 +19,6 @@ "dependencies": { "@rollup/plugin-sucrase": "4.0.4", "@sentry/core": "7.14.2", - "@sentry/hub": "7.14.2", "@sentry/integrations": "7.14.2", "@sentry/node": "7.14.2", "@sentry/react": "7.14.2", diff --git a/packages/nextjs/src/index.server.ts b/packages/nextjs/src/index.server.ts index ffd989510b11..98037d2c777a 100644 --- a/packages/nextjs/src/index.server.ts +++ b/packages/nextjs/src/index.server.ts @@ -1,4 +1,4 @@ -import { Carrier, getHubFromCarrier, getMainCarrier } from '@sentry/hub'; +import { Carrier, getHubFromCarrier, getMainCarrier } from '@sentry/core'; import { RewriteFrames } from '@sentry/integrations'; import { configureScope, getCurrentHub, init as nodeInit, Integrations } from '@sentry/node'; import { hasTracingEnabled } from '@sentry/tracing'; diff --git a/packages/nextjs/src/performance/client.ts b/packages/nextjs/src/performance/client.ts index fd7d7dadbf2a..c1cea58dc5e6 100644 --- a/packages/nextjs/src/performance/client.ts +++ b/packages/nextjs/src/performance/client.ts @@ -1,4 +1,4 @@ -import { getCurrentHub } from '@sentry/hub'; +import { getCurrentHub } from '@sentry/core'; import { Primitive, TraceparentData, Transaction, TransactionContext, TransactionSource } from '@sentry/types'; import { baggageHeaderToDynamicSamplingContext, diff --git a/packages/nextjs/src/utils/_error.ts b/packages/nextjs/src/utils/_error.ts index 9871bb277071..6508eb39ba6e 100644 --- a/packages/nextjs/src/utils/_error.ts +++ b/packages/nextjs/src/utils/_error.ts @@ -1,5 +1,4 @@ -import { captureException, withScope } from '@sentry/core'; -import { getCurrentHub } from '@sentry/hub'; +import { captureException, getCurrentHub, withScope } from '@sentry/core'; import { addExceptionMechanism } from '@sentry/utils'; import { NextPageContext } from 'next'; diff --git a/packages/nextjs/test/config/withSentry.test.ts b/packages/nextjs/test/config/withSentry.test.ts index 2485b10f64d7..4314d1e32faa 100644 --- a/packages/nextjs/test/config/withSentry.test.ts +++ b/packages/nextjs/test/config/withSentry.test.ts @@ -1,4 +1,4 @@ -import * as hub from '@sentry/hub'; +import * as hub from '@sentry/core'; import * as Sentry from '@sentry/node'; import { Client, ClientOptions } from '@sentry/types'; import * as utils from '@sentry/utils'; diff --git a/packages/nextjs/test/index.client.test.ts b/packages/nextjs/test/index.client.test.ts index 89ca6fdb6c93..9a2ec99141d8 100644 --- a/packages/nextjs/test/index.client.test.ts +++ b/packages/nextjs/test/index.client.test.ts @@ -1,5 +1,4 @@ -import { BaseClient } from '@sentry/core'; -import { getCurrentHub } from '@sentry/hub'; +import { BaseClient, getCurrentHub } from '@sentry/core'; import * as SentryReact from '@sentry/react'; import { Integrations as TracingIntegrations } from '@sentry/tracing'; import { Integration } from '@sentry/types'; diff --git a/packages/nextjs/test/integration/package.json b/packages/nextjs/test/integration/package.json index 676dc93089c4..a17ca83b7ad5 100644 --- a/packages/nextjs/test/integration/package.json +++ b/packages/nextjs/test/integration/package.json @@ -26,7 +26,6 @@ "resolutions": { "@sentry/browser": "file:../../../browser", "@sentry/core": "file:../../../core", - "@sentry/hub": "file:../../../hub", "@sentry/integrations": "file:../../../integrations", "@sentry/node": "file:../../../node", "@sentry/react": "file:../../../react", diff --git a/packages/node/package.json b/packages/node/package.json index 1b92ee027d77..a3c499bbe6c6 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -17,7 +17,6 @@ }, "dependencies": { "@sentry/core": "7.14.2", - "@sentry/hub": "7.14.2", "@sentry/types": "7.14.2", "@sentry/utils": "7.14.2", "cookie": "^0.4.1", diff --git a/packages/node/src/client.ts b/packages/node/src/client.ts index d8a98ee3bfd5..66dc8fb4ce27 100644 --- a/packages/node/src/client.ts +++ b/packages/node/src/client.ts @@ -1,5 +1,4 @@ -import { BaseClient, Scope, SDK_VERSION } from '@sentry/core'; -import { SessionFlusher } from '@sentry/hub'; +import { BaseClient, Scope, SDK_VERSION, SessionFlusher } from '@sentry/core'; import { Event, EventHint, Severity, SeverityLevel } from '@sentry/types'; import { logger, resolvedSyncPromise } from '@sentry/utils'; import * as os from 'os'; diff --git a/packages/node/src/eventbuilder.ts b/packages/node/src/eventbuilder.ts index c6fdeb0598e2..3d97d2a602ab 100644 --- a/packages/node/src/eventbuilder.ts +++ b/packages/node/src/eventbuilder.ts @@ -1,4 +1,4 @@ -import { getCurrentHub } from '@sentry/hub'; +import { getCurrentHub } from '@sentry/core'; import { Event, EventHint, diff --git a/packages/node/src/index.ts b/packages/node/src/index.ts index 566340c6b7c6..68d96e6e524a 100644 --- a/packages/node/src/index.ts +++ b/packages/node/src/index.ts @@ -51,8 +51,7 @@ export { defaultIntegrations, init, defaultStackParser, lastEventId, flush, clos export { addRequestDataToEvent, DEFAULT_USER_INCLUDES, extractRequestData } from './requestdata'; export { deepReadDirSync } from './utils'; -import { Integrations as CoreIntegrations } from '@sentry/core'; -import { getMainCarrier } from '@sentry/hub'; +import { getMainCarrier, Integrations as CoreIntegrations } from '@sentry/core'; import * as domain from 'domain'; import * as Handlers from './handlers'; @@ -66,7 +65,7 @@ const INTEGRATIONS = { export { INTEGRATIONS as Integrations, Handlers }; // We need to patch domain on the global __SENTRY__ object to make it work for node in cross-platform packages like -// @sentry/hub. If we don't do this, browser bundlers will have troubles resolving `require('domain')`. +// @sentry/core. If we don't do this, browser bundlers will have troubles resolving `require('domain')`. const carrier = getMainCarrier(); if (carrier.__SENTRY__) { carrier.__SENTRY__.extensions = carrier.__SENTRY__.extensions || {}; diff --git a/packages/node/src/sdk.ts b/packages/node/src/sdk.ts index 9f4a7eb3ee3c..118fe200d46c 100644 --- a/packages/node/src/sdk.ts +++ b/packages/node/src/sdk.ts @@ -1,6 +1,12 @@ /* eslint-disable max-lines */ -import { getCurrentHub, getIntegrationsToSetup, initAndBind, Integrations as CoreIntegrations } from '@sentry/core'; -import { getMainCarrier, setHubOnCarrier } from '@sentry/hub'; +import { + getCurrentHub, + getIntegrationsToSetup, + getMainCarrier, + initAndBind, + Integrations as CoreIntegrations, + setHubOnCarrier, +} from '@sentry/core'; import { SessionStatus, StackParser } from '@sentry/types'; import { createStackParser, diff --git a/packages/node/test/client.test.ts b/packages/node/test/client.test.ts index 6c4a2193c762..a219a307f9d9 100644 --- a/packages/node/test/client.test.ts +++ b/packages/node/test/client.test.ts @@ -1,4 +1,4 @@ -import { Scope, SessionFlusher } from '@sentry/hub'; +import { Scope, SessionFlusher } from '@sentry/core'; import { Event, EventHint } from '@sentry/types'; import * as os from 'os'; diff --git a/packages/node/test/eventbuilders.test.ts b/packages/node/test/eventbuilders.test.ts index f92ec303bb3c..49f8e8156c5c 100644 --- a/packages/node/test/eventbuilders.test.ts +++ b/packages/node/test/eventbuilders.test.ts @@ -5,8 +5,8 @@ import { eventFromUnknownInput } from '../src/eventbuilder'; const testScope = new Scope(); -jest.mock('@sentry/hub', () => { - const original = jest.requireActual('@sentry/hub'); +jest.mock('@sentry/core', () => { + const original = jest.requireActual('@sentry/core'); return { ...original, getCurrentHub(): { diff --git a/packages/node/test/handlers.test.ts b/packages/node/test/handlers.test.ts index 9910048cd942..ed35c01ef25d 100644 --- a/packages/node/test/handlers.test.ts +++ b/packages/node/test/handlers.test.ts @@ -1,6 +1,5 @@ import * as sentryCore from '@sentry/core'; -import * as sentryHub from '@sentry/hub'; -import { Hub } from '@sentry/hub'; +import { Hub, Scope } from '@sentry/core'; import { Transaction } from '@sentry/tracing'; import { Event } from '@sentry/types'; import { SentryError } from '@sentry/utils'; @@ -277,10 +276,8 @@ describe('tracingHandler', () => { it('puts its transaction on the scope', () => { const options = getDefaultNodeClientOptions({ tracesSampleRate: 1.0 }); const hub = new Hub(new NodeClient(options)); - // we need to mock both of these because the tracing handler relies on `@sentry/core` while the sampler relies on - // `@sentry/hub`, and mocking breaks the link between the two + jest.spyOn(sentryCore, 'getCurrentHub').mockReturnValue(hub); - jest.spyOn(sentryHub, 'getCurrentHub').mockReturnValue(hub); sentryTracingMiddleware(req, res, next); @@ -443,7 +440,6 @@ describe('errorHandler()', () => { jest.spyOn(client, '_captureRequestSession'); jest.spyOn(sentryCore, 'getCurrentHub').mockReturnValue(hub); - jest.spyOn(sentryHub, 'getCurrentHub').mockReturnValue(hub); scope?.setRequestSession({ status: 'ok' }); sentryErrorMiddleware({ name: 'error', message: 'this is an error' }, req, res, next); @@ -460,7 +456,6 @@ describe('errorHandler()', () => { jest.spyOn(client, '_captureRequestSession'); jest.spyOn(sentryCore, 'getCurrentHub').mockReturnValue(hub); - jest.spyOn(sentryHub, 'getCurrentHub').mockReturnValue(hub); scope?.setRequestSession({ status: 'ok' }); sentryErrorMiddleware({ name: 'error', message: 'this is an error' }, req, res, next); @@ -474,7 +469,7 @@ describe('errorHandler()', () => { // It is required to initialise SessionFlusher to capture Session Aggregates (it is usually initialised // by the`requestHandler`) client.initSessionFlusher(); - const scope = new sentryHub.Scope(); + const scope = new Scope(); const hub = new Hub(client, scope); jest.spyOn(client, '_captureRequestSession'); @@ -493,12 +488,11 @@ describe('errorHandler()', () => { // It is required to initialise SessionFlusher to capture Session Aggregates (it is usually initialised // by the`requestHandler`) client.initSessionFlusher(); - const scope = new sentryHub.Scope(); + const scope = new Scope(); const hub = new Hub(client, scope); jest.spyOn(client, '_captureRequestSession'); jest.spyOn(sentryCore, 'getCurrentHub').mockReturnValue(hub); - jest.spyOn(sentryHub, 'getCurrentHub').mockReturnValue(hub); sentryErrorMiddleware({ name: 'error', message: 'this is an error' }, req, res, next); const requestSession = scope?.getRequestSession(); diff --git a/packages/node/test/index.test.ts b/packages/node/test/index.test.ts index 7b127637778c..7e5fc929beea 100644 --- a/packages/node/test/index.test.ts +++ b/packages/node/test/index.test.ts @@ -1,5 +1,4 @@ -import { initAndBind, SDK_VERSION } from '@sentry/core'; -import { getMainCarrier } from '@sentry/hub'; +import { getMainCarrier, initAndBind, SDK_VERSION } from '@sentry/core'; import { EventHint, Integration } from '@sentry/types'; import * as domain from 'domain'; diff --git a/packages/node/test/integrations/http.test.ts b/packages/node/test/integrations/http.test.ts index c401c7584574..94bc4edf6c30 100644 --- a/packages/node/test/integrations/http.test.ts +++ b/packages/node/test/integrations/http.test.ts @@ -1,6 +1,5 @@ import * as sentryCore from '@sentry/core'; -import * as hubModule from '@sentry/hub'; -import { Hub } from '@sentry/hub'; +import { Hub } from '@sentry/core'; import { addExtensionMethods, Span, TRACEPARENT_REGEXP, Transaction } from '@sentry/tracing'; import { TransactionContext } from '@sentry/types'; import { parseSemver } from '@sentry/utils'; @@ -43,10 +42,7 @@ describe('tracing', () => { }), ); - // we need to mock both of these because the tracing handler relies on `@sentry/core` while the sampler relies on - // `@sentry/hub`, and mocking breaks the link between the two jest.spyOn(sentryCore, 'getCurrentHub').mockReturnValue(hub); - jest.spyOn(hubModule, 'getCurrentHub').mockReturnValue(hub); const transaction = hub.startTransaction({ name: 'dogpark', @@ -212,10 +208,7 @@ describe('tracing', () => { const hub = new Hub(); - // we need to mock both of these because the tracing handler relies on `@sentry/core` while the sampler relies on - // `@sentry/hub`, and mocking breaks the link between the two jest.spyOn(sentryCore, 'getCurrentHub').mockImplementation(() => hub); - jest.spyOn(hubModule, 'getCurrentHub').mockImplementation(() => hub); const client = new NodeClient(options); jest.spyOn(hub, 'getClient').mockImplementation(() => client); diff --git a/packages/node/test/onuncaughtexception.test.ts b/packages/node/test/onuncaughtexception.test.ts index 7527eea00993..54b49fdb8587 100644 --- a/packages/node/test/onuncaughtexception.test.ts +++ b/packages/node/test/onuncaughtexception.test.ts @@ -1,10 +1,10 @@ -import { Hub } from '@sentry/hub'; +import { Hub } from '@sentry/core'; import { OnUncaughtException } from '../src/integrations/onuncaughtexception'; -jest.mock('@sentry/hub', () => { +jest.mock('@sentry/core', () => { // we just want to short-circuit it, so dont worry about types - const original = jest.requireActual('@sentry/hub'); + const original = jest.requireActual('@sentry/core'); original.Hub.prototype.getIntegration = () => true; return { ...original, diff --git a/packages/node/test/onunhandledrejection.test.ts b/packages/node/test/onunhandledrejection.test.ts index 012e6b37643f..3c5e60883eee 100644 --- a/packages/node/test/onunhandledrejection.test.ts +++ b/packages/node/test/onunhandledrejection.test.ts @@ -1,4 +1,4 @@ -import { Hub } from '@sentry/hub'; +import { Hub } from '@sentry/core'; import { OnUnhandledRejection } from '../src/integrations/onunhandledrejection'; @@ -6,9 +6,9 @@ import { OnUnhandledRejection } from '../src/integrations/onunhandledrejection'; global.console.warn = () => null; global.console.error = () => null; -jest.mock('@sentry/hub', () => { +jest.mock('@sentry/core', () => { // we just want to short-circuit it, so dont worry about types - const original = jest.requireActual('@sentry/hub'); + const original = jest.requireActual('@sentry/core'); original.Hub.prototype.getIntegration = () => true; return { ...original, diff --git a/packages/remix/package.json b/packages/remix/package.json index 4f8a89f52129..29f1291bd0d0 100644 --- a/packages/remix/package.json +++ b/packages/remix/package.json @@ -22,7 +22,6 @@ "dependencies": { "@sentry/cli": "2.2.0", "@sentry/core": "7.14.2", - "@sentry/hub": "7.14.2", "@sentry/integrations": "7.14.2", "@sentry/node": "7.14.2", "@sentry/react": "7.14.2", diff --git a/packages/remix/src/utils/serverAdapters/express.ts b/packages/remix/src/utils/serverAdapters/express.ts index 76ef655236ff..7582cfe3303d 100644 --- a/packages/remix/src/utils/serverAdapters/express.ts +++ b/packages/remix/src/utils/serverAdapters/express.ts @@ -1,4 +1,4 @@ -import { getCurrentHub } from '@sentry/hub'; +import { getCurrentHub } from '@sentry/core'; import { flush } from '@sentry/node'; import { hasTracingEnabled } from '@sentry/tracing'; import { Transaction } from '@sentry/types'; diff --git a/packages/remix/test/index.client.test.ts b/packages/remix/test/index.client.test.ts index eaca0b58c0f5..9027811a1df5 100644 --- a/packages/remix/test/index.client.test.ts +++ b/packages/remix/test/index.client.test.ts @@ -1,4 +1,4 @@ -import { getCurrentHub } from '@sentry/hub'; +import { getCurrentHub } from '@sentry/core'; import * as SentryReact from '@sentry/react'; import { getGlobalObject } from '@sentry/utils'; diff --git a/packages/remix/test/integration/package.json b/packages/remix/test/integration/package.json index 5a9173a68f69..504427932e00 100644 --- a/packages/remix/test/integration/package.json +++ b/packages/remix/test/integration/package.json @@ -25,7 +25,6 @@ "resolutions": { "@sentry/browser": "file:../../../browser", "@sentry/core": "file:../../../core", - "@sentry/hub": "file:../../../hub", "@sentry/integrations": "file:../../../integrations", "@sentry/node": "file:../../../node", "@sentry/react": "file:../../../react", diff --git a/packages/svelte/test/performance.test.ts b/packages/svelte/test/performance.test.ts index e5ecae861a41..cb039870a719 100644 --- a/packages/svelte/test/performance.test.ts +++ b/packages/svelte/test/performance.test.ts @@ -1,4 +1,4 @@ -import { Scope } from '@sentry/hub'; +import { Scope } from '@sentry/core'; import { act, render } from '@testing-library/svelte'; // linter doesn't like Svelte component imports @@ -19,8 +19,8 @@ const testInitSpan: any = { startChild: jest.fn(), }; -jest.mock('@sentry/hub', () => { - const original = jest.requireActual('@sentry/hub'); +jest.mock('@sentry/core', () => { + const original = jest.requireActual('@sentry/core'); return { ...original, getCurrentHub(): { diff --git a/packages/tracing/package.json b/packages/tracing/package.json index 3b0ca48eb420..cbf289a5d397 100644 --- a/packages/tracing/package.json +++ b/packages/tracing/package.json @@ -16,7 +16,7 @@ "access": "public" }, "dependencies": { - "@sentry/hub": "7.14.2", + "@sentry/core": "7.14.2", "@sentry/types": "7.14.2", "@sentry/utils": "7.14.2", "tslib": "^1.9.3" diff --git a/packages/tracing/src/browser/browsertracing.ts b/packages/tracing/src/browser/browsertracing.ts index f0924b543450..7f89dd1e29fc 100644 --- a/packages/tracing/src/browser/browsertracing.ts +++ b/packages/tracing/src/browser/browsertracing.ts @@ -1,5 +1,5 @@ /* eslint-disable max-lines */ -import { Hub } from '@sentry/hub'; +import { Hub } from '@sentry/core'; import { EventProcessor, Integration, Transaction, TransactionContext } from '@sentry/types'; import { baggageHeaderToDynamicSamplingContext, getDomElement, getGlobalObject, logger } from '@sentry/utils'; diff --git a/packages/tracing/src/hubextensions.ts b/packages/tracing/src/hubextensions.ts index e3f953805697..e3e833262a97 100644 --- a/packages/tracing/src/hubextensions.ts +++ b/packages/tracing/src/hubextensions.ts @@ -1,4 +1,4 @@ -import { getMainCarrier, Hub } from '@sentry/hub'; +import { getMainCarrier, Hub } from '@sentry/core'; import { ClientOptions, CustomSamplingContext, diff --git a/packages/tracing/src/idletransaction.ts b/packages/tracing/src/idletransaction.ts index c19f187fd00a..6bc72d8e6ce2 100644 --- a/packages/tracing/src/idletransaction.ts +++ b/packages/tracing/src/idletransaction.ts @@ -1,5 +1,5 @@ /* eslint-disable max-lines */ -import { Hub } from '@sentry/hub'; +import { Hub } from '@sentry/core'; import { TransactionContext } from '@sentry/types'; import { logger, timestampWithMs } from '@sentry/utils'; diff --git a/packages/tracing/src/integrations/node/apollo.ts b/packages/tracing/src/integrations/node/apollo.ts index d1449a91fe1b..8202164a0fec 100644 --- a/packages/tracing/src/integrations/node/apollo.ts +++ b/packages/tracing/src/integrations/node/apollo.ts @@ -1,4 +1,4 @@ -import { Hub } from '@sentry/hub'; +import { Hub } from '@sentry/core'; import { EventProcessor, Integration } from '@sentry/types'; import { arrayify, fill, isThenable, loadModule, logger } from '@sentry/utils'; diff --git a/packages/tracing/src/integrations/node/graphql.ts b/packages/tracing/src/integrations/node/graphql.ts index b8736cf995f9..cdb073779516 100644 --- a/packages/tracing/src/integrations/node/graphql.ts +++ b/packages/tracing/src/integrations/node/graphql.ts @@ -1,4 +1,4 @@ -import { Hub } from '@sentry/hub'; +import { Hub } from '@sentry/core'; import { EventProcessor, Integration } from '@sentry/types'; import { fill, isThenable, loadModule, logger } from '@sentry/utils'; diff --git a/packages/tracing/src/integrations/node/mongo.ts b/packages/tracing/src/integrations/node/mongo.ts index 624ac2ed4478..b580fc33bd1e 100644 --- a/packages/tracing/src/integrations/node/mongo.ts +++ b/packages/tracing/src/integrations/node/mongo.ts @@ -1,4 +1,4 @@ -import { Hub } from '@sentry/hub'; +import { Hub } from '@sentry/core'; import { EventProcessor, Integration, SpanContext } from '@sentry/types'; import { fill, isThenable, loadModule, logger } from '@sentry/utils'; diff --git a/packages/tracing/src/integrations/node/mysql.ts b/packages/tracing/src/integrations/node/mysql.ts index 3a2a3f626293..deacfedc8209 100644 --- a/packages/tracing/src/integrations/node/mysql.ts +++ b/packages/tracing/src/integrations/node/mysql.ts @@ -1,4 +1,4 @@ -import { Hub } from '@sentry/hub'; +import { Hub } from '@sentry/core'; import { EventProcessor, Integration } from '@sentry/types'; import { fill, loadModule, logger } from '@sentry/utils'; diff --git a/packages/tracing/src/integrations/node/postgres.ts b/packages/tracing/src/integrations/node/postgres.ts index 4c88be67014a..516c9dbe1ea7 100644 --- a/packages/tracing/src/integrations/node/postgres.ts +++ b/packages/tracing/src/integrations/node/postgres.ts @@ -1,4 +1,4 @@ -import { Hub } from '@sentry/hub'; +import { Hub } from '@sentry/core'; import { EventProcessor, Integration } from '@sentry/types'; import { fill, isThenable, loadModule, logger } from '@sentry/utils'; diff --git a/packages/tracing/src/integrations/node/prisma.ts b/packages/tracing/src/integrations/node/prisma.ts index a1c9f553964b..9f743ca0f66e 100644 --- a/packages/tracing/src/integrations/node/prisma.ts +++ b/packages/tracing/src/integrations/node/prisma.ts @@ -1,4 +1,4 @@ -import { Hub } from '@sentry/hub'; +import { Hub } from '@sentry/core'; import { EventProcessor, Integration } from '@sentry/types'; import { isThenable, logger } from '@sentry/utils'; diff --git a/packages/tracing/src/transaction.ts b/packages/tracing/src/transaction.ts index 1fcfda5de64d..83d5d14e419f 100644 --- a/packages/tracing/src/transaction.ts +++ b/packages/tracing/src/transaction.ts @@ -1,4 +1,4 @@ -import { getCurrentHub, Hub } from '@sentry/hub'; +import { getCurrentHub, Hub } from '@sentry/core'; import { DynamicSamplingContext, Event, diff --git a/packages/tracing/src/utils.ts b/packages/tracing/src/utils.ts index 9d999df486fb..d79a4f91a2df 100644 --- a/packages/tracing/src/utils.ts +++ b/packages/tracing/src/utils.ts @@ -1,4 +1,4 @@ -import { getCurrentHub, Hub } from '@sentry/hub'; +import { getCurrentHub, Hub } from '@sentry/core'; import { Options, Transaction } from '@sentry/types'; /** diff --git a/packages/tracing/test/browser/backgroundtab.test.ts b/packages/tracing/test/browser/backgroundtab.test.ts index 3e332033d74d..47b7f14d8a7d 100644 --- a/packages/tracing/test/browser/backgroundtab.test.ts +++ b/packages/tracing/test/browser/backgroundtab.test.ts @@ -1,5 +1,5 @@ import { BrowserClient } from '@sentry/browser'; -import { Hub, makeMain } from '@sentry/hub'; +import { Hub, makeMain } from '@sentry/core'; import { JSDOM } from 'jsdom'; import { registerBackgroundTabDetection } from '../../src/browser/backgroundtab'; diff --git a/packages/tracing/test/browser/browsertracing.test.ts b/packages/tracing/test/browser/browsertracing.test.ts index 325078d05acf..dc4588605ebe 100644 --- a/packages/tracing/test/browser/browsertracing.test.ts +++ b/packages/tracing/test/browser/browsertracing.test.ts @@ -1,5 +1,5 @@ import { BrowserClient } from '@sentry/browser'; -import { Hub, makeMain } from '@sentry/hub'; +import { Hub, makeMain } from '@sentry/core'; import type { BaseTransportOptions, ClientOptions, DsnComponents } from '@sentry/types'; import { getGlobalObject, InstrumentHandlerCallback, InstrumentHandlerType } from '@sentry/utils'; import { JSDOM } from 'jsdom'; diff --git a/packages/tracing/test/browser/request.test.ts b/packages/tracing/test/browser/request.test.ts index 023c1414b0f0..0c11a2bee515 100644 --- a/packages/tracing/test/browser/request.test.ts +++ b/packages/tracing/test/browser/request.test.ts @@ -1,5 +1,5 @@ import { BrowserClient } from '@sentry/browser'; -import { Hub, makeMain } from '@sentry/hub'; +import { Hub, makeMain } from '@sentry/core'; import * as utils from '@sentry/utils'; import { Span, spanStatusfromHttpCode, Transaction } from '../../src'; diff --git a/packages/tracing/test/errors.test.ts b/packages/tracing/test/errors.test.ts index 6d3a3fa50768..7942bf2b85e9 100644 --- a/packages/tracing/test/errors.test.ts +++ b/packages/tracing/test/errors.test.ts @@ -1,5 +1,5 @@ import { BrowserClient } from '@sentry/browser'; -import { Hub, makeMain } from '@sentry/hub'; +import { Hub, makeMain } from '@sentry/core'; import { InstrumentHandlerCallback, InstrumentHandlerType } from '@sentry/utils'; import { registerErrorInstrumentation } from '../src/errors'; diff --git a/packages/tracing/test/hub.test.ts b/packages/tracing/test/hub.test.ts index e859a302878e..0b9e5e3a1b38 100644 --- a/packages/tracing/test/hub.test.ts +++ b/packages/tracing/test/hub.test.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/unbound-method */ import { BrowserClient } from '@sentry/browser'; -import { Hub, makeMain } from '@sentry/hub'; +import { Hub, makeMain } from '@sentry/core'; import * as utilsModule from '@sentry/utils'; // for mocking import { logger } from '@sentry/utils'; diff --git a/packages/tracing/test/idletransaction.test.ts b/packages/tracing/test/idletransaction.test.ts index 1e7af1d78c86..79cd3f546bf9 100644 --- a/packages/tracing/test/idletransaction.test.ts +++ b/packages/tracing/test/idletransaction.test.ts @@ -1,5 +1,5 @@ import { BrowserClient } from '@sentry/browser'; -import { Hub } from '@sentry/hub'; +import { Hub } from '@sentry/core'; import { DEFAULT_FINAL_TIMEOUT, diff --git a/packages/tracing/test/index.test.ts b/packages/tracing/test/index.test.ts index c01b8cad0b54..e8a7d0d09f52 100644 --- a/packages/tracing/test/index.test.ts +++ b/packages/tracing/test/index.test.ts @@ -1,4 +1,4 @@ -import { getCurrentHub } from '@sentry/hub'; +import { getCurrentHub } from '@sentry/core'; import { BrowserTracing, Integrations } from '../src'; diff --git a/packages/tracing/test/integrations/apollo.test.ts b/packages/tracing/test/integrations/apollo.test.ts index c178a00b10cd..2f8e5c843d07 100644 --- a/packages/tracing/test/integrations/apollo.test.ts +++ b/packages/tracing/test/integrations/apollo.test.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/unbound-method */ -import { Hub, Scope } from '@sentry/hub'; +import { Hub, Scope } from '@sentry/core'; import { Apollo } from '../../src/integrations/node/apollo'; import { Span } from '../../src/span'; diff --git a/packages/tracing/test/integrations/graphql.test.ts b/packages/tracing/test/integrations/graphql.test.ts index bf823899632d..e074dfc602f8 100644 --- a/packages/tracing/test/integrations/graphql.test.ts +++ b/packages/tracing/test/integrations/graphql.test.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/unbound-method */ -import { Hub, Scope } from '@sentry/hub'; +import { Hub, Scope } from '@sentry/core'; import { GraphQL } from '../../src/integrations/node/graphql'; import { Span } from '../../src/span'; diff --git a/packages/tracing/test/integrations/node/mongo.test.ts b/packages/tracing/test/integrations/node/mongo.test.ts index aefaa307df2c..b7417a6ae9b2 100644 --- a/packages/tracing/test/integrations/node/mongo.test.ts +++ b/packages/tracing/test/integrations/node/mongo.test.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/unbound-method */ -import { Hub, Scope } from '@sentry/hub'; +import { Hub, Scope } from '@sentry/core'; import { Mongo } from '../../../src/integrations/node/mongo'; import { Span } from '../../../src/span'; diff --git a/packages/tracing/test/integrations/node/postgres.test.ts b/packages/tracing/test/integrations/node/postgres.test.ts index f4b3eed1b2a7..4b6c23db41e6 100644 --- a/packages/tracing/test/integrations/node/postgres.test.ts +++ b/packages/tracing/test/integrations/node/postgres.test.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/unbound-method */ -import { Hub, Scope } from '@sentry/hub'; +import { Hub, Scope } from '@sentry/core'; import { Postgres } from '../../../src/integrations/node/postgres'; import { Span } from '../../../src/span'; diff --git a/packages/tracing/test/integrations/node/prisma.test.ts b/packages/tracing/test/integrations/node/prisma.test.ts index 0b795c2266b8..3c088ac25834 100644 --- a/packages/tracing/test/integrations/node/prisma.test.ts +++ b/packages/tracing/test/integrations/node/prisma.test.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/unbound-method */ -import { Hub, Scope } from '@sentry/hub'; +import { Hub, Scope } from '@sentry/core'; import { Prisma } from '../../../src/integrations/node/prisma'; import { Span } from '../../../src/span'; diff --git a/packages/tracing/test/span.test.ts b/packages/tracing/test/span.test.ts index 88630a859cb2..b269314d61bb 100644 --- a/packages/tracing/test/span.test.ts +++ b/packages/tracing/test/span.test.ts @@ -1,5 +1,5 @@ import { BrowserClient } from '@sentry/browser'; -import { Hub, makeMain, Scope } from '@sentry/hub'; +import { Hub, makeMain, Scope } from '@sentry/core'; import { BaseTransportOptions, ClientOptions, TransactionSource } from '@sentry/types'; import { Span, Transaction } from '../src';