From 6b15512626fc18a9f68652d95f217b3395e457a7 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Mon, 26 Sep 2022 19:14:29 +0100 Subject: [PATCH] Move @sentry/hub code to @sentry/core --- packages/browser/test/unit/sdk.test.ts | 4 ++-- packages/core/package.json | 1 - packages/core/src/baseclient.ts | 3 ++- packages/{hub => core}/src/exports.ts | 0 packages/{hub => core}/src/hub.ts | 0 packages/core/src/index.ts | 13 ++++++------ packages/core/src/integration.ts | 4 +++- packages/{hub => core}/src/scope.ts | 0 packages/core/src/sdk.ts | 3 ++- packages/{hub => core}/src/session.ts | 0 packages/{hub => core}/src/sessionflusher.ts | 0 packages/core/test/lib/base.test.ts | 2 +- packages/core/test/lib/hint.test.ts | 2 +- packages/core/test/lib/sdk.test.ts | 6 +++--- packages/core/test/mocks/integration.ts | 2 +- packages/hub/package.json | 3 +-- packages/hub/src/index.ts | 20 +++++++++++++------ packages/hub/test/exports.test.ts | 6 ++++-- packages/hub/test/session.test.ts | 2 +- packages/hub/test/sessionflusher.test.ts | 2 +- packages/nextjs/package.json | 1 - packages/nextjs/src/index.server.ts | 2 +- packages/nextjs/src/performance/client.ts | 2 +- packages/nextjs/src/utils/_error.ts | 3 +-- .../nextjs/test/config/withSentry.test.ts | 2 +- packages/nextjs/test/index.client.test.ts | 3 +-- packages/nextjs/test/integration/package.json | 1 - packages/node/package.json | 1 - packages/node/src/client.ts | 3 +-- packages/node/src/eventbuilder.ts | 2 +- packages/node/src/index.ts | 5 ++--- packages/node/src/sdk.ts | 10 ++++++++-- packages/node/test/client.test.ts | 2 +- packages/node/test/eventbuilders.test.ts | 4 ++-- packages/node/test/handlers.test.ts | 14 ++++--------- packages/node/test/index.test.ts | 3 +-- packages/node/test/integrations/http.test.ts | 9 +-------- .../node/test/onuncaughtexception.test.ts | 6 +++--- .../node/test/onunhandledrejection.test.ts | 6 +++--- packages/remix/package.json | 1 - .../remix/src/utils/serverAdapters/express.ts | 2 +- packages/remix/test/index.client.test.ts | 2 +- packages/remix/test/integration/package.json | 1 - packages/svelte/test/performance.test.ts | 6 +++--- packages/tracing/package.json | 2 +- .../tracing/src/browser/browsertracing.ts | 2 +- packages/tracing/src/hubextensions.ts | 2 +- packages/tracing/src/idletransaction.ts | 2 +- .../tracing/src/integrations/node/apollo.ts | 2 +- .../tracing/src/integrations/node/graphql.ts | 2 +- .../tracing/src/integrations/node/mongo.ts | 2 +- .../tracing/src/integrations/node/mysql.ts | 2 +- .../tracing/src/integrations/node/postgres.ts | 2 +- .../tracing/src/integrations/node/prisma.ts | 2 +- packages/tracing/src/transaction.ts | 2 +- packages/tracing/src/utils.ts | 2 +- .../test/browser/backgroundtab.test.ts | 2 +- .../test/browser/browsertracing.test.ts | 2 +- packages/tracing/test/browser/request.test.ts | 2 +- packages/tracing/test/errors.test.ts | 2 +- packages/tracing/test/hub.test.ts | 2 +- packages/tracing/test/idletransaction.test.ts | 2 +- packages/tracing/test/index.test.ts | 2 +- .../tracing/test/integrations/apollo.test.ts | 2 +- .../tracing/test/integrations/graphql.test.ts | 2 +- .../test/integrations/node/mongo.test.ts | 2 +- .../test/integrations/node/postgres.test.ts | 2 +- .../test/integrations/node/prisma.test.ts | 2 +- packages/tracing/test/span.test.ts | 2 +- 69 files changed, 104 insertions(+), 110 deletions(-) rename packages/{hub => core}/src/exports.ts (100%) rename packages/{hub => core}/src/hub.ts (100%) rename packages/{hub => core}/src/scope.ts (100%) rename packages/{hub => core}/src/session.ts (100%) rename packages/{hub => core}/src/sessionflusher.ts (100%) 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 fd97e77b2c75..cc973af9d815 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -16,7 +16,6 @@ "access": "public" }, "dependencies": { - "@sentry/hub": "7.13.0", "@sentry/types": "7.13.0", "@sentry/utils": "7.13.0", "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..ccbfc3da3e2e 100644 --- a/packages/core/test/mocks/integration.ts +++ b/packages/core/test/mocks/integration.ts @@ -1,4 +1,4 @@ -import { configureScope, getCurrentHub } from '@sentry/hub'; +import { configureScope, getCurrentHub } from '../../src'; import { Event, EventProcessor, Integration } from '@sentry/types'; export class TestIntegration implements Integration { diff --git a/packages/hub/package.json b/packages/hub/package.json index ad74b8760d83..850ff0e33a61 100644 --- a/packages/hub/package.json +++ b/packages/hub/package.json @@ -16,8 +16,7 @@ "access": "public" }, "dependencies": { - "@sentry/types": "7.13.0", - "@sentry/utils": "7.13.0", + "@sentry/core": "7.13.0", "tslib": "^1.9.3" }, "scripts": { diff --git a/packages/hub/src/index.ts b/packages/hub/src/index.ts index 16c4f3680dd8..70c0fd3e1f5c 100644 --- a/packages/hub/src/index.ts +++ b/packages/hub/src/index.ts @@ -1,10 +1,18 @@ -export type { Carrier, Layer } from './hub'; +export type { Carrier, Layer } from '@sentry/core'; -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 { + getCurrentHub, + addGlobalEventProcessor, + Scope, + getHubFromCarrier, + getMainCarrier, + Hub, + makeMain, + setHubOnCarrier, + SessionFlusher, + closeSession, + makeSession, + updateSession, addBreadcrumb, captureException, captureEvent, @@ -18,4 +26,4 @@ export { setTags, setUser, withScope, -} from './exports'; +} from '@sentry/core'; diff --git a/packages/hub/test/exports.test.ts b/packages/hub/test/exports.test.ts index af24b4623a43..2da186f3a451 100644 --- a/packages/hub/test/exports.test.ts +++ b/packages/hub/test/exports.test.ts @@ -1,5 +1,7 @@ -import { getCurrentHub, getHubFromCarrier, Scope } from '../src'; import { + getCurrentHub, + getHubFromCarrier, + Scope, captureEvent, captureException, captureMessage, @@ -11,7 +13,7 @@ import { setTags, setUser, withScope, -} from '../src/exports'; +} from '../src'; export class TestClient { public static instance?: TestClient; diff --git a/packages/hub/test/session.test.ts b/packages/hub/test/session.test.ts index f57267fd11c0..12d8ea713e20 100644 --- a/packages/hub/test/session.test.ts +++ b/packages/hub/test/session.test.ts @@ -1,7 +1,7 @@ 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..5c26d37502f1 100644 --- a/packages/hub/test/sessionflusher.test.ts +++ b/packages/hub/test/sessionflusher.test.ts @@ -1,6 +1,6 @@ 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 3a34a9eecce4..ee1fadee268f 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.13.0", - "@sentry/hub": "7.13.0", "@sentry/integrations": "7.13.0", "@sentry/node": "7.13.0", "@sentry/react": "7.13.0", diff --git a/packages/nextjs/src/index.server.ts b/packages/nextjs/src/index.server.ts index 49e868154a74..25e1300472d1 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 4a9b3908ae8c..8bff648c0cb3 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 8df5cb90e6e4..d3eb9d8b531d 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -17,7 +17,6 @@ }, "dependencies": { "@sentry/core": "7.13.0", - "@sentry/hub": "7.13.0", "@sentry/types": "7.13.0", "@sentry/utils": "7.13.0", "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..e72612f590a1 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 { initAndBind, SDK_VERSION, getMainCarrier } 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 442430dc79ba..a4d45c4e39d4 100644 --- a/packages/remix/package.json +++ b/packages/remix/package.json @@ -22,7 +22,6 @@ "dependencies": { "@sentry/cli": "2.2.0", "@sentry/core": "7.13.0", - "@sentry/hub": "7.13.0", "@sentry/integrations": "7.13.0", "@sentry/node": "7.13.0", "@sentry/react": "7.13.0", 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 6a2515d3cff3..1bb026fe3497 100644 --- a/packages/tracing/package.json +++ b/packages/tracing/package.json @@ -16,8 +16,8 @@ "access": "public" }, "dependencies": { - "@sentry/hub": "7.13.0", "@sentry/types": "7.13.0", + "@sentry/core": "7.13.0", "@sentry/utils": "7.13.0", "tslib": "^1.9.3" }, diff --git a/packages/tracing/src/browser/browsertracing.ts b/packages/tracing/src/browser/browsertracing.ts index 8a06f029d53f..07dec0cd585f 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 dbb9254054e9..e5a7fddbae9c 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 b12ba4b34601..c93978dc7b70 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 90ebbf889777..7c041b25a578 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 1f16c7a69e41..29b4368cb007 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 963c14206e9e..2b78b64592bc 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 2fc24fa1d670..ca89ae11eece 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 956de96b5ea5..7d4b38aa3667 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 6b69754edf1d..efefd46b883f 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 49db69479097..50f12e013b2e 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 501101dbce6f..b0908f1a2350 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';