From f14e393cafb5d7ce7a508c70ce2741551171df18 Mon Sep 17 00:00:00 2001 From: s1gr1d Date: Fri, 23 Feb 2024 14:29:58 +0100 Subject: [PATCH 01/11] merge integrations into core --- .github/workflows/build.yml | 1 + packages/core/package.json | 21 ++++++----- packages/core/rollup.bundle.config.mjs | 36 +++++++++++++++++++ packages/core/rollup.npm.config.mjs | 2 +- packages/core/src/index.ts | 6 ++++ .../src/integrations}/captureconsole.ts | 4 ++- .../src => core/src/integrations}/debug.ts | 2 +- .../src => core/src/integrations}/dedupe.ts | 4 +-- .../src/integrations}/extraerrordata.ts | 4 +-- .../src/integrations}/rewriteframes.ts | 2 +- .../src/integrations}/sessiontiming.ts | 2 +- .../lib/integrations}/captureconsole.test.ts | 19 ++++------ .../test/lib/integrations}/debug.test.ts | 2 +- .../test/lib/integrations}/dedupe.test.ts | 2 +- .../lib/integrations}/extraerrordata.test.ts | 2 +- .../lib/integrations}/rewriteframes.test.ts | 2 +- .../lib/integrations}/sessiontiming.test.ts | 2 +- packages/core/tsconfig.types.json | 2 +- 18 files changed, 79 insertions(+), 36 deletions(-) create mode 100644 packages/core/rollup.bundle.config.mjs rename packages/{integrations/src => core/src/integrations}/captureconsole.ts (91%) rename packages/{integrations/src => core/src/integrations}/debug.ts (96%) rename packages/{integrations/src => core/src/integrations}/dedupe.ts (98%) rename packages/{integrations/src => core/src/integrations}/extraerrordata.ts (97%) rename packages/{integrations/src => core/src/integrations}/rewriteframes.ts (98%) rename packages/{integrations/src => core/src/integrations}/sessiontiming.ts (93%) rename packages/{integrations/test => core/test/lib/integrations}/captureconsole.test.ts (95%) rename packages/{integrations/test => core/test/lib/integrations}/debug.test.ts (97%) rename packages/{integrations/test => core/test/lib/integrations}/dedupe.test.ts (98%) rename packages/{integrations/test => core/test/lib/integrations}/extraerrordata.test.ts (98%) rename packages/{integrations/test => core/test/lib/integrations}/rewriteframes.test.ts (99%) rename packages/{integrations/test => core/test/lib/integrations}/sessiontiming.test.ts (87%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f852c9f465b3..7c18422f25eb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -424,6 +424,7 @@ jobs: name: ${{ github.sha }} path: | ${{ github.workspace }}/packages/browser/build/bundles/** + ${{ github.workspace }}/packages/core/build/bundles/** ${{ github.workspace }}/packages/integrations/build/bundles/** ${{ github.workspace }}/packages/replay/build/bundles/** ${{ github.workspace }}/packages/replay-canvas/build/bundles/** diff --git a/packages/core/package.json b/packages/core/package.json index 3bd1182f7931..c89c17f27315 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -15,13 +15,13 @@ "types", "types-ts3.8" ], - "main": "build/cjs/index.js", - "module": "build/esm/index.js", - "types": "build/types/index.d.ts", + "main": "build/npm/cjs/index.js", + "module": "build/npm/esm/index.js", + "types": "build/npm/types/index.d.ts", "typesVersions": { "<4.9": { - "build/types/index.d.ts": [ - "build/types-ts3.8/index.d.ts" + "build/npm/types/index.d.ts": [ + "build/npm/types-ts3.8/index.d.ts" ] } }, @@ -33,17 +33,20 @@ "@sentry/utils": "7.100.0" }, "scripts": { - "build": "run-p build:transpile build:types", + "build": "run-p build:transpile build:types build:bundle", + "build:bundle": "run-p build:bundle:es5 build:bundle:es6", + "build:bundle:es5": "JS_VERSION=es5 rollup -c rollup.bundle.config.mjs", + "build:bundle:es6": "JS_VERSION=es6 rollup -c rollup.bundle.config.mjs", "build:dev": "yarn build", "build:transpile": "rollup -c rollup.npm.config.mjs", "build:types": "run-s build:types:core build:types:downlevel", "build:types:core": "tsc -p tsconfig.types.json", - "build:types:downlevel": "yarn downlevel-dts build/types build/types-ts3.8 --to ts3.8", + "build:types:downlevel": "yarn downlevel-dts build/npm/types build/npm/types-ts3.8 --to ts3.8", "build:watch": "run-p build:transpile:watch build:types:watch", "build:dev:watch": "yarn build:watch", "build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch", "build:types:watch": "tsc -p tsconfig.types.json --watch", - "build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build", + "build:tarball": "ts-node ../../scripts/prepack.ts --bundles && npm pack ./build/npm", "circularDepCheck": "madge --circular src/index.ts", "clean": "rimraf build coverage sentry-core-*.tgz", "fix": "eslint . --format stylish --fix", @@ -51,7 +54,7 @@ "test": "jest", "test:watch": "jest --watch", "version": "node ../../scripts/versionbump.js src/version.ts", - "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push --sig" + "yalc:publish": "ts-node ../../scripts/prepack.ts --bundles && yalc publish build/npm --push --sig" }, "volta": { "extends": "../../package.json" diff --git a/packages/core/rollup.bundle.config.mjs b/packages/core/rollup.bundle.config.mjs new file mode 100644 index 000000000000..477cea70bfd5 --- /dev/null +++ b/packages/core/rollup.bundle.config.mjs @@ -0,0 +1,36 @@ +import { makeBaseBundleConfig, makeBundleConfigVariants } from '@sentry-internal/rollup-utils'; + +const builds = []; + +const targets = process.env.JS_VERSION ? [process.env.JS_VERSION] : ['es5', 'es6']; + +if (targets.some(target => target !== 'es5' && target !== 'es6')) { + throw new Error('JS_VERSION must be either "es5" or "es6"'); +} + +const addonIntegrationFiles = [ + 'captureconsole.ts', + 'debug.ts', + 'dedupe.ts', + 'extraerrordata.ts', + 'rewriteframes.ts', + 'sessiontiming.ts', +]; + +targets.forEach(jsVersion => { + addonIntegrationFiles.forEach(integrationFile => { + const integrationName = integrationFile.split('.')[0]; + + const integrationsBundleConfig = makeBaseBundleConfig({ + bundleType: 'addon', + entrypoints: [`src/integrations/${integrationFile}`], + jsVersion, + licenseTitle: `@sentry/browser - ${integrationName}`, + outputFileBase: () => `bundles/${integrationName}${jsVersion === 'es5' ? '.es5' : ''}`, + }); + + builds.push(...makeBundleConfigVariants(integrationsBundleConfig)); + }); +}); + +export default builds; diff --git a/packages/core/rollup.npm.config.mjs b/packages/core/rollup.npm.config.mjs index 84a06f2fb64a..f13f345d2b98 100644 --- a/packages/core/rollup.npm.config.mjs +++ b/packages/core/rollup.npm.config.mjs @@ -1,3 +1,3 @@ import { makeBaseNPMConfig, makeNPMConfigVariants } from '@sentry-internal/rollup-utils'; -export default makeNPMConfigVariants(makeBaseNPMConfig()); +export default makeNPMConfigVariants(makeBaseNPMConfig({ hasBundles: true })); diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 198f25bcb74b..b5bee258dae6 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -108,6 +108,12 @@ export { inboundFiltersIntegration } from './integrations/inboundfilters'; export { linkedErrorsIntegration } from './integrations/linkederrors'; export { moduleMetadataIntegration } from './integrations/metadata'; export { requestDataIntegration } from './integrations/requestdata'; +export { captureConsoleIntegration } from './integrations/captureconsole'; +export { debugIntegration } from './integrations/debug'; +export { dedupeIntegration } from './integrations/dedupe'; +export { extraErrorDataIntegration } from './integrations/extraerrordata'; +export { rewriteFramesIntegration } from './integrations/rewriteframes'; +export { sessionTimingIntegration } from './integrations/sessiontiming'; export { metrics } from './metrics/exports'; export type { MetricData } from './metrics/exports'; export { metricsDefault } from './metrics/exports-default'; diff --git a/packages/integrations/src/captureconsole.ts b/packages/core/src/integrations/captureconsole.ts similarity index 91% rename from packages/integrations/src/captureconsole.ts rename to packages/core/src/integrations/captureconsole.ts index dd4bb34ac5c1..8e6dfc646419 100644 --- a/packages/integrations/src/captureconsole.ts +++ b/packages/core/src/integrations/captureconsole.ts @@ -1,4 +1,3 @@ -import { captureException, captureMessage, defineIntegration, getClient, withScope } from '@sentry/core'; import type { CaptureContext, IntegrationFn } from '@sentry/types'; import { CONSOLE_LEVELS, @@ -8,6 +7,9 @@ import { safeJoin, severityLevelFromString, } from '@sentry/utils'; +import { getClient, withScope } from '../currentScopes'; +import { captureException, captureMessage } from '../exports'; +import { defineIntegration } from '../integration'; interface CaptureConsoleOptions { levels?: string[]; diff --git a/packages/integrations/src/debug.ts b/packages/core/src/integrations/debug.ts similarity index 96% rename from packages/integrations/src/debug.ts rename to packages/core/src/integrations/debug.ts index 559041b40d36..83ac43de97b9 100644 --- a/packages/integrations/src/debug.ts +++ b/packages/core/src/integrations/debug.ts @@ -1,6 +1,6 @@ -import { defineIntegration } from '@sentry/core'; import type { Event, EventHint, IntegrationFn } from '@sentry/types'; import { consoleSandbox } from '@sentry/utils'; +import { defineIntegration } from '../integration'; const INTEGRATION_NAME = 'Debug'; diff --git a/packages/integrations/src/dedupe.ts b/packages/core/src/integrations/dedupe.ts similarity index 98% rename from packages/integrations/src/dedupe.ts rename to packages/core/src/integrations/dedupe.ts index 5aeafd42e97e..13d92fe3d56b 100644 --- a/packages/integrations/src/dedupe.ts +++ b/packages/core/src/integrations/dedupe.ts @@ -1,8 +1,8 @@ -import { defineIntegration } from '@sentry/core'; import type { Event, Exception, IntegrationFn, StackFrame } from '@sentry/types'; import { logger } from '@sentry/utils'; +import { defineIntegration } from '../integration'; -import { DEBUG_BUILD } from './debug-build'; +import { DEBUG_BUILD } from '../debug-build'; const INTEGRATION_NAME = 'Dedupe'; diff --git a/packages/integrations/src/extraerrordata.ts b/packages/core/src/integrations/extraerrordata.ts similarity index 97% rename from packages/integrations/src/extraerrordata.ts rename to packages/core/src/integrations/extraerrordata.ts index fc0c9c05fe58..4218dd1ff8e4 100644 --- a/packages/integrations/src/extraerrordata.ts +++ b/packages/core/src/integrations/extraerrordata.ts @@ -1,8 +1,8 @@ -import { defineIntegration } from '@sentry/core'; import type { Contexts, Event, EventHint, ExtendedError, IntegrationFn } from '@sentry/types'; import { addNonEnumerableProperty, isError, isPlainObject, logger, normalize } from '@sentry/utils'; +import { defineIntegration } from '../integration'; -import { DEBUG_BUILD } from './debug-build'; +import { DEBUG_BUILD } from '../debug-build'; const INTEGRATION_NAME = 'ExtraErrorData'; diff --git a/packages/integrations/src/rewriteframes.ts b/packages/core/src/integrations/rewriteframes.ts similarity index 98% rename from packages/integrations/src/rewriteframes.ts rename to packages/core/src/integrations/rewriteframes.ts index d32252ef15d8..ee842e86942f 100644 --- a/packages/integrations/src/rewriteframes.ts +++ b/packages/core/src/integrations/rewriteframes.ts @@ -1,6 +1,6 @@ -import { defineIntegration } from '@sentry/core'; import type { Event, IntegrationFn, StackFrame, Stacktrace } from '@sentry/types'; import { basename, relative } from '@sentry/utils'; +import { defineIntegration } from '../integration'; type StackFrameIteratee = (frame: StackFrame) => StackFrame; diff --git a/packages/integrations/src/sessiontiming.ts b/packages/core/src/integrations/sessiontiming.ts similarity index 93% rename from packages/integrations/src/sessiontiming.ts rename to packages/core/src/integrations/sessiontiming.ts index 41af19bed15c..6f01e5d48541 100644 --- a/packages/integrations/src/sessiontiming.ts +++ b/packages/core/src/integrations/sessiontiming.ts @@ -1,5 +1,5 @@ -import { defineIntegration } from '@sentry/core'; import type { IntegrationFn } from '@sentry/types'; +import { defineIntegration } from '../integration'; const INTEGRATION_NAME = 'SessionTiming'; diff --git a/packages/integrations/test/captureconsole.test.ts b/packages/core/test/lib/integrations/captureconsole.test.ts similarity index 95% rename from packages/integrations/test/captureconsole.test.ts rename to packages/core/test/lib/integrations/captureconsole.test.ts index 896c4b590181..ba4f3c9799b0 100644 --- a/packages/integrations/test/captureconsole.test.ts +++ b/packages/core/test/lib/integrations/captureconsole.test.ts @@ -1,16 +1,11 @@ /* eslint-disable @typescript-eslint/unbound-method */ -import * as SentryCore from '@sentry/core'; import type { Client, ConsoleLevel, Event } from '@sentry/types'; -import { - CONSOLE_LEVELS, - GLOBAL_OBJ, - addConsoleInstrumentationHandler, - originalConsoleMethods, - resetInstrumentationHandlers, -} from '@sentry/utils'; +import { CONSOLE_LEVELS, GLOBAL_OBJ, originalConsoleMethods, resetInstrumentationHandlers } from '@sentry/utils'; +import * as CurrentScopes from '../../../src/currentscopes'; +import * as SentryCore from '../../../src/exports'; -import { captureConsoleIntegration } from '../src/captureconsole'; +import { captureConsoleIntegration } from '../../../src/integrations/captureconsole'; const mockConsole: { [key in ConsoleLevel]: jest.Mock } = { debug: jest.fn(), @@ -24,7 +19,7 @@ const mockConsole: { [key in ConsoleLevel]: jest.Mock } = { describe('CaptureConsole setup', () => { // Ensure we've initialized the instrumentation so we can get the original one - addConsoleInstrumentationHandler(() => {}); + // addConsoleInstrumentationHandler(() => {}); const _originalConsoleMethods = Object.assign({}, originalConsoleMethods); let mockClient: Client; @@ -45,8 +40,8 @@ describe('CaptureConsole setup', () => { jest.spyOn(SentryCore, 'captureMessage').mockImplementation(captureMessage); jest.spyOn(SentryCore, 'captureException').mockImplementation(captureException); - jest.spyOn(SentryCore, 'getClient').mockImplementation(() => mockClient); - jest.spyOn(SentryCore, 'withScope').mockImplementation(withScope); + jest.spyOn(CurrentScopes, 'getClient').mockImplementation(() => mockClient); + jest.spyOn(CurrentScopes, 'withScope').mockImplementation(withScope); CONSOLE_LEVELS.forEach(key => { originalConsoleMethods[key] = mockConsole[key]; diff --git a/packages/integrations/test/debug.test.ts b/packages/core/test/lib/integrations/debug.test.ts similarity index 97% rename from packages/integrations/test/debug.test.ts rename to packages/core/test/lib/integrations/debug.test.ts index 5d0f90ba2074..49ed0d2d341a 100644 --- a/packages/integrations/test/debug.test.ts +++ b/packages/core/test/lib/integrations/debug.test.ts @@ -1,6 +1,6 @@ import type { Client, Event, EventHint } from '@sentry/types'; -import { debugIntegration } from '../src/debug'; +import { debugIntegration } from '../../../src/integrations/debug'; function testEventLogged( integration: ReturnType, diff --git a/packages/integrations/test/dedupe.test.ts b/packages/core/test/lib/integrations/dedupe.test.ts similarity index 98% rename from packages/integrations/test/dedupe.test.ts rename to packages/core/test/lib/integrations/dedupe.test.ts index e3b3e4bc8a48..540b07c53b79 100644 --- a/packages/integrations/test/dedupe.test.ts +++ b/packages/core/test/lib/integrations/dedupe.test.ts @@ -1,6 +1,6 @@ import type { Event as SentryEvent, Exception, StackFrame, Stacktrace } from '@sentry/types'; -import { _shouldDropEvent, dedupeIntegration } from '../src/dedupe'; +import { _shouldDropEvent, dedupeIntegration } from '../../../src/integrations/dedupe'; type EventWithException = SentryEvent & { exception: { diff --git a/packages/integrations/test/extraerrordata.test.ts b/packages/core/test/lib/integrations/extraerrordata.test.ts similarity index 98% rename from packages/integrations/test/extraerrordata.test.ts rename to packages/core/test/lib/integrations/extraerrordata.test.ts index 0a7bf19dd47d..c5ffd68c1405 100644 --- a/packages/integrations/test/extraerrordata.test.ts +++ b/packages/core/test/lib/integrations/extraerrordata.test.ts @@ -1,6 +1,6 @@ import type { Event as SentryEvent, ExtendedError } from '@sentry/types'; -import { extraErrorDataIntegration } from '../src/extraerrordata'; +import { extraErrorDataIntegration } from '../../../src/integrations/extraerrordata'; const extraErrorData = extraErrorDataIntegration(); let event: SentryEvent; diff --git a/packages/integrations/test/rewriteframes.test.ts b/packages/core/test/lib/integrations/rewriteframes.test.ts similarity index 99% rename from packages/integrations/test/rewriteframes.test.ts rename to packages/core/test/lib/integrations/rewriteframes.test.ts index d13e88318b77..17d6ed4b9c5b 100644 --- a/packages/integrations/test/rewriteframes.test.ts +++ b/packages/core/test/lib/integrations/rewriteframes.test.ts @@ -1,6 +1,6 @@ import type { Event, StackFrame } from '@sentry/types'; -import { rewriteFramesIntegration } from '../src/rewriteframes'; +import { rewriteFramesIntegration } from '../../../src/integrations/rewriteframes'; let rewriteFrames: ReturnType; let exceptionEvent: Event; diff --git a/packages/integrations/test/sessiontiming.test.ts b/packages/core/test/lib/integrations/sessiontiming.test.ts similarity index 87% rename from packages/integrations/test/sessiontiming.test.ts rename to packages/core/test/lib/integrations/sessiontiming.test.ts index 339531ff48fa..6213d7cae9c1 100644 --- a/packages/integrations/test/sessiontiming.test.ts +++ b/packages/core/test/lib/integrations/sessiontiming.test.ts @@ -1,5 +1,5 @@ import type { Event } from '@sentry/types'; -import { sessionTimingIntegration } from '../src/sessiontiming'; +import { sessionTimingIntegration } from '../../../src/integrations/sessiontiming'; const sessionTiming = sessionTimingIntegration(); diff --git a/packages/core/tsconfig.types.json b/packages/core/tsconfig.types.json index 65455f66bd75..374fd9bc9364 100644 --- a/packages/core/tsconfig.types.json +++ b/packages/core/tsconfig.types.json @@ -5,6 +5,6 @@ "declaration": true, "declarationMap": true, "emitDeclarationOnly": true, - "outDir": "build/types" + "outDir": "build/npm/types" } } From ec635da327bd466daddcd330f838610743b83211 Mon Sep 17 00:00:00 2001 From: s1gr1d Date: Mon, 26 Feb 2024 09:22:30 +0100 Subject: [PATCH 02/11] revert bundle changes in core --- .github/workflows/build.yml | 1 - packages/core/package.json | 21 +++++++-------- packages/core/rollup.bundle.config.mjs | 36 -------------------------- packages/core/rollup.npm.config.mjs | 2 +- packages/core/tsconfig.types.json | 2 +- 5 files changed, 11 insertions(+), 51 deletions(-) delete mode 100644 packages/core/rollup.bundle.config.mjs diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7c18422f25eb..f852c9f465b3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -424,7 +424,6 @@ jobs: name: ${{ github.sha }} path: | ${{ github.workspace }}/packages/browser/build/bundles/** - ${{ github.workspace }}/packages/core/build/bundles/** ${{ github.workspace }}/packages/integrations/build/bundles/** ${{ github.workspace }}/packages/replay/build/bundles/** ${{ github.workspace }}/packages/replay-canvas/build/bundles/** diff --git a/packages/core/package.json b/packages/core/package.json index c89c17f27315..3bd1182f7931 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -15,13 +15,13 @@ "types", "types-ts3.8" ], - "main": "build/npm/cjs/index.js", - "module": "build/npm/esm/index.js", - "types": "build/npm/types/index.d.ts", + "main": "build/cjs/index.js", + "module": "build/esm/index.js", + "types": "build/types/index.d.ts", "typesVersions": { "<4.9": { - "build/npm/types/index.d.ts": [ - "build/npm/types-ts3.8/index.d.ts" + "build/types/index.d.ts": [ + "build/types-ts3.8/index.d.ts" ] } }, @@ -33,20 +33,17 @@ "@sentry/utils": "7.100.0" }, "scripts": { - "build": "run-p build:transpile build:types build:bundle", - "build:bundle": "run-p build:bundle:es5 build:bundle:es6", - "build:bundle:es5": "JS_VERSION=es5 rollup -c rollup.bundle.config.mjs", - "build:bundle:es6": "JS_VERSION=es6 rollup -c rollup.bundle.config.mjs", + "build": "run-p build:transpile build:types", "build:dev": "yarn build", "build:transpile": "rollup -c rollup.npm.config.mjs", "build:types": "run-s build:types:core build:types:downlevel", "build:types:core": "tsc -p tsconfig.types.json", - "build:types:downlevel": "yarn downlevel-dts build/npm/types build/npm/types-ts3.8 --to ts3.8", + "build:types:downlevel": "yarn downlevel-dts build/types build/types-ts3.8 --to ts3.8", "build:watch": "run-p build:transpile:watch build:types:watch", "build:dev:watch": "yarn build:watch", "build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch", "build:types:watch": "tsc -p tsconfig.types.json --watch", - "build:tarball": "ts-node ../../scripts/prepack.ts --bundles && npm pack ./build/npm", + "build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build", "circularDepCheck": "madge --circular src/index.ts", "clean": "rimraf build coverage sentry-core-*.tgz", "fix": "eslint . --format stylish --fix", @@ -54,7 +51,7 @@ "test": "jest", "test:watch": "jest --watch", "version": "node ../../scripts/versionbump.js src/version.ts", - "yalc:publish": "ts-node ../../scripts/prepack.ts --bundles && yalc publish build/npm --push --sig" + "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push --sig" }, "volta": { "extends": "../../package.json" diff --git a/packages/core/rollup.bundle.config.mjs b/packages/core/rollup.bundle.config.mjs deleted file mode 100644 index 477cea70bfd5..000000000000 --- a/packages/core/rollup.bundle.config.mjs +++ /dev/null @@ -1,36 +0,0 @@ -import { makeBaseBundleConfig, makeBundleConfigVariants } from '@sentry-internal/rollup-utils'; - -const builds = []; - -const targets = process.env.JS_VERSION ? [process.env.JS_VERSION] : ['es5', 'es6']; - -if (targets.some(target => target !== 'es5' && target !== 'es6')) { - throw new Error('JS_VERSION must be either "es5" or "es6"'); -} - -const addonIntegrationFiles = [ - 'captureconsole.ts', - 'debug.ts', - 'dedupe.ts', - 'extraerrordata.ts', - 'rewriteframes.ts', - 'sessiontiming.ts', -]; - -targets.forEach(jsVersion => { - addonIntegrationFiles.forEach(integrationFile => { - const integrationName = integrationFile.split('.')[0]; - - const integrationsBundleConfig = makeBaseBundleConfig({ - bundleType: 'addon', - entrypoints: [`src/integrations/${integrationFile}`], - jsVersion, - licenseTitle: `@sentry/browser - ${integrationName}`, - outputFileBase: () => `bundles/${integrationName}${jsVersion === 'es5' ? '.es5' : ''}`, - }); - - builds.push(...makeBundleConfigVariants(integrationsBundleConfig)); - }); -}); - -export default builds; diff --git a/packages/core/rollup.npm.config.mjs b/packages/core/rollup.npm.config.mjs index f13f345d2b98..84a06f2fb64a 100644 --- a/packages/core/rollup.npm.config.mjs +++ b/packages/core/rollup.npm.config.mjs @@ -1,3 +1,3 @@ import { makeBaseNPMConfig, makeNPMConfigVariants } from '@sentry-internal/rollup-utils'; -export default makeNPMConfigVariants(makeBaseNPMConfig({ hasBundles: true })); +export default makeNPMConfigVariants(makeBaseNPMConfig()); diff --git a/packages/core/tsconfig.types.json b/packages/core/tsconfig.types.json index 374fd9bc9364..65455f66bd75 100644 --- a/packages/core/tsconfig.types.json +++ b/packages/core/tsconfig.types.json @@ -5,6 +5,6 @@ "declaration": true, "declarationMap": true, "emitDeclarationOnly": true, - "outDir": "build/npm/types" + "outDir": "build/types" } } From b5e7ed1e4795ce745bd8b927257d55d5923f28b1 Mon Sep 17 00:00:00 2001 From: s1gr1d Date: Mon, 26 Feb 2024 10:34:45 +0100 Subject: [PATCH 03/11] export browser integrations from core --- packages/browser/rollup.bundle.config.mjs | 28 +++ packages/browser/src/exports.ts | 3 +- packages/browser/src/index.bundle.base.ts | 4 +- packages/browser/src/index.ts | 13 ++ .../index.captureconsole.ts | 1 + .../src/integrations-bundle/index.debug.ts | 1 + .../src/integrations-bundle/index.dedupe.ts | 1 + .../index.extraerrordata.ts | 1 + .../index.rewriteframes.ts | 1 + .../index.sessiontiming.ts | 1 + .../src/integrations}/contextlines.ts | 0 packages/browser/src/integrations/dedupe.ts | 194 ------------------ .../src/integrations}/httpclient.ts | 2 +- packages/browser/src/integrations/index.ts | 1 - .../src/integrations}/reportingobserver.ts | 0 packages/browser/src/sdk.ts | 2 +- .../browser/test/unit/index.bundle.test.ts | 2 +- .../unit/integrations}/contextlines.test.ts | 2 +- .../integrations}/reportingobserver.test.ts | 2 +- 19 files changed, 56 insertions(+), 203 deletions(-) create mode 100644 packages/browser/src/integrations-bundle/index.captureconsole.ts create mode 100644 packages/browser/src/integrations-bundle/index.debug.ts create mode 100644 packages/browser/src/integrations-bundle/index.dedupe.ts create mode 100644 packages/browser/src/integrations-bundle/index.extraerrordata.ts create mode 100644 packages/browser/src/integrations-bundle/index.rewriteframes.ts create mode 100644 packages/browser/src/integrations-bundle/index.sessiontiming.ts rename packages/{integrations/src => browser/src/integrations}/contextlines.ts (100%) delete mode 100644 packages/browser/src/integrations/dedupe.ts rename packages/{integrations/src => browser/src/integrations}/httpclient.ts (99%) rename packages/{integrations/src => browser/src/integrations}/reportingobserver.ts (100%) rename packages/{integrations/test => browser/test/unit/integrations}/contextlines.test.ts (97%) rename packages/{integrations/test => browser/test/unit/integrations}/reportingobserver.test.ts (99%) diff --git a/packages/browser/rollup.bundle.config.mjs b/packages/browser/rollup.bundle.config.mjs index 66b1c5bb5992..7fafe48aacbd 100644 --- a/packages/browser/rollup.bundle.config.mjs +++ b/packages/browser/rollup.bundle.config.mjs @@ -8,6 +8,10 @@ if (targets.some(target => target !== 'es5' && target !== 'es6')) { throw new Error('JS_VERSION must be either "es5" or "es6"'); } +const addonIntegrationFiles = ['contextlines', 'httpclient', 'reportingobserver']; + +const coreIntegrationFiles = ['captureconsole', 'debug', 'dedupe', 'extraerrordata', 'rewriteframes', 'sessiontiming']; + targets.forEach(jsVersion => { const baseBundleConfig = makeBaseBundleConfig({ bundleType: 'standalone', @@ -25,6 +29,30 @@ targets.forEach(jsVersion => { outputFileBase: () => `bundles/bundle.tracing${jsVersion === 'es5' ? '.es5' : ''}`, }); + addonIntegrationFiles.forEach(integrationName => { + const integrationsBundleConfig = makeBaseBundleConfig({ + bundleType: 'addon', + entrypoints: [`src/integrations/${integrationName}.ts`], + jsVersion, + licenseTitle: `@sentry/browser - ${integrationName}`, + outputFileBase: () => `bundles/${integrationName}${jsVersion === 'es5' ? '.es5' : ''}`, + }); + + builds.push(...makeBundleConfigVariants(integrationsBundleConfig)); + }); + + coreIntegrationFiles.forEach(integrationName => { + const integrationsBundleConfig = makeBaseBundleConfig({ + bundleType: 'addon', + entrypoints: [`src/integrations-bundle/index.${integrationName}.ts`], + jsVersion, + licenseTitle: `@sentry/browser - ${integrationName}`, + outputFileBase: () => `bundles/${integrationName}${jsVersion === 'es5' ? '.es5' : ''}`, + }); + + builds.push(...makeBundleConfigVariants(integrationsBundleConfig)); + }); + builds.push(...makeBundleConfigVariants(baseBundleConfig), ...makeBundleConfigVariants(tracingBaseBundleConfig)); }); diff --git a/packages/browser/src/exports.ts b/packages/browser/src/exports.ts index 5e99eb33651b..04a9632b2f5d 100644 --- a/packages/browser/src/exports.ts +++ b/packages/browser/src/exports.ts @@ -108,11 +108,10 @@ export { } from './sdk'; export { breadcrumbsIntegration } from './integrations/breadcrumbs'; -export { dedupeIntegration } from './integrations/dedupe'; export { globalHandlersIntegration } from './integrations/globalhandlers'; export { httpContextIntegration } from './integrations/httpcontext'; export { linkedErrorsIntegration } from './integrations/linkederrors'; export { browserApiErrorsIntegration } from './integrations/browserapierrors'; // eslint-disable-next-line deprecation/deprecation -export { Breadcrumbs, LinkedErrors, HttpContext, Dedupe } from './integrations'; +export { Breadcrumbs, LinkedErrors, HttpContext } from './integrations'; diff --git a/packages/browser/src/index.bundle.base.ts b/packages/browser/src/index.bundle.base.ts index 304d1c4f16d1..20bea46dca8b 100644 --- a/packages/browser/src/index.bundle.base.ts +++ b/packages/browser/src/index.bundle.base.ts @@ -1,3 +1,5 @@ +import type { IntegrationFn } from '@sentry/types/src'; + export * from './exports'; import { Integrations as CoreIntegrations } from '@sentry/core'; @@ -14,7 +16,7 @@ if (WINDOW.Sentry && WINDOW.Sentry.Integrations) { } // eslint-disable-next-line @typescript-eslint/no-explicit-any -const INTEGRATIONS: Record Integration> = { +const INTEGRATIONS: Record Integration) | IntegrationFn> = { ...windowIntegrations, // eslint-disable-next-line deprecation/deprecation ...CoreIntegrations, diff --git a/packages/browser/src/index.ts b/packages/browser/src/index.ts index a7e8bc2d8b0c..d8473e69fcf1 100644 --- a/packages/browser/src/index.ts +++ b/packages/browser/src/index.ts @@ -23,6 +23,19 @@ const INTEGRATIONS = { // eslint-disable-next-line deprecation/deprecation export { INTEGRATIONS as Integrations }; +export { reportingObserverIntegration } from './integrations/reportingobserver'; +export { httpClientIntegration } from './integrations/httpclient'; +export { contextLinesIntegration } from './integrations/contextlines'; + +export { + captureConsoleIntegration, + debugIntegration, + dedupeIntegration, + extraErrorDataIntegration, + rewriteFramesIntegration, + sessionTimingIntegration, +} from '@sentry/core'; + export { // eslint-disable-next-line deprecation/deprecation Replay, diff --git a/packages/browser/src/integrations-bundle/index.captureconsole.ts b/packages/browser/src/integrations-bundle/index.captureconsole.ts new file mode 100644 index 000000000000..a2187ae98798 --- /dev/null +++ b/packages/browser/src/integrations-bundle/index.captureconsole.ts @@ -0,0 +1 @@ +export { captureConsoleIntegration } from '@sentry/core'; diff --git a/packages/browser/src/integrations-bundle/index.debug.ts b/packages/browser/src/integrations-bundle/index.debug.ts new file mode 100644 index 000000000000..39e8920e381f --- /dev/null +++ b/packages/browser/src/integrations-bundle/index.debug.ts @@ -0,0 +1 @@ +export { debugIntegration } from '@sentry/core'; diff --git a/packages/browser/src/integrations-bundle/index.dedupe.ts b/packages/browser/src/integrations-bundle/index.dedupe.ts new file mode 100644 index 000000000000..776d967c31a9 --- /dev/null +++ b/packages/browser/src/integrations-bundle/index.dedupe.ts @@ -0,0 +1 @@ +export { dedupeIntegration } from '@sentry/core'; diff --git a/packages/browser/src/integrations-bundle/index.extraerrordata.ts b/packages/browser/src/integrations-bundle/index.extraerrordata.ts new file mode 100644 index 000000000000..4306f9694902 --- /dev/null +++ b/packages/browser/src/integrations-bundle/index.extraerrordata.ts @@ -0,0 +1 @@ +export { extraErrorDataIntegration } from '@sentry/core'; diff --git a/packages/browser/src/integrations-bundle/index.rewriteframes.ts b/packages/browser/src/integrations-bundle/index.rewriteframes.ts new file mode 100644 index 000000000000..07ebaf6666f5 --- /dev/null +++ b/packages/browser/src/integrations-bundle/index.rewriteframes.ts @@ -0,0 +1 @@ +export { rewriteFramesIntegration } from '@sentry/core'; diff --git a/packages/browser/src/integrations-bundle/index.sessiontiming.ts b/packages/browser/src/integrations-bundle/index.sessiontiming.ts new file mode 100644 index 000000000000..ae495a70cc49 --- /dev/null +++ b/packages/browser/src/integrations-bundle/index.sessiontiming.ts @@ -0,0 +1 @@ +export { sessionTimingIntegration } from '@sentry/core'; diff --git a/packages/integrations/src/contextlines.ts b/packages/browser/src/integrations/contextlines.ts similarity index 100% rename from packages/integrations/src/contextlines.ts rename to packages/browser/src/integrations/contextlines.ts diff --git a/packages/browser/src/integrations/dedupe.ts b/packages/browser/src/integrations/dedupe.ts deleted file mode 100644 index 1e12b5c5a92c..000000000000 --- a/packages/browser/src/integrations/dedupe.ts +++ /dev/null @@ -1,194 +0,0 @@ -import { convertIntegrationFnToClass, defineIntegration } from '@sentry/core'; -import type { Event, Exception, Integration, IntegrationClass, IntegrationFn, StackFrame } from '@sentry/types'; -import { logger } from '@sentry/utils'; - -import { DEBUG_BUILD } from '../debug-build'; - -const INTEGRATION_NAME = 'Dedupe'; - -const _dedupeIntegration = (() => { - let previousEvent: Event | undefined; - - return { - name: INTEGRATION_NAME, - processEvent(currentEvent) { - // We want to ignore any non-error type events, e.g. transactions or replays - // These should never be deduped, and also not be compared against as _previousEvent. - if (currentEvent.type) { - return currentEvent; - } - - // Juuust in case something goes wrong - try { - if (_shouldDropEvent(currentEvent, previousEvent)) { - DEBUG_BUILD && logger.warn('Event dropped due to being a duplicate of previously captured event.'); - return null; - } - } catch (_oO) {} // eslint-disable-line no-empty - - return (previousEvent = currentEvent); - }, - }; -}) satisfies IntegrationFn; - -export const dedupeIntegration = defineIntegration(_dedupeIntegration); - -/** - * Deduplication filter. - * @deprecated Use `dedupeIntegration()` instead. - */ -// eslint-disable-next-line deprecation/deprecation -export const Dedupe = convertIntegrationFnToClass(INTEGRATION_NAME, dedupeIntegration) as IntegrationClass< - Integration & { processEvent: (event: Event) => Event } ->; - -function _shouldDropEvent(currentEvent: Event, previousEvent?: Event): boolean { - if (!previousEvent) { - return false; - } - - if (_isSameMessageEvent(currentEvent, previousEvent)) { - return true; - } - - if (_isSameExceptionEvent(currentEvent, previousEvent)) { - return true; - } - - return false; -} - -function _isSameMessageEvent(currentEvent: Event, previousEvent: Event): boolean { - const currentMessage = currentEvent.message; - const previousMessage = previousEvent.message; - - // If neither event has a message property, they were both exceptions, so bail out - if (!currentMessage && !previousMessage) { - return false; - } - - // If only one event has a stacktrace, but not the other one, they are not the same - if ((currentMessage && !previousMessage) || (!currentMessage && previousMessage)) { - return false; - } - - if (currentMessage !== previousMessage) { - return false; - } - - if (!_isSameFingerprint(currentEvent, previousEvent)) { - return false; - } - - if (!_isSameStacktrace(currentEvent, previousEvent)) { - return false; - } - - return true; -} - -function _isSameExceptionEvent(currentEvent: Event, previousEvent: Event): boolean { - const previousException = _getExceptionFromEvent(previousEvent); - const currentException = _getExceptionFromEvent(currentEvent); - - if (!previousException || !currentException) { - return false; - } - - if (previousException.type !== currentException.type || previousException.value !== currentException.value) { - return false; - } - - if (!_isSameFingerprint(currentEvent, previousEvent)) { - return false; - } - - if (!_isSameStacktrace(currentEvent, previousEvent)) { - return false; - } - - return true; -} - -function _isSameStacktrace(currentEvent: Event, previousEvent: Event): boolean { - let currentFrames = _getFramesFromEvent(currentEvent); - let previousFrames = _getFramesFromEvent(previousEvent); - - // If neither event has a stacktrace, they are assumed to be the same - if (!currentFrames && !previousFrames) { - return true; - } - - // If only one event has a stacktrace, but not the other one, they are not the same - if ((currentFrames && !previousFrames) || (!currentFrames && previousFrames)) { - return false; - } - - currentFrames = currentFrames as StackFrame[]; - previousFrames = previousFrames as StackFrame[]; - - // If number of frames differ, they are not the same - if (previousFrames.length !== currentFrames.length) { - return false; - } - - // Otherwise, compare the two - for (let i = 0; i < previousFrames.length; i++) { - const frameA = previousFrames[i]; - const frameB = currentFrames[i]; - - if ( - frameA.filename !== frameB.filename || - frameA.lineno !== frameB.lineno || - frameA.colno !== frameB.colno || - frameA.function !== frameB.function - ) { - return false; - } - } - - return true; -} - -function _isSameFingerprint(currentEvent: Event, previousEvent: Event): boolean { - let currentFingerprint = currentEvent.fingerprint; - let previousFingerprint = previousEvent.fingerprint; - - // If neither event has a fingerprint, they are assumed to be the same - if (!currentFingerprint && !previousFingerprint) { - return true; - } - - // If only one event has a fingerprint, but not the other one, they are not the same - if ((currentFingerprint && !previousFingerprint) || (!currentFingerprint && previousFingerprint)) { - return false; - } - - currentFingerprint = currentFingerprint as string[]; - previousFingerprint = previousFingerprint as string[]; - - // Otherwise, compare the two - try { - return !!(currentFingerprint.join('') === previousFingerprint.join('')); - } catch (_oO) { - return false; - } -} - -function _getExceptionFromEvent(event: Event): Exception | undefined { - return event.exception && event.exception.values && event.exception.values[0]; -} - -function _getFramesFromEvent(event: Event): StackFrame[] | undefined { - const exception = event.exception; - - if (exception) { - try { - // @ts-expect-error Object could be undefined - return exception.values[0].stacktrace.frames; - } catch (_oO) { - return undefined; - } - } - return undefined; -} diff --git a/packages/integrations/src/httpclient.ts b/packages/browser/src/integrations/httpclient.ts similarity index 99% rename from packages/integrations/src/httpclient.ts rename to packages/browser/src/integrations/httpclient.ts index 1c93a232104b..e8d5d596d975 100644 --- a/packages/integrations/src/httpclient.ts +++ b/packages/browser/src/integrations/httpclient.ts @@ -10,7 +10,7 @@ import { supportsNativeFetch, } from '@sentry/utils'; -import { DEBUG_BUILD } from './debug-build'; +import { DEBUG_BUILD } from '../debug-build'; export type HttpStatusCodeRange = [number, number] | number; export type HttpRequestTarget = string | RegExp; diff --git a/packages/browser/src/integrations/index.ts b/packages/browser/src/integrations/index.ts index a39db874045b..66aa1d8f11a5 100644 --- a/packages/browser/src/integrations/index.ts +++ b/packages/browser/src/integrations/index.ts @@ -2,4 +2,3 @@ export { Breadcrumbs } from './breadcrumbs'; export { LinkedErrors } from './linkederrors'; export { HttpContext } from './httpcontext'; -export { Dedupe } from './dedupe'; diff --git a/packages/integrations/src/reportingobserver.ts b/packages/browser/src/integrations/reportingobserver.ts similarity index 100% rename from packages/integrations/src/reportingobserver.ts rename to packages/browser/src/integrations/reportingobserver.ts diff --git a/packages/browser/src/sdk.ts b/packages/browser/src/sdk.ts index 3e89e43b3da1..254276af335c 100644 --- a/packages/browser/src/sdk.ts +++ b/packages/browser/src/sdk.ts @@ -16,13 +16,13 @@ import { supportsFetch, } from '@sentry/utils'; +import { dedupeIntegration } from '@sentry/core'; import type { BrowserClientOptions, BrowserOptions } from './client'; import { BrowserClient } from './client'; import { DEBUG_BUILD } from './debug-build'; import { WINDOW, wrap as internalWrap } from './helpers'; import { breadcrumbsIntegration } from './integrations/breadcrumbs'; import { browserApiErrorsIntegration } from './integrations/browserapierrors'; -import { dedupeIntegration } from './integrations/dedupe'; import { globalHandlersIntegration } from './integrations/globalhandlers'; import { httpContextIntegration } from './integrations/httpcontext'; import { linkedErrorsIntegration } from './integrations/linkederrors'; diff --git a/packages/browser/test/unit/index.bundle.test.ts b/packages/browser/test/unit/index.bundle.test.ts index bf498477c73c..a081c21a1e59 100644 --- a/packages/browser/test/unit/index.bundle.test.ts +++ b/packages/browser/test/unit/index.bundle.test.ts @@ -11,7 +11,7 @@ import * as TracingBundle from '../../src/index.bundle'; describe('index.bundle', () => { it('has correct exports', () => { Object.keys(TracingBundle.Integrations).forEach(key => { - expect((TracingBundle.Integrations[key] as any).id).toStrictEqual(expect.any(String)); + expect((TracingBundle.Integrations[key] as any).name).toStrictEqual(expect.any(String)); }); expect(TracingBundle.Integrations.Replay).toBe(ReplayShim); diff --git a/packages/integrations/test/contextlines.test.ts b/packages/browser/test/unit/integrations/contextlines.test.ts similarity index 97% rename from packages/integrations/test/contextlines.test.ts rename to packages/browser/test/unit/integrations/contextlines.test.ts index 00365d7ab910..5f19bd2b41a7 100644 --- a/packages/integrations/test/contextlines.test.ts +++ b/packages/browser/test/unit/integrations/contextlines.test.ts @@ -1,6 +1,6 @@ import type { StackFrame } from '@sentry/types'; -import { applySourceContextToFrame } from '../src/contextlines'; +import { applySourceContextToFrame } from '../../../src/integrations/contextlines'; const lines = ['line1', 'line2', 'line3', 'line4', 'line5', 'line6', 'line7', 'line8', 'line9']; describe('ContextLines', () => { diff --git a/packages/integrations/test/reportingobserver.test.ts b/packages/browser/test/unit/integrations/reportingobserver.test.ts similarity index 99% rename from packages/integrations/test/reportingobserver.test.ts rename to packages/browser/test/unit/integrations/reportingobserver.test.ts index a8766e7cd58c..aba669286f44 100644 --- a/packages/integrations/test/reportingobserver.test.ts +++ b/packages/browser/test/unit/integrations/reportingobserver.test.ts @@ -1,7 +1,7 @@ import * as SentryCore from '@sentry/core'; import type { Client } from '@sentry/types'; -import { reportingObserverIntegration } from '../src/reportingobserver'; +import { reportingObserverIntegration } from '../../../src/integrations/reportingobserver'; const mockScope = { setExtra: jest.fn(), From 4d1923a5c07acae1b1e008cbe211d645ea4567fe Mon Sep 17 00:00:00 2001 From: s1gr1d Date: Mon, 26 Feb 2024 10:35:46 +0100 Subject: [PATCH 04/11] delete integrations package --- packages/integrations/.eslintrc.js | 11 ---- packages/integrations/LICENSE | 14 ---- packages/integrations/README.md | 26 -------- packages/integrations/jest.config.js | 1 - packages/integrations/package.json | 66 ------------------- .../integrations/rollup.bundle.config.mjs | 19 ------ packages/integrations/rollup.npm.config.mjs | 8 --- packages/integrations/scripts/buildBundles.ts | 63 ------------------ packages/integrations/src/debug-build.ts | 8 --- packages/integrations/src/index.ts | 9 --- packages/integrations/tsconfig.json | 10 --- packages/integrations/tsconfig.test.json | 12 ---- packages/integrations/tsconfig.types.json | 10 --- 13 files changed, 257 deletions(-) delete mode 100644 packages/integrations/.eslintrc.js delete mode 100644 packages/integrations/LICENSE delete mode 100644 packages/integrations/README.md delete mode 100644 packages/integrations/jest.config.js delete mode 100644 packages/integrations/package.json delete mode 100644 packages/integrations/rollup.bundle.config.mjs delete mode 100644 packages/integrations/rollup.npm.config.mjs delete mode 100644 packages/integrations/scripts/buildBundles.ts delete mode 100644 packages/integrations/src/debug-build.ts delete mode 100644 packages/integrations/src/index.ts delete mode 100644 packages/integrations/tsconfig.json delete mode 100644 packages/integrations/tsconfig.test.json delete mode 100644 packages/integrations/tsconfig.types.json diff --git a/packages/integrations/.eslintrc.js b/packages/integrations/.eslintrc.js deleted file mode 100644 index 46741a6b1a82..000000000000 --- a/packages/integrations/.eslintrc.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = { - extends: ['../../.eslintrc.js'], - overrides: [ - { - files: ['scripts/**/*.ts'], - parserOptions: { - project: ['../../tsconfig.dev.json'], - }, - }, - ], -}; diff --git a/packages/integrations/LICENSE b/packages/integrations/LICENSE deleted file mode 100644 index 535ef0561e1b..000000000000 --- a/packages/integrations/LICENSE +++ /dev/null @@ -1,14 +0,0 @@ -Copyright (c) 2019 Sentry (https://sentry.io) and individual contributors. All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit -persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the -Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/packages/integrations/README.md b/packages/integrations/README.md deleted file mode 100644 index 9f94611ce045..000000000000 --- a/packages/integrations/README.md +++ /dev/null @@ -1,26 +0,0 @@ -

- - Sentry - -

- -# Sentry JavaScript SDK Integrations - -[![npm version](https://img.shields.io/npm/v/@sentry/integrations.svg)](https://www.npmjs.com/package/@sentry/integrations) -[![npm dm](https://img.shields.io/npm/dm/@sentry/integrations.svg)](https://www.npmjs.com/package/@sentry/integrations) -[![npm dt](https://img.shields.io/npm/dt/@sentry/integrations.svg)](https://www.npmjs.com/package/@sentry/integrations) - -## Links - -- [Official SDK Docs](https://docs.sentry.io/quickstart/) -- [TypeDoc](http://getsentry.github.io/sentry-javascript/) - -## General - -Pluggable integrations that can be used to enhance JS SDKs. - -All of the integrations can also be found on our CDN e.g.: - -Angular integration: `https://browser.sentry-cdn.com/5.0.0/angular.min.js` - -Please make sure to always to match the version of the integration with the version of the JS SDK you are loading. diff --git a/packages/integrations/jest.config.js b/packages/integrations/jest.config.js deleted file mode 100644 index 24f49ab59a4c..000000000000 --- a/packages/integrations/jest.config.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('../../jest/jest.config.js'); diff --git a/packages/integrations/package.json b/packages/integrations/package.json deleted file mode 100644 index 46f3485228cd..000000000000 --- a/packages/integrations/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@sentry/integrations", - "version": "7.100.0", - "description": "Pluggable integrations that can be used to enhance JS SDKs", - "repository": "git://github.com/getsentry/sentry-javascript.git", - "homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/integrations", - "author": "Sentry", - "license": "MIT", - "engines": { - "node": ">=14" - }, - "publishConfig": { - "access": "public" - }, - "files": [ - "cjs", - "esm", - "types", - "types-ts3.8" - ], - "main": "build/npm/cjs/index.js", - "module": "build/npm/esm/index.js", - "types": "build/npm/types/index.d.ts", - "typesVersions": { - "<4.9": { - "build/npm/types/index.d.ts": [ - "build/npm/types-ts3.8/index.d.ts" - ] - } - }, - "dependencies": { - "@sentry/core": "7.100.0", - "@sentry/types": "7.100.0", - "@sentry/utils": "7.100.0" - }, - "devDependencies": { - "@sentry/browser": "7.100.0", - "chai": "^4.1.2" - }, - "scripts": { - "build": "run-p build:transpile build:types build:bundle", - "build:bundle": "ts-node scripts/buildBundles.ts --parallel", - "build:dev": "run-p build:transpile build:types", - "build:transpile": "rollup -c rollup.npm.config.mjs", - "build:types": "run-s build:types:core build:types:downlevel", - "build:types:core": "tsc -p tsconfig.types.json", - "build:types:downlevel": "yarn downlevel-dts build/npm/types build/npm/types-ts3.8 --to ts3.8", - "build:watch": "run-p build:transpile:watch build:types:watch", - "build:dev:watch": "yarn build:watch", - "build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch", - "build:types:watch": "tsc -p tsconfig.types.json --watch", - "build:tarball": "ts-node ../../scripts/prepack.ts --bundles && npm pack ./build/npm", - "circularDepCheck": "madge --circular src/index.ts", - "clean": "rimraf build coverage .rpt2_cache sentry-integrations-*.tgz", - "fix": "eslint . --format stylish --fix", - "lint": "eslint . --format stylish", - "validate:es5": "es-check es5 'build/bundles/*.es5*.js'", - "test": "jest", - "test:watch": "jest --watch", - "yalc:publish": "ts-node ../../scripts/prepack.ts --bundles && yalc publish ./build/npm --push --sig" - }, - "volta": { - "extends": "../../package.json" - }, - "sideEffects": false -} diff --git a/packages/integrations/rollup.bundle.config.mjs b/packages/integrations/rollup.bundle.config.mjs deleted file mode 100644 index 4ad9d857b496..000000000000 --- a/packages/integrations/rollup.bundle.config.mjs +++ /dev/null @@ -1,19 +0,0 @@ -import { makeBaseBundleConfig, makeBundleConfigVariants } from '@sentry-internal/rollup-utils'; - -const builds = []; - -const file = process.env.INTEGRATION_FILE; -const jsVersion = process.env.JS_VERSION; - -const baseBundleConfig = makeBaseBundleConfig({ - bundleType: 'addon', - entrypoints: [`src/${file}`], - jsVersion, - licenseTitle: '@sentry/integrations', - outputFileBase: ({ name: entrypoint }) => `bundles/${entrypoint}${jsVersion === 'es5' ? '.es5' : ''}`, -}); - -// this makes non-minified, minified, and minified-with-debug-logging versions of each bundle -builds.push(...makeBundleConfigVariants(baseBundleConfig)); - -export default builds; diff --git a/packages/integrations/rollup.npm.config.mjs b/packages/integrations/rollup.npm.config.mjs deleted file mode 100644 index 6d09adefc859..000000000000 --- a/packages/integrations/rollup.npm.config.mjs +++ /dev/null @@ -1,8 +0,0 @@ -import { makeBaseNPMConfig, makeNPMConfigVariants } from '@sentry-internal/rollup-utils'; - -export default makeNPMConfigVariants( - makeBaseNPMConfig({ - // packages with bundles have a different build directory structure - hasBundles: true, - }), -); diff --git a/packages/integrations/scripts/buildBundles.ts b/packages/integrations/scripts/buildBundles.ts deleted file mode 100644 index 97730f10afe2..000000000000 --- a/packages/integrations/scripts/buildBundles.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { spawn } from 'child_process'; -import { readdirSync } from 'fs'; -import { join } from 'path'; - -const runParallel = process.argv.includes('--parallel'); - -/** Gets a list of src filenames, one for each integration and excludes the index.ts */ -function getIntegrations(): string[] { - const srcDir = join(__dirname, '..', 'src'); - const srcFiles = readdirSync(srcDir); - // The index file is only there for the purposes of npm builds - // (for the CDN we create a separate bundle for each integration) - return srcFiles.filter(file => file !== 'index.ts'); -} - -/** Builds a bundle for a specific integration and JavaScript ES version */ -async function buildBundle(integration: string, jsVersion: string): Promise { - return new Promise((resolve, reject) => { - const child = spawn('yarn', ['--silent', 'rollup', '--config', 'rollup.bundle.config.mjs'], { - shell: true, // required to run on Windows - env: { ...process.env, INTEGRATION_FILE: integration, JS_VERSION: jsVersion }, - }); - - child.on('exit', exitcode => { - if (exitcode !== 0) { - reject(new Error(`Failed to build bundle for integration "${integration}" with exit code: ${exitcode}`)); - } else { - resolve(); - } - }); - }); -} - -if (runParallel) { - // We're building a bundle for each integration and each JavaScript version. - const tasks = getIntegrations().reduce( - (tasks, integration) => { - tasks.push(buildBundle(integration, 'es5'), buildBundle(integration, 'es6')); - return tasks; - }, - [] as Promise[], - ); - - Promise.all(tasks) - // eslint-disable-next-line no-console - .then(_ => console.log('\nIntegration bundles built successfully')) - .catch(error => { - // eslint-disable-next-line no-console - console.error(error); - // Important to exit with a non-zero exit code, so that the build fails. - process.exit(1); - }); -} else { - // eslint-disable-next-line @typescript-eslint/no-floating-promises - (async () => { - for (const integration of getIntegrations()) { - await buildBundle(integration, 'es5'); - await buildBundle(integration, 'es6'); - } - // eslint-disable-next-line no-console - console.log('\nIntegration bundles built successfully'); - })(); -} diff --git a/packages/integrations/src/debug-build.ts b/packages/integrations/src/debug-build.ts deleted file mode 100644 index 60aa50940582..000000000000 --- a/packages/integrations/src/debug-build.ts +++ /dev/null @@ -1,8 +0,0 @@ -declare const __DEBUG_BUILD__: boolean; - -/** - * This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code. - * - * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking. - */ -export const DEBUG_BUILD = __DEBUG_BUILD__; diff --git a/packages/integrations/src/index.ts b/packages/integrations/src/index.ts deleted file mode 100644 index a2c1fb48920f..000000000000 --- a/packages/integrations/src/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -export { captureConsoleIntegration } from './captureconsole'; -export { debugIntegration } from './debug'; -export { dedupeIntegration } from './dedupe'; -export { extraErrorDataIntegration } from './extraerrordata'; -export { reportingObserverIntegration } from './reportingobserver'; -export { rewriteFramesIntegration } from './rewriteframes'; -export { sessionTimingIntegration } from './sessiontiming'; -export { httpClientIntegration } from './httpclient'; -export { contextLinesIntegration } from './contextlines'; diff --git a/packages/integrations/tsconfig.json b/packages/integrations/tsconfig.json deleted file mode 100644 index e5ec1017893d..000000000000 --- a/packages/integrations/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../../tsconfig.json", - - "include": ["src/**/*"], - - "compilerOptions": { - // package-specific options - "esModuleInterop": true, - } -} diff --git a/packages/integrations/tsconfig.test.json b/packages/integrations/tsconfig.test.json deleted file mode 100644 index 87f6afa06b86..000000000000 --- a/packages/integrations/tsconfig.test.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "./tsconfig.json", - - "include": ["test/**/*"], - - "compilerOptions": { - // should include all types from `./tsconfig.json` plus types for all test frameworks used - "types": ["node", "jest"] - - // other package-specific, test-specific options - } -} diff --git a/packages/integrations/tsconfig.types.json b/packages/integrations/tsconfig.types.json deleted file mode 100644 index 374fd9bc9364..000000000000 --- a/packages/integrations/tsconfig.types.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "./tsconfig.json", - - "compilerOptions": { - "declaration": true, - "declarationMap": true, - "emitDeclarationOnly": true, - "outDir": "build/npm/types" - } -} From 94af4579d09da8f922b9e955e89ff83b067eb412 Mon Sep 17 00:00:00 2001 From: s1gr1d Date: Mon, 26 Feb 2024 13:33:57 +0100 Subject: [PATCH 05/11] delete sentry/integration deps --- .craft.yml | 3 --- .github/workflows/build.yml | 2 -- MIGRATION.md | 17 +++++++++++++++++ README.md | 2 -- .../suites/integrations/ContextLines/init.js | 3 +-- .../integrations/httpclient/fetch/init.js | 3 +-- .../httpclient/httpClientIntegration/init.js | 3 +-- .../suites/integrations/httpclient/init.js | 3 +-- .../utils/generatePlugin.ts | 1 - .../test-applications/generic-ts3.8/index.ts | 2 -- .../generic-ts3.8/package.json | 1 - .../node-express-app/package.json | 1 - .../node-express-app/src/app.ts | 2 -- .../node-hapi-app/package.json | 1 - .../e2e-tests/verdaccio-config/config.yaml | 6 ------ dev-packages/rollup-utils/bundleHelpers.mjs | 2 +- package.json | 1 - packages/astro/src/index.types.ts | 1 + packages/core/src/integrations/requestdata.ts | 2 +- .../lib/integrations/captureconsole.test.ts | 10 ++++++++-- packages/nextjs/package.json | 1 - .../client/clientNormalizationIntegration.ts | 2 +- .../src/edge/distDirRewriteFramesIntegration.ts | 3 +-- .../nextjs/src/edge/rewriteFramesIntegration.ts | 3 +-- packages/nextjs/src/index.types.ts | 1 + .../server/distDirRewriteFramesIntegration.ts | 3 +-- .../src/server/rewriteFramesIntegration.ts | 3 +-- packages/nextjs/test/integration/package.json | 1 - packages/node-experimental/src/index.ts | 6 ++++++ packages/node/src/integrations/index.ts | 9 +++++++++ packages/remix/src/index.types.ts | 1 + packages/remix/test/integration/package.json | 1 - packages/sveltekit/package.json | 1 - packages/sveltekit/src/index.types.ts | 1 + .../src/server/rewriteFramesIntegration.ts | 3 +-- .../test/server/rewriteFramesIntegration.ts | 2 +- 36 files changed, 57 insertions(+), 50 deletions(-) diff --git a/.craft.yml b/.craft.yml index 5ffdda2338ae..9259fc979356 100644 --- a/.craft.yml +++ b/.craft.yml @@ -70,9 +70,6 @@ targets: - name: npm id: '@sentry/wasm' includeNames: /^sentry-wasm-\d.*\.tgz$/ - - name: npm - id: '@sentry/integrations' - includeNames: /^sentry-integrations-\d.*\.tgz$/ ## 4. WinterCG Packages - name: npm diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f852c9f465b3..06131c73b84a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -101,7 +101,6 @@ jobs: - 'packages/tracing-internal/**' - 'packages/utils/**' - 'packages/types/**' - - 'packages/integrations/**' browser: &browser - *shared - 'packages/browser/**' @@ -424,7 +423,6 @@ jobs: name: ${{ github.sha }} path: | ${{ github.workspace }}/packages/browser/build/bundles/** - ${{ github.workspace }}/packages/integrations/build/bundles/** ${{ github.workspace }}/packages/replay/build/bundles/** ${{ github.workspace }}/packages/replay-canvas/build/bundles/** ${{ github.workspace }}/packages/**/*.tgz diff --git a/MIGRATION.md b/MIGRATION.md index a2a9803071e7..c6f49dd725b7 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -112,6 +112,23 @@ Sentry SDK requires the fetch API to be available in the environment. [`error.cause`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause) by default. +## Integrations + +We moved optional integrations from their own package (`@sentry/integrations`) to `@sentry/browser` and `@sentry/node`. + +Integrations that are now exported from `@sentry/browser` : +- httpClientIntegration +- contextLinesIntegration +- reportingObserverIntegration + +Integrations that are now exported from `@sentry/node` and `@sentry/browser` (or framework-specific packages like `@sentry/react`): +- captureConsoleIntegration +- debugIntegration +- dedupeIntegration +- extraErrorDataIntegration +- rewriteFramesIntegration +- sessionTimingIntegration + # Deprecations in 7.x You can use the **Experimental** [@sentry/migr8](https://www.npmjs.com/package/@sentry/migr8) to automatically update diff --git a/README.md b/README.md index 80790d36c4a2..807c4b6988e2 100644 --- a/README.md +++ b/README.md @@ -57,8 +57,6 @@ package. Please refer to the README and instructions of those SDKs for more deta - [`@sentry/gatsby`](https://github.com/getsentry/sentry-javascript/tree/master/packages/gatsby): SDK for Gatsby - [`@sentry/nextjs`](https://github.com/getsentry/sentry-javascript/tree/master/packages/nextjs): SDK for Next.js - [`@sentry/remix`](https://github.com/getsentry/sentry-javascript/tree/master/packages/remix): SDK for Remix -- [`@sentry/integrations`](https://github.com/getsentry/sentry-javascript/tree/master/packages/integrations): Pluggable - integrations that can be used to enhance JS SDKs - [`@sentry/serverless`](https://github.com/getsentry/sentry-javascript/tree/master/packages/serverless): SDK for Serverless Platforms (AWS, GCP) - [`@sentry/electron`](https://github.com/getsentry/sentry-electron): SDK for Electron with support for native crashes diff --git a/dev-packages/browser-integration-tests/suites/integrations/ContextLines/init.js b/dev-packages/browser-integration-tests/suites/integrations/ContextLines/init.js index b5b85dd2a8e9..f7b0c4556e21 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/ContextLines/init.js +++ b/dev-packages/browser-integration-tests/suites/integrations/ContextLines/init.js @@ -1,9 +1,8 @@ import * as Sentry from '@sentry/browser'; -import { contextLinesIntegration } from '@sentry/integrations'; window.Sentry = Sentry; Sentry.init({ dsn: 'https://public@dsn.ingest.sentry.io/1337', - integrations: [contextLinesIntegration()], + integrations: [Sentry.contextLinesIntegration()], }); diff --git a/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/init.js b/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/init.js index 07bc4a5b351e..ce06dc30c734 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/init.js +++ b/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/init.js @@ -1,11 +1,10 @@ import * as Sentry from '@sentry/browser'; -import { httpClientIntegration } from '@sentry/integrations'; window.Sentry = Sentry; Sentry.init({ dsn: 'https://public@dsn.ingest.sentry.io/1337', - integrations: [httpClientIntegration()], + integrations: [Sentry.httpClientIntegration()], tracesSampleRate: 1, sendDefaultPii: true, }); diff --git a/dev-packages/browser-integration-tests/suites/integrations/httpclient/httpClientIntegration/init.js b/dev-packages/browser-integration-tests/suites/integrations/httpclient/httpClientIntegration/init.js index 07bc4a5b351e..ce06dc30c734 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/httpclient/httpClientIntegration/init.js +++ b/dev-packages/browser-integration-tests/suites/integrations/httpclient/httpClientIntegration/init.js @@ -1,11 +1,10 @@ import * as Sentry from '@sentry/browser'; -import { httpClientIntegration } from '@sentry/integrations'; window.Sentry = Sentry; Sentry.init({ dsn: 'https://public@dsn.ingest.sentry.io/1337', - integrations: [httpClientIntegration()], + integrations: [Sentry.httpClientIntegration()], tracesSampleRate: 1, sendDefaultPii: true, }); diff --git a/dev-packages/browser-integration-tests/suites/integrations/httpclient/init.js b/dev-packages/browser-integration-tests/suites/integrations/httpclient/init.js index 07bc4a5b351e..ce06dc30c734 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/httpclient/init.js +++ b/dev-packages/browser-integration-tests/suites/integrations/httpclient/init.js @@ -1,11 +1,10 @@ import * as Sentry from '@sentry/browser'; -import { httpClientIntegration } from '@sentry/integrations'; window.Sentry = Sentry; Sentry.init({ dsn: 'https://public@dsn.ingest.sentry.io/1337', - integrations: [httpClientIntegration()], + integrations: [Sentry.httpClientIntegration()], tracesSampleRate: 1, sendDefaultPii: true, }); diff --git a/dev-packages/browser-integration-tests/utils/generatePlugin.ts b/dev-packages/browser-integration-tests/utils/generatePlugin.ts index 0ef9a73a91d2..740409554134 100644 --- a/dev-packages/browser-integration-tests/utils/generatePlugin.ts +++ b/dev-packages/browser-integration-tests/utils/generatePlugin.ts @@ -169,7 +169,6 @@ class SentryScenarioGenerationPlugin { // To help Webpack resolve Sentry modules in `import` statements in cases where they're provided in bundles rather than in `node_modules` '@sentry/browser': 'Sentry', '@sentry/replay': 'Sentry', - '@sentry/integrations': 'Sentry', '@sentry/wasm': 'Sentry', } : {}; diff --git a/dev-packages/e2e-tests/test-applications/generic-ts3.8/index.ts b/dev-packages/e2e-tests/test-applications/generic-ts3.8/index.ts index 34a7ba15fe24..48776e59e268 100644 --- a/dev-packages/e2e-tests/test-applications/generic-ts3.8/index.ts +++ b/dev-packages/e2e-tests/test-applications/generic-ts3.8/index.ts @@ -3,8 +3,6 @@ import * as _SentryBrowser from '@sentry/browser'; // biome-ignore lint/nursery/noUnusedImports: import * as _SentryCore from '@sentry/core'; // biome-ignore lint/nursery/noUnusedImports: -import * as _SentryIntegrations from '@sentry/integrations'; -// biome-ignore lint/nursery/noUnusedImports: import * as _SentryNode from '@sentry/node'; // biome-ignore lint/nursery/noUnusedImports: import * as _SentryOpentelemetry from '@sentry/opentelemetry-node'; diff --git a/dev-packages/e2e-tests/test-applications/generic-ts3.8/package.json b/dev-packages/e2e-tests/test-applications/generic-ts3.8/package.json index 82be8f36bd5f..8e409a936199 100644 --- a/dev-packages/e2e-tests/test-applications/generic-ts3.8/package.json +++ b/dev-packages/e2e-tests/test-applications/generic-ts3.8/package.json @@ -15,7 +15,6 @@ "dependencies": { "@sentry/browser": "latest || *", "@sentry/core": "latest || *", - "@sentry/integrations": "latest || *", "@sentry/node": "latest || *", "@sentry/opentelemetry-node": "latest || *", "@sentry/replay": "latest || *", diff --git a/dev-packages/e2e-tests/test-applications/node-express-app/package.json b/dev-packages/e2e-tests/test-applications/node-express-app/package.json index 2c721361b212..2ccd7ab35f76 100644 --- a/dev-packages/e2e-tests/test-applications/node-express-app/package.json +++ b/dev-packages/e2e-tests/test-applications/node-express-app/package.json @@ -11,7 +11,6 @@ "test:assert": "pnpm test" }, "dependencies": { - "@sentry/integrations": "latest || *", "@sentry/node": "latest || *", "@sentry/types": "latest || *", "express": "4.18.2", diff --git a/dev-packages/e2e-tests/test-applications/node-express-app/src/app.ts b/dev-packages/e2e-tests/test-applications/node-express-app/src/app.ts index c6cabed89382..a4d6ccc6c983 100644 --- a/dev-packages/e2e-tests/test-applications/node-express-app/src/app.ts +++ b/dev-packages/e2e-tests/test-applications/node-express-app/src/app.ts @@ -1,4 +1,3 @@ -import { httpClientIntegration } from '@sentry/integrations'; import * as Sentry from '@sentry/node'; import express from 'express'; @@ -12,7 +11,6 @@ Sentry.init({ environment: 'qa', // dynamic sampling bias to keep transactions dsn: process.env.E2E_TEST_DSN, includeLocalVariables: true, - integrations: [httpClientIntegration()], debug: true, tunnel: `http://localhost:3031/`, // proxy server tracesSampleRate: 1, diff --git a/dev-packages/e2e-tests/test-applications/node-hapi-app/package.json b/dev-packages/e2e-tests/test-applications/node-hapi-app/package.json index 1aba49ac4d3e..e463d02a73e6 100644 --- a/dev-packages/e2e-tests/test-applications/node-hapi-app/package.json +++ b/dev-packages/e2e-tests/test-applications/node-hapi-app/package.json @@ -12,7 +12,6 @@ }, "dependencies": { "@hapi/hapi": "21.3.2", - "@sentry/integrations": "latest || *", "@sentry/node": "latest || *", "@sentry/types": "latest || *", "@types/node": "18.15.1", diff --git a/dev-packages/e2e-tests/verdaccio-config/config.yaml b/dev-packages/e2e-tests/verdaccio-config/config.yaml index 2ff38d3f63d1..042f93162934 100644 --- a/dev-packages/e2e-tests/verdaccio-config/config.yaml +++ b/dev-packages/e2e-tests/verdaccio-config/config.yaml @@ -86,12 +86,6 @@ packages: unpublish: $all # proxy: npmjs # Don't proxy for E2E tests! - '@sentry/integrations': - access: $all - publish: $all - unpublish: $all - # proxy: npmjs # Don't proxy for E2E tests! - '@sentry/nextjs': access: $all publish: $all diff --git a/dev-packages/rollup-utils/bundleHelpers.mjs b/dev-packages/rollup-utils/bundleHelpers.mjs index 2b77db6c7a9e..9e4466bb56cd 100644 --- a/dev-packages/rollup-utils/bundleHelpers.mjs +++ b/dev-packages/rollup-utils/bundleHelpers.mjs @@ -59,7 +59,7 @@ export function makeBaseBundleConfig(options) { plugins: [rrwebBuildPlugin, markAsBrowserBuildPlugin], }; - // used by `@sentry/integrations` and `@sentry/wasm` (bundles which need to be combined with a stand-alone SDK bundle) + // used by `@sentry/wasm` (bundles which need to be combined with a stand-alone SDK bundle) const addOnBundleConfig = { // These output settings are designed to mimic an IIFE. We don't use Rollup's `iife` format because we don't want to // attach this code to a new global variable, but rather inject it into the existing SDK's `Integrations` object. diff --git a/package.json b/package.json index f1cbdfd8c726..b44b18e87a7a 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,6 @@ "packages/eslint-plugin-sdk", "packages/feedback", "packages/gatsby", - "packages/integrations", "packages/integration-shims", "packages/nextjs", "packages/node", diff --git a/packages/astro/src/index.types.ts b/packages/astro/src/index.types.ts index 25317086ac56..11ea06bae7c1 100644 --- a/packages/astro/src/index.types.ts +++ b/packages/astro/src/index.types.ts @@ -18,6 +18,7 @@ export declare function init(options: Options | clientSdk.BrowserOptions | serve export declare const Integrations: typeof serverSdk.Integrations; export declare const linkedErrorsIntegration: typeof clientSdk.linkedErrorsIntegration; +export declare const contextLinesIntegration: typeof clientSdk.contextLinesIntegration; export declare const getDefaultIntegrations: (options: Options) => Integration[]; export declare const defaultStackParser: StackParser; diff --git a/packages/core/src/integrations/requestdata.ts b/packages/core/src/integrations/requestdata.ts index 002673cdc13f..bd893f2099a6 100644 --- a/packages/core/src/integrations/requestdata.ts +++ b/packages/core/src/integrations/requestdata.ts @@ -130,7 +130,7 @@ const _requestDataIntegration = ((options: RequestDataIntegrationOptions = {}) = export const requestDataIntegration = defineIntegration(_requestDataIntegration); /** - * Add data about a request to an event. Primarily for use in Node-based SDKs, but included in `@sentry/integrations` + * Add data about a request to an event. Primarily for use in Node-based SDKs, but included in `@sentry/core` * so it can be used in cross-platform SDKs like `@sentry/nextjs`. * @deprecated Use `requestDataIntegration()` instead. */ diff --git a/packages/core/test/lib/integrations/captureconsole.test.ts b/packages/core/test/lib/integrations/captureconsole.test.ts index ba4f3c9799b0..04b8e16d04cc 100644 --- a/packages/core/test/lib/integrations/captureconsole.test.ts +++ b/packages/core/test/lib/integrations/captureconsole.test.ts @@ -1,7 +1,13 @@ /* eslint-disable @typescript-eslint/unbound-method */ import type { Client, ConsoleLevel, Event } from '@sentry/types'; -import { CONSOLE_LEVELS, GLOBAL_OBJ, originalConsoleMethods, resetInstrumentationHandlers } from '@sentry/utils'; +import { + CONSOLE_LEVELS, + GLOBAL_OBJ, + addConsoleInstrumentationHandler, + originalConsoleMethods, + resetInstrumentationHandlers, +} from '@sentry/utils'; import * as CurrentScopes from '../../../src/currentscopes'; import * as SentryCore from '../../../src/exports'; @@ -19,7 +25,7 @@ const mockConsole: { [key in ConsoleLevel]: jest.Mock } = { describe('CaptureConsole setup', () => { // Ensure we've initialized the instrumentation so we can get the original one - // addConsoleInstrumentationHandler(() => {}); + addConsoleInstrumentationHandler(() => {}); const _originalConsoleMethods = Object.assign({}, originalConsoleMethods); let mockClient: Client; diff --git a/packages/nextjs/package.json b/packages/nextjs/package.json index e6767dbb95d3..ea7fd47dd014 100644 --- a/packages/nextjs/package.json +++ b/packages/nextjs/package.json @@ -26,7 +26,6 @@ "dependencies": { "@rollup/plugin-commonjs": "24.0.0", "@sentry/core": "7.100.0", - "@sentry/integrations": "7.100.0", "@sentry/node-experimental": "7.100.0", "@sentry/react": "7.100.0", "@sentry/types": "7.100.0", diff --git a/packages/nextjs/src/client/clientNormalizationIntegration.ts b/packages/nextjs/src/client/clientNormalizationIntegration.ts index 5caf7d2a3b59..06f010c980c9 100644 --- a/packages/nextjs/src/client/clientNormalizationIntegration.ts +++ b/packages/nextjs/src/client/clientNormalizationIntegration.ts @@ -1,5 +1,5 @@ +import { rewriteFramesIntegration } from '@sentry/browser'; import { defineIntegration } from '@sentry/core'; -import { rewriteFramesIntegration } from '@sentry/integrations'; export const nextjsClientStackFrameNormalizationIntegration = defineIntegration( ({ assetPrefixPath }: { assetPrefixPath: string }) => { diff --git a/packages/nextjs/src/edge/distDirRewriteFramesIntegration.ts b/packages/nextjs/src/edge/distDirRewriteFramesIntegration.ts index 5e0555f193e3..d2e1b519c29b 100644 --- a/packages/nextjs/src/edge/distDirRewriteFramesIntegration.ts +++ b/packages/nextjs/src/edge/distDirRewriteFramesIntegration.ts @@ -1,5 +1,4 @@ -import { defineIntegration } from '@sentry/core'; -import { rewriteFramesIntegration } from '@sentry/integrations'; +import { defineIntegration, rewriteFramesIntegration } from '@sentry/core'; import { escapeStringForRegex } from '@sentry/utils'; export const distDirRewriteFramesIntegration = defineIntegration(({ distDirName }: { distDirName: string }) => { diff --git a/packages/nextjs/src/edge/rewriteFramesIntegration.ts b/packages/nextjs/src/edge/rewriteFramesIntegration.ts index effb99fc4e81..f19a3c79a4c5 100644 --- a/packages/nextjs/src/edge/rewriteFramesIntegration.ts +++ b/packages/nextjs/src/edge/rewriteFramesIntegration.ts @@ -1,5 +1,4 @@ -import { defineIntegration } from '@sentry/core'; -import { rewriteFramesIntegration as originalRewriteFramesIntegration } from '@sentry/integrations'; +import { defineIntegration, rewriteFramesIntegration as originalRewriteFramesIntegration } from '@sentry/core'; import type { IntegrationFn, StackFrame } from '@sentry/types'; import { GLOBAL_OBJ, escapeStringForRegex } from '@sentry/utils'; diff --git a/packages/nextjs/src/index.types.ts b/packages/nextjs/src/index.types.ts index 652f8ae7b5f6..976644d0992a 100644 --- a/packages/nextjs/src/index.types.ts +++ b/packages/nextjs/src/index.types.ts @@ -22,6 +22,7 @@ export declare function init( export declare const Integrations: undefined; // TODO(v8): Remove this line. Can only be done when dependencies don't export `Integrations` anymore. export declare const linkedErrorsIntegration: typeof clientSdk.linkedErrorsIntegration; +export declare const contextLinesIntegration: typeof clientSdk.contextLinesIntegration; export declare const getDefaultIntegrations: (options: Options) => Integration[]; export declare const defaultStackParser: StackParser; diff --git a/packages/nextjs/src/server/distDirRewriteFramesIntegration.ts b/packages/nextjs/src/server/distDirRewriteFramesIntegration.ts index 71cb5f2d766c..8ac80d91d61c 100644 --- a/packages/nextjs/src/server/distDirRewriteFramesIntegration.ts +++ b/packages/nextjs/src/server/distDirRewriteFramesIntegration.ts @@ -1,6 +1,5 @@ import * as path from 'path'; -import { defineIntegration } from '@sentry/core'; -import { rewriteFramesIntegration } from '@sentry/integrations'; +import { defineIntegration, rewriteFramesIntegration } from '@sentry/core'; import { escapeStringForRegex } from '@sentry/utils'; export const distDirRewriteFramesIntegration = defineIntegration(({ distDirName }: { distDirName: string }) => { diff --git a/packages/nextjs/src/server/rewriteFramesIntegration.ts b/packages/nextjs/src/server/rewriteFramesIntegration.ts index fe18c6a18be5..5b7c64d81b7a 100644 --- a/packages/nextjs/src/server/rewriteFramesIntegration.ts +++ b/packages/nextjs/src/server/rewriteFramesIntegration.ts @@ -1,6 +1,5 @@ import * as path from 'path'; -import { defineIntegration } from '@sentry/core'; -import { rewriteFramesIntegration as originalRewriteFramesIntegration } from '@sentry/integrations'; +import { defineIntegration, rewriteFramesIntegration as originalRewriteFramesIntegration } from '@sentry/core'; import type { IntegrationFn, StackFrame } from '@sentry/types'; import { escapeStringForRegex } from '@sentry/utils'; diff --git a/packages/nextjs/test/integration/package.json b/packages/nextjs/test/integration/package.json index d73c8fa688f9..c31a1594dc8d 100644 --- a/packages/nextjs/test/integration/package.json +++ b/packages/nextjs/test/integration/package.json @@ -27,7 +27,6 @@ "resolutions": { "@sentry/browser": "file:../../../browser", "@sentry/core": "file:../../../core", - "@sentry/integrations": "file:../../../integrations", "@sentry/node": "file:../../../node-experimental", "@sentry/node-experimental": "file:../../../node", "@sentry/react": "file:../../../react", diff --git a/packages/node-experimental/src/index.ts b/packages/node-experimental/src/index.ts index c1a55ce959f7..b8c12b6ba3f9 100644 --- a/packages/node-experimental/src/index.ts +++ b/packages/node-experimental/src/index.ts @@ -84,6 +84,12 @@ export { captureException, captureEvent, captureMessage, + captureConsoleIntegration, + debugIntegration, + dedupeIntegration, + extraErrorDataIntegration, + rewriteFramesIntegration, + sessionTimingIntegration, } from '@sentry/core'; export type { diff --git a/packages/node/src/integrations/index.ts b/packages/node/src/integrations/index.ts index 083df21bd68d..4fe23e230f7b 100644 --- a/packages/node/src/integrations/index.ts +++ b/packages/node/src/integrations/index.ts @@ -10,3 +10,12 @@ export { RequestData } from '@sentry/core'; export { Undici } from './undici'; export { Spotlight } from './spotlight'; export { Hapi } from './hapi'; + +export { + captureConsoleIntegration, + debugIntegration, + dedupeIntegration, + extraErrorDataIntegration, + rewriteFramesIntegration, + sessionTimingIntegration, +} from '@sentry/core'; diff --git a/packages/remix/src/index.types.ts b/packages/remix/src/index.types.ts index 0bf2620f6212..5835c05b2c71 100644 --- a/packages/remix/src/index.types.ts +++ b/packages/remix/src/index.types.ts @@ -17,6 +17,7 @@ export declare function init(options: RemixOptions): void; export declare const Integrations: typeof clientSdk.Integrations & typeof serverSdk.Integrations; export declare const linkedErrorsIntegration: typeof clientSdk.linkedErrorsIntegration; +export declare const contextLinesIntegration: typeof clientSdk.contextLinesIntegration; export declare const getDefaultIntegrations: (options: Options) => Integration[]; export declare const defaultStackParser: StackParser; diff --git a/packages/remix/test/integration/package.json b/packages/remix/test/integration/package.json index f112babe40f6..3c0d63b7961b 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/integrations": "file:../../../integrations", "@sentry/node": "file:../../../node-experimental", "@sentry/node-experimental": "file:../../../node", "@sentry/react": "file:../../../react", diff --git a/packages/sveltekit/package.json b/packages/sveltekit/package.json index 99f55c0e2ca4..c92bc40210c4 100644 --- a/packages/sveltekit/package.json +++ b/packages/sveltekit/package.json @@ -39,7 +39,6 @@ "dependencies": { "@sentry-internal/tracing": "7.100.0", "@sentry/core": "7.100.0", - "@sentry/integrations": "7.100.0", "@sentry/node-experimental": "7.100.0", "@sentry/svelte": "7.100.0", "@sentry/types": "7.100.0", diff --git a/packages/sveltekit/src/index.types.ts b/packages/sveltekit/src/index.types.ts index e05aa031e53e..42a34e430fd8 100644 --- a/packages/sveltekit/src/index.types.ts +++ b/packages/sveltekit/src/index.types.ts @@ -41,6 +41,7 @@ export declare function wrapLoadWithSentry any>(orig export declare const Integrations: typeof clientSdk.Integrations & typeof serverSdk.Integrations; export declare const linkedErrorsIntegration: typeof clientSdk.linkedErrorsIntegration; +export declare const contextLinesIntegration: typeof clientSdk.contextLinesIntegration; export declare const getDefaultIntegrations: (options: Options) => Integration[]; export declare const defaultStackParser: StackParser; diff --git a/packages/sveltekit/src/server/rewriteFramesIntegration.ts b/packages/sveltekit/src/server/rewriteFramesIntegration.ts index 9187630e96ec..da37457cc5b9 100644 --- a/packages/sveltekit/src/server/rewriteFramesIntegration.ts +++ b/packages/sveltekit/src/server/rewriteFramesIntegration.ts @@ -1,5 +1,4 @@ -import { defineIntegration } from '@sentry/core'; -import { rewriteFramesIntegration as originalRewriteFramesIntegration } from '@sentry/integrations'; +import { defineIntegration, rewriteFramesIntegration as originalRewriteFramesIntegration } from '@sentry/core'; import type { IntegrationFn, StackFrame } from '@sentry/types'; import { GLOBAL_OBJ, basename, escapeStringForRegex, join } from '@sentry/utils'; import { WRAPPED_MODULE_SUFFIX } from '../vite/autoInstrument'; diff --git a/packages/sveltekit/test/server/rewriteFramesIntegration.ts b/packages/sveltekit/test/server/rewriteFramesIntegration.ts index cb55fd62d1c7..acf4591d8371 100644 --- a/packages/sveltekit/test/server/rewriteFramesIntegration.ts +++ b/packages/sveltekit/test/server/rewriteFramesIntegration.ts @@ -1,4 +1,4 @@ -import { rewriteFramesIntegration } from '@sentry/integrations'; +import { rewriteFramesIntegration } from '@sentry/browser'; import type { Event, StackFrame } from '@sentry/types'; import { basename } from '@sentry/utils'; From 8c8b98ce60afbd2750b39000248b3ffd2d8328f6 Mon Sep 17 00:00:00 2001 From: s1gr1d Date: Mon, 26 Feb 2024 13:41:12 +0100 Subject: [PATCH 06/11] fix formatting --- MIGRATION.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/MIGRATION.md b/MIGRATION.md index c6f49dd725b7..1bae55164e85 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -117,12 +117,15 @@ Sentry SDK requires the fetch API to be available in the environment. We moved optional integrations from their own package (`@sentry/integrations`) to `@sentry/browser` and `@sentry/node`. Integrations that are now exported from `@sentry/browser` : + - httpClientIntegration - contextLinesIntegration - reportingObserverIntegration -Integrations that are now exported from `@sentry/node` and `@sentry/browser` (or framework-specific packages like `@sentry/react`): -- captureConsoleIntegration +Integrations that are now exported from `@sentry/node` and `@sentry/browser` (or framework-specific packages like +`@sentry/react`): + +- captureConsoleIntegration - debugIntegration - dedupeIntegration - extraErrorDataIntegration From d1236f65c5c247c82cef640ec1405629ee5fd1b2 Mon Sep 17 00:00:00 2001 From: s1gr1d Date: Mon, 26 Feb 2024 14:43:16 +0100 Subject: [PATCH 07/11] export integrations from node package --- packages/node/src/index.ts | 9 +++++++++ packages/node/src/integrations/index.ts | 9 --------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/node/src/index.ts b/packages/node/src/index.ts index ac17a5d0b5ed..bfe015a1d593 100644 --- a/packages/node/src/index.ts +++ b/packages/node/src/index.ts @@ -116,6 +116,15 @@ export const Integrations = { ...TracingIntegrations, }; +export { + captureConsoleIntegration, + debugIntegration, + dedupeIntegration, + extraErrorDataIntegration, + rewriteFramesIntegration, + sessionTimingIntegration, +} from '@sentry/core'; + export { consoleIntegration } from './integrations/console'; export { onUncaughtExceptionIntegration } from './integrations/onuncaughtexception'; export { onUnhandledRejectionIntegration } from './integrations/onunhandledrejection'; diff --git a/packages/node/src/integrations/index.ts b/packages/node/src/integrations/index.ts index 4fe23e230f7b..083df21bd68d 100644 --- a/packages/node/src/integrations/index.ts +++ b/packages/node/src/integrations/index.ts @@ -10,12 +10,3 @@ export { RequestData } from '@sentry/core'; export { Undici } from './undici'; export { Spotlight } from './spotlight'; export { Hapi } from './hapi'; - -export { - captureConsoleIntegration, - debugIntegration, - dedupeIntegration, - extraErrorDataIntegration, - rewriteFramesIntegration, - sessionTimingIntegration, -} from '@sentry/core'; From 487278dd8de97119d22d8bc91dab174e64f6f7f1 Mon Sep 17 00:00:00 2001 From: s1gr1d Date: Tue, 27 Feb 2024 10:15:38 +0100 Subject: [PATCH 08/11] fix test errors --- .../suites/integrations/ContextLines/init.js | 3 ++- .../suites/integrations/httpclient/fetch/init.js | 3 ++- .../httpclient/httpClientIntegration/init.js | 3 ++- .../suites/integrations/httpclient/init.js | 3 ++- .../utils/generatePlugin.ts | 13 ++++++++----- packages/bun/src/index.ts | 6 ++++++ .../test/lib/integrations/captureconsole.test.ts | 2 +- packages/deno/src/index.ts | 5 +++++ packages/serverless/src/index.ts | 9 +++++++++ 9 files changed, 37 insertions(+), 10 deletions(-) diff --git a/dev-packages/browser-integration-tests/suites/integrations/ContextLines/init.js b/dev-packages/browser-integration-tests/suites/integrations/ContextLines/init.js index f7b0c4556e21..cdcb68f2b48f 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/ContextLines/init.js +++ b/dev-packages/browser-integration-tests/suites/integrations/ContextLines/init.js @@ -1,8 +1,9 @@ import * as Sentry from '@sentry/browser'; +import { contextLinesIntegration } from '@sentry/browser'; window.Sentry = Sentry; Sentry.init({ dsn: 'https://public@dsn.ingest.sentry.io/1337', - integrations: [Sentry.contextLinesIntegration()], + integrations: [contextLinesIntegration()], }); diff --git a/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/init.js b/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/init.js index ce06dc30c734..8540ab176c38 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/init.js +++ b/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/init.js @@ -1,10 +1,11 @@ import * as Sentry from '@sentry/browser'; +import { httpClientIntegration } from '@sentry/browser'; window.Sentry = Sentry; Sentry.init({ dsn: 'https://public@dsn.ingest.sentry.io/1337', - integrations: [Sentry.httpClientIntegration()], + integrations: [httpClientIntegration()], tracesSampleRate: 1, sendDefaultPii: true, }); diff --git a/dev-packages/browser-integration-tests/suites/integrations/httpclient/httpClientIntegration/init.js b/dev-packages/browser-integration-tests/suites/integrations/httpclient/httpClientIntegration/init.js index ce06dc30c734..8540ab176c38 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/httpclient/httpClientIntegration/init.js +++ b/dev-packages/browser-integration-tests/suites/integrations/httpclient/httpClientIntegration/init.js @@ -1,10 +1,11 @@ import * as Sentry from '@sentry/browser'; +import { httpClientIntegration } from '@sentry/browser'; window.Sentry = Sentry; Sentry.init({ dsn: 'https://public@dsn.ingest.sentry.io/1337', - integrations: [Sentry.httpClientIntegration()], + integrations: [httpClientIntegration()], tracesSampleRate: 1, sendDefaultPii: true, }); diff --git a/dev-packages/browser-integration-tests/suites/integrations/httpclient/init.js b/dev-packages/browser-integration-tests/suites/integrations/httpclient/init.js index ce06dc30c734..8540ab176c38 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/httpclient/init.js +++ b/dev-packages/browser-integration-tests/suites/integrations/httpclient/init.js @@ -1,10 +1,11 @@ import * as Sentry from '@sentry/browser'; +import { httpClientIntegration } from '@sentry/browser'; window.Sentry = Sentry; Sentry.init({ dsn: 'https://public@dsn.ingest.sentry.io/1337', - integrations: [Sentry.httpClientIntegration()], + integrations: [httpClientIntegration()], tracesSampleRate: 1, sendDefaultPii: true, }); diff --git a/dev-packages/browser-integration-tests/utils/generatePlugin.ts b/dev-packages/browser-integration-tests/utils/generatePlugin.ts index 740409554134..63a1d9f51854 100644 --- a/dev-packages/browser-integration-tests/utils/generatePlugin.ts +++ b/dev-packages/browser-integration-tests/utils/generatePlugin.ts @@ -129,14 +129,17 @@ function generateSentryAlias(): Record { return Object.fromEntries( packageNames.map(packageName => { + // pluggable integrations exist in the browser package + const actPackageName = packageName === 'integrations' ? 'browser' : packageName; + const packageJSON: Package = JSON.parse( - fs.readFileSync(path.resolve(PACKAGES_DIR, packageName, 'package.json'), { encoding: 'utf-8' }).toString(), + fs.readFileSync(path.resolve(PACKAGES_DIR, actPackageName, 'package.json'), { encoding: 'utf-8' }).toString(), ); - const modulePath = path.resolve(PACKAGES_DIR, packageName); + const modulePath = path.resolve(PACKAGES_DIR, actPackageName); - if (useCompiledModule && bundleKey && BUNDLE_PATHS[packageName]?.[bundleKey]) { - const bundlePath = path.resolve(modulePath, BUNDLE_PATHS[packageName][bundleKey]); + if (useCompiledModule && bundleKey && BUNDLE_PATHS[actPackageName]?.[bundleKey]) { + const bundlePath = path.resolve(modulePath, BUNDLE_PATHS[actPackageName][bundleKey]); return [packageJSON['name'], bundlePath]; } @@ -241,7 +244,7 @@ class SentryScenarioGenerationPlugin { this.localOutPath, path.resolve( PACKAGES_DIR, - 'integrations', + 'browser', BUNDLE_PATHS['integrations'][integrationBundleKey].replace('[INTEGRATION_NAME]', integration), ), fileName, diff --git a/packages/bun/src/index.ts b/packages/bun/src/index.ts index 0f4f431401bc..fe00c1eef4b9 100644 --- a/packages/bun/src/index.ts +++ b/packages/bun/src/index.ts @@ -73,6 +73,12 @@ export { inboundFiltersIntegration, linkedErrorsIntegration, requestDataIntegration, + captureConsoleIntegration, + debugIntegration, + dedupeIntegration, + extraErrorDataIntegration, + rewriteFramesIntegration, + sessionTimingIntegration, parameterize, startSession, captureSession, diff --git a/packages/core/test/lib/integrations/captureconsole.test.ts b/packages/core/test/lib/integrations/captureconsole.test.ts index 04b8e16d04cc..6ed79d586c9c 100644 --- a/packages/core/test/lib/integrations/captureconsole.test.ts +++ b/packages/core/test/lib/integrations/captureconsole.test.ts @@ -8,7 +8,7 @@ import { originalConsoleMethods, resetInstrumentationHandlers, } from '@sentry/utils'; -import * as CurrentScopes from '../../../src/currentscopes'; +import * as CurrentScopes from '../../../src/currentScopes'; import * as SentryCore from '../../../src/exports'; import { captureConsoleIntegration } from '../../../src/integrations/captureconsole'; diff --git a/packages/deno/src/index.ts b/packages/deno/src/index.ts index 3aec144b58c6..f124763abd9a 100644 --- a/packages/deno/src/index.ts +++ b/packages/deno/src/index.ts @@ -71,6 +71,11 @@ export { linkedErrorsIntegration, functionToStringIntegration, requestDataIntegration, + captureConsoleIntegration, + debugIntegration, + extraErrorDataIntegration, + rewriteFramesIntegration, + sessionTimingIntegration, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, diff --git a/packages/serverless/src/index.ts b/packages/serverless/src/index.ts index ed2debfa9508..bc709a402961 100644 --- a/packages/serverless/src/index.ts +++ b/packages/serverless/src/index.ts @@ -98,3 +98,12 @@ export { endSession, withActiveSpan, } from '@sentry/node-experimental'; + +export { + captureConsoleIntegration, + debugIntegration, + dedupeIntegration, + extraErrorDataIntegration, + rewriteFramesIntegration, + sessionTimingIntegration, +} from '@sentry/core'; From 9e346060eb5643af3341cc85368958e080629e2f Mon Sep 17 00:00:00 2001 From: s1gr1d Date: Tue, 27 Feb 2024 14:03:40 +0100 Subject: [PATCH 09/11] fix missing dedupe integration --- .../suites/manual-client/browser-context/init.js | 4 ++-- packages/browser/src/exports.ts | 1 + packages/browser/src/index.ts | 1 - packages/browser/test/integration/run.js | 2 +- packages/deno/src/index.ts | 3 ++- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/dev-packages/browser-integration-tests/suites/manual-client/browser-context/init.js b/dev-packages/browser-integration-tests/suites/manual-client/browser-context/init.js index d176abb81e23..cf70853184cd 100644 --- a/dev-packages/browser-integration-tests/suites/manual-client/browser-context/init.js +++ b/dev-packages/browser-integration-tests/suites/manual-client/browser-context/init.js @@ -1,12 +1,12 @@ import { Breadcrumbs, BrowserClient, - Dedupe, FunctionToString, HttpContext, Hub, InboundFilters, LinkedErrors, + dedupeIntegration, defaultStackParser, makeFetchTransport, } from '@sentry/browser'; @@ -14,7 +14,7 @@ import { const integrations = [ new Breadcrumbs(), new FunctionToString(), - new Dedupe(), + dedupeIntegration(), new HttpContext(), new InboundFilters(), new LinkedErrors(), diff --git a/packages/browser/src/exports.ts b/packages/browser/src/exports.ts index 04a9632b2f5d..b066ebe3d9a4 100644 --- a/packages/browser/src/exports.ts +++ b/packages/browser/src/exports.ts @@ -66,6 +66,7 @@ export { InboundFilters, functionToStringIntegration, inboundFiltersIntegration, + dedupeIntegration, parameterize, startSession, captureSession, diff --git a/packages/browser/src/index.ts b/packages/browser/src/index.ts index d8473e69fcf1..d4c47e6f91eb 100644 --- a/packages/browser/src/index.ts +++ b/packages/browser/src/index.ts @@ -30,7 +30,6 @@ export { contextLinesIntegration } from './integrations/contextlines'; export { captureConsoleIntegration, debugIntegration, - dedupeIntegration, extraErrorDataIntegration, rewriteFramesIntegration, sessionTimingIntegration, diff --git a/packages/browser/test/integration/run.js b/packages/browser/test/integration/run.js index abca77887ddf..2eac65132877 100755 --- a/packages/browser/test/integration/run.js +++ b/packages/browser/test/integration/run.js @@ -73,7 +73,7 @@ function build() { writeFile( 'artifacts/dedupe.js', - readFile('../../../integrations/build/bundles/dedupe.js').replace('//# sourceMappingURL=dedupe.js.map', ''), + readFile('../../../browser/build/bundles/dedupe.js').replace('//# sourceMappingURL=dedupe.js.map', ''), ); concatFiles('artifacts/setup.js', ['artifacts/dedupe.js', 'common/utils.js', 'common/triggers.js', 'common/init.js']); rmdir('artifacts/dedupe.js'); diff --git a/packages/deno/src/index.ts b/packages/deno/src/index.ts index f124763abd9a..067cfd8a1599 100644 --- a/packages/deno/src/index.ts +++ b/packages/deno/src/index.ts @@ -73,6 +73,7 @@ export { requestDataIntegration, captureConsoleIntegration, debugIntegration, + dedupeIntegration, extraErrorDataIntegration, rewriteFramesIntegration, sessionTimingIntegration, @@ -94,7 +95,7 @@ export { init, } from './sdk'; -export { breadcrumbsIntegration, dedupeIntegration } from '@sentry/browser'; +export { breadcrumbsIntegration } from '@sentry/browser'; import { Integrations as CoreIntegrations } from '@sentry/core'; export { denoContextIntegration } from './integrations/context'; From 82bfc58db96710523c2a0bddf5c05ba12bca0cc4 Mon Sep 17 00:00:00 2001 From: s1gr1d Date: Tue, 27 Feb 2024 16:12:48 +0100 Subject: [PATCH 10/11] review comments --- .../browser-integration-tests/utils/generatePlugin.ts | 11 ++++------- dev-packages/rollup-utils/bundleHelpers.mjs | 2 +- packages/browser/rollup.bundle.config.mjs | 4 ++-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/dev-packages/browser-integration-tests/utils/generatePlugin.ts b/dev-packages/browser-integration-tests/utils/generatePlugin.ts index 63a1d9f51854..738771aedced 100644 --- a/dev-packages/browser-integration-tests/utils/generatePlugin.ts +++ b/dev-packages/browser-integration-tests/utils/generatePlugin.ts @@ -129,17 +129,14 @@ function generateSentryAlias(): Record { return Object.fromEntries( packageNames.map(packageName => { - // pluggable integrations exist in the browser package - const actPackageName = packageName === 'integrations' ? 'browser' : packageName; - const packageJSON: Package = JSON.parse( - fs.readFileSync(path.resolve(PACKAGES_DIR, actPackageName, 'package.json'), { encoding: 'utf-8' }).toString(), + fs.readFileSync(path.resolve(PACKAGES_DIR, packageName, 'package.json'), { encoding: 'utf-8' }).toString(), ); - const modulePath = path.resolve(PACKAGES_DIR, actPackageName); + const modulePath = path.resolve(PACKAGES_DIR, packageName); - if (useCompiledModule && bundleKey && BUNDLE_PATHS[actPackageName]?.[bundleKey]) { - const bundlePath = path.resolve(modulePath, BUNDLE_PATHS[actPackageName][bundleKey]); + if (useCompiledModule && bundleKey && BUNDLE_PATHS[packageName]?.[bundleKey]) { + const bundlePath = path.resolve(modulePath, BUNDLE_PATHS[packageName][bundleKey]); return [packageJSON['name'], bundlePath]; } diff --git a/dev-packages/rollup-utils/bundleHelpers.mjs b/dev-packages/rollup-utils/bundleHelpers.mjs index 9e4466bb56cd..6043207ee97c 100644 --- a/dev-packages/rollup-utils/bundleHelpers.mjs +++ b/dev-packages/rollup-utils/bundleHelpers.mjs @@ -59,7 +59,7 @@ export function makeBaseBundleConfig(options) { plugins: [rrwebBuildPlugin, markAsBrowserBuildPlugin], }; - // used by `@sentry/wasm` (bundles which need to be combined with a stand-alone SDK bundle) + // used by `@sentry/wasm` & pluggable integrations from core/browser (bundles which need to be combined with a stand-alone SDK bundle) const addOnBundleConfig = { // These output settings are designed to mimic an IIFE. We don't use Rollup's `iife` format because we don't want to // attach this code to a new global variable, but rather inject it into the existing SDK's `Integrations` object. diff --git a/packages/browser/rollup.bundle.config.mjs b/packages/browser/rollup.bundle.config.mjs index 7fafe48aacbd..d9c9164c5cea 100644 --- a/packages/browser/rollup.bundle.config.mjs +++ b/packages/browser/rollup.bundle.config.mjs @@ -8,7 +8,7 @@ if (targets.some(target => target !== 'es5' && target !== 'es6')) { throw new Error('JS_VERSION must be either "es5" or "es6"'); } -const addonIntegrationFiles = ['contextlines', 'httpclient', 'reportingobserver']; +const browserPluggableIntegrationFiles = ['contextlines', 'httpclient', 'reportingobserver']; const coreIntegrationFiles = ['captureconsole', 'debug', 'dedupe', 'extraerrordata', 'rewriteframes', 'sessiontiming']; @@ -29,7 +29,7 @@ targets.forEach(jsVersion => { outputFileBase: () => `bundles/bundle.tracing${jsVersion === 'es5' ? '.es5' : ''}`, }); - addonIntegrationFiles.forEach(integrationName => { + browserPluggableIntegrationFiles.forEach(integrationName => { const integrationsBundleConfig = makeBaseBundleConfig({ bundleType: 'addon', entrypoints: [`src/integrations/${integrationName}.ts`], From 108f53f2b85716799969d2d1545874642ead1f9f Mon Sep 17 00:00:00 2001 From: s1gr1d Date: Tue, 27 Feb 2024 17:00:41 +0100 Subject: [PATCH 11/11] more review comments --- MIGRATION.md | 6 +++--- packages/browser/rollup.bundle.config.mjs | 11 +++++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/MIGRATION.md b/MIGRATION.md index 1bae55164e85..4b44177ec71d 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -114,9 +114,9 @@ Sentry SDK requires the fetch API to be available in the environment. ## Integrations -We moved optional integrations from their own package (`@sentry/integrations`) to `@sentry/browser` and `@sentry/node`. +We moved pluggable integrations from their own package (`@sentry/integrations`) to `@sentry/browser` and `@sentry/node`. -Integrations that are now exported from `@sentry/browser` : +Integrations that are now exported from `@sentry/browser` (or framework-specific packages like `@sentry/react`): - httpClientIntegration - contextLinesIntegration @@ -127,10 +127,10 @@ Integrations that are now exported from `@sentry/node` and `@sentry/browser` (or - captureConsoleIntegration - debugIntegration -- dedupeIntegration - extraErrorDataIntegration - rewriteFramesIntegration - sessionTimingIntegration +- dedupeIntegration (enabled by default, not pluggable) # Deprecations in 7.x diff --git a/packages/browser/rollup.bundle.config.mjs b/packages/browser/rollup.bundle.config.mjs index d9c9164c5cea..d262f1a1bc51 100644 --- a/packages/browser/rollup.bundle.config.mjs +++ b/packages/browser/rollup.bundle.config.mjs @@ -10,7 +10,14 @@ if (targets.some(target => target !== 'es5' && target !== 'es6')) { const browserPluggableIntegrationFiles = ['contextlines', 'httpclient', 'reportingobserver']; -const coreIntegrationFiles = ['captureconsole', 'debug', 'dedupe', 'extraerrordata', 'rewriteframes', 'sessiontiming']; +const corePluggableIntegrationFiles = [ + 'captureconsole', + 'debug', + 'dedupe', + 'extraerrordata', + 'rewriteframes', + 'sessiontiming', +]; targets.forEach(jsVersion => { const baseBundleConfig = makeBaseBundleConfig({ @@ -41,7 +48,7 @@ targets.forEach(jsVersion => { builds.push(...makeBundleConfigVariants(integrationsBundleConfig)); }); - coreIntegrationFiles.forEach(integrationName => { + corePluggableIntegrationFiles.forEach(integrationName => { const integrationsBundleConfig = makeBaseBundleConfig({ bundleType: 'addon', entrypoints: [`src/integrations-bundle/index.${integrationName}.ts`],