Skip to content

Commit

Permalink
feat(v8/integrations): Merge integrations into core (#10799)
Browse files Browse the repository at this point in the history
Move relevant integrations. Part of
#9833
  • Loading branch information
s1gr1d authored Feb 27, 2024
1 parent 519aacc commit a5c4fcb
Show file tree
Hide file tree
Showing 85 changed files with 167 additions and 526 deletions.
3 changes: 0 additions & 3 deletions .craft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ jobs:
- 'packages/tracing-internal/**'
- 'packages/utils/**'
- 'packages/types/**'
- 'packages/integrations/**'
browser: &browser
- *shared
- 'packages/browser/**'
Expand Down Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,26 @@ 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 pluggable integrations from their own package (`@sentry/integrations`) to `@sentry/browser` and `@sentry/node`.

Integrations that are now exported from `@sentry/browser` (or framework-specific packages like `@sentry/react`):

- httpClientIntegration
- contextLinesIntegration
- reportingObserverIntegration

Integrations that are now exported from `@sentry/node` and `@sentry/browser` (or framework-specific packages like
`@sentry/react`):

- captureConsoleIntegration
- debugIntegration
- extraErrorDataIntegration
- rewriteFramesIntegration
- sessionTimingIntegration
- dedupeIntegration (enabled by default, not pluggable)

# Deprecations in 7.x

You can use the **Experimental** [@sentry/migr8](https://www.npmjs.com/package/@sentry/migr8) to automatically update
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as Sentry from '@sentry/browser';
import { contextLinesIntegration } from '@sentry/integrations';
import { contextLinesIntegration } from '@sentry/browser';

window.Sentry = Sentry;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as Sentry from '@sentry/browser';
import { httpClientIntegration } from '@sentry/integrations';
import { httpClientIntegration } from '@sentry/browser';

window.Sentry = Sentry;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as Sentry from '@sentry/browser';
import { httpClientIntegration } from '@sentry/integrations';
import { httpClientIntegration } from '@sentry/browser';

window.Sentry = Sentry;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as Sentry from '@sentry/browser';
import { httpClientIntegration } from '@sentry/integrations';
import { httpClientIntegration } from '@sentry/browser';

window.Sentry = Sentry;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import {
Breadcrumbs,
BrowserClient,
Dedupe,
FunctionToString,
HttpContext,
Hub,
InboundFilters,
LinkedErrors,
dedupeIntegration,
defaultStackParser,
makeFetchTransport,
} from '@sentry/browser';

const integrations = [
new Breadcrumbs(),
new FunctionToString(),
new Dedupe(),
dedupeIntegration(),
new HttpContext(),
new InboundFilters(),
new LinkedErrors(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
: {};
Expand Down Expand Up @@ -242,7 +241,7 @@ class SentryScenarioGenerationPlugin {
this.localOutPath,
path.resolve(
PACKAGES_DIR,
'integrations',
'browser',
BUNDLE_PATHS['integrations'][integrationBundleKey].replace('[INTEGRATION_NAME]', integration),
),
fileName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"dependencies": {
"@sentry/browser": "latest || *",
"@sentry/core": "latest || *",
"@sentry/integrations": "latest || *",
"@sentry/node": "latest || *",
"@sentry/opentelemetry-node": "latest || *",
"@sentry/replay": "latest || *",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"test:assert": "pnpm test"
},
"dependencies": {
"@sentry/integrations": "latest || *",
"@sentry/node": "latest || *",
"@sentry/types": "latest || *",
"express": "4.18.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { httpClientIntegration } from '@sentry/integrations';
import * as Sentry from '@sentry/node';
import express from 'express';

Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
},
"dependencies": {
"@hapi/hapi": "21.3.2",
"@sentry/integrations": "latest || *",
"@sentry/node": "latest || *",
"@sentry/types": "latest || *",
"@types/node": "18.15.1",
Expand Down
6 changes: 0 additions & 6 deletions dev-packages/e2e-tests/verdaccio-config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/rollup-utils/bundleHelpers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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` & 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.
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"packages/eslint-plugin-sdk",
"packages/feedback",
"packages/gatsby",
"packages/integrations",
"packages/integration-shims",
"packages/nextjs",
"packages/node",
Expand Down
1 change: 1 addition & 0 deletions packages/astro/src/index.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
35 changes: 35 additions & 0 deletions packages/browser/rollup.bundle.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ if (targets.some(target => target !== 'es5' && target !== 'es6')) {
throw new Error('JS_VERSION must be either "es5" or "es6"');
}

const browserPluggableIntegrationFiles = ['contextlines', 'httpclient', 'reportingobserver'];

const corePluggableIntegrationFiles = [
'captureconsole',
'debug',
'dedupe',
'extraerrordata',
'rewriteframes',
'sessiontiming',
];

targets.forEach(jsVersion => {
const baseBundleConfig = makeBaseBundleConfig({
bundleType: 'standalone',
Expand All @@ -25,6 +36,30 @@ targets.forEach(jsVersion => {
outputFileBase: () => `bundles/bundle.tracing${jsVersion === 'es5' ? '.es5' : ''}`,
});

browserPluggableIntegrationFiles.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));
});

corePluggableIntegrationFiles.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));
});

Expand Down
4 changes: 2 additions & 2 deletions packages/browser/src/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export {
InboundFilters,
functionToStringIntegration,
inboundFiltersIntegration,
dedupeIntegration,
parameterize,
startSession,
captureSession,
Expand Down Expand Up @@ -108,11 +109,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';
4 changes: 3 additions & 1 deletion packages/browser/src/index.bundle.base.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { IntegrationFn } from '@sentry/types/src';

export * from './exports';

import { Integrations as CoreIntegrations } from '@sentry/core';
Expand All @@ -14,7 +16,7 @@ if (WINDOW.Sentry && WINDOW.Sentry.Integrations) {
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const INTEGRATIONS: Record<string, new (...args: any[]) => Integration> = {
const INTEGRATIONS: Record<string, (new (...args: any[]) => Integration) | IntegrationFn> = {
...windowIntegrations,
// eslint-disable-next-line deprecation/deprecation
...CoreIntegrations,
Expand Down
12 changes: 12 additions & 0 deletions packages/browser/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ 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,
extraErrorDataIntegration,
rewriteFramesIntegration,
sessionTimingIntegration,
} from '@sentry/core';

export {
// eslint-disable-next-line deprecation/deprecation
Replay,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { captureConsoleIntegration } from '@sentry/core';
1 change: 1 addition & 0 deletions packages/browser/src/integrations-bundle/index.debug.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { debugIntegration } from '@sentry/core';
1 change: 1 addition & 0 deletions packages/browser/src/integrations-bundle/index.dedupe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { dedupeIntegration } from '@sentry/core';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { extraErrorDataIntegration } from '@sentry/core';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { rewriteFramesIntegration } from '@sentry/core';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { sessionTimingIntegration } from '@sentry/core';
File renamed without changes.
Loading

0 comments on commit a5c4fcb

Please sign in to comment.