Skip to content

Commit c5dcb5d

Browse files
authored
feat(browser): Export functional integrations & deprecate classes (#10267)
Also deprecate the `Integrations` hash in browser SDKs. I also forgot to add the integrations from `@sentry/integrations` to the migration.md doc, so adding those as well!
1 parent 2c43038 commit c5dcb5d

File tree

20 files changed

+125
-54
lines changed

20 files changed

+125
-54
lines changed

MIGRATION.md

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,31 @@ integrations from the `Integrations.XXX` hash, is deprecated in favor of using t
3434

3535
The following list shows how integrations should be migrated:
3636

37-
| Old | New | Packages |
38-
| ------------------------ | ------------------------------- | ------------------------------------------------------------------------------------------------------- |
39-
| `new InboundFilters()` | `inboundFiltersIntegration()` | `@sentry/core`, `@sentry/browser`, `@sentry/node`, `@sentry/deno`, `@sentry/bun`, `@sentry/vercel-edge` |
40-
| `new FunctionToString()` | `functionToStringIntegration()` | `@sentry/core`, `@sentry/browser`, `@sentry/node`, `@sentry/deno`, `@sentry/bun`, `@sentry/vercel-edge` |
41-
| `new LinkedErrors()` | `linkedErrorsIntegration()` | `@sentry/core`, `@sentry/browser`, `@sentry/node`, `@sentry/deno`, `@sentry/bun`, `@sentry/vercel-edge` |
42-
| `new ModuleMetadata()` | `moduleMetadataIntegration()` | `@sentry/core`, `@sentry/browser` |
43-
| `new RequestData()` | `requestDataIntegration()` | `@sentry/core`, `@sentry/node`, `@sentry/deno`, `@sentry/bun`, `@sentry/vercel-edge` |
44-
| `new Wasm() ` | `wasmIntegration()` | `@sentry/wasm` |
45-
| `new Replay()` | `replayIntegration()` | `@sentry/browser` |
46-
| `new ReplayCanvas()` | `replayCanvasIntegration()` | `@sentry/browser` |
47-
| `new Feedback()` | `feedbackIntegration()` | `@sentry/browser` |
37+
| Old | New | Packages |
38+
| ------------------------- | -------------------------------- | ------------------------------------------------------------------------------------------------------- |
39+
| `new InboundFilters()` | `inboundFiltersIntegration()` | `@sentry/core`, `@sentry/browser`, `@sentry/node`, `@sentry/deno`, `@sentry/bun`, `@sentry/vercel-edge` |
40+
| `new FunctionToString()` | `functionToStringIntegration()` | `@sentry/core`, `@sentry/browser`, `@sentry/node`, `@sentry/deno`, `@sentry/bun`, `@sentry/vercel-edge` |
41+
| `new LinkedErrors()` | `linkedErrorsIntegration()` | `@sentry/core`, `@sentry/browser`, `@sentry/node`, `@sentry/deno`, `@sentry/bun`, `@sentry/vercel-edge` |
42+
| `new ModuleMetadata()` | `moduleMetadataIntegration()` | `@sentry/core`, `@sentry/browser` |
43+
| `new RequestData()` | `requestDataIntegration()` | `@sentry/core`, `@sentry/node`, `@sentry/deno`, `@sentry/bun`, `@sentry/vercel-edge` |
44+
| `new Wasm() ` | `wasmIntegration()` | `@sentry/wasm` |
45+
| `new Replay()` | `replayIntegration()` | `@sentry/browser` |
46+
| `new ReplayCanvas()` | `replayCanvasIntegration()` | `@sentry/browser` |
47+
| `new Feedback()` | `feedbackIntegration()` | `@sentry/browser` |
48+
| `new CaptureConsole()` | `captureConsoleIntegration()` | `@sentry/integrations` |
49+
| `new Debug()` | `debugIntegration()` | `@sentry/integrations` |
50+
| `new Dedupe()` | `dedupeIntegration()` | `@sentry/browser`, `@sentry/integrations`, `@sentry/deno` |
51+
| `new ExtraErrorData()` | `extraErrorDataIntegration()` | `@sentry/integrations` |
52+
| `new ReportingObserver()` | `reportingObserverIntegration()` | `@sentry/integrations` |
53+
| `new RewriteFrames()` | `rewriteFramesIntegration()` | `@sentry/integrations` |
54+
| `new SessionTiming()` | `sessionTimingIntegration()` | `@sentry/integrations` |
55+
| `new HttpClient()` | `httpClientIntegration()` | `@sentry/integrations` |
56+
| `new ContextLines()` | `contextLinesIntegration()` | `@sentry/browser` |
57+
| `new Breadcrumbs()` | `breadcrumbsIntegration()` | `@sentry/browser`, `@sentry/deno` |
58+
| `new GlobalHandlers()` | `globalHandlersIntegration()` | `@sentry/browser` |
59+
| `new HttpContext()` | `httpContextIntegration()` | `@sentry/browser` |
60+
| `new TryCatch()` | `browserApiErrorsIntegration()` | `@sentry/browser`, `@sentry/deno` |
61+
| `new VueIntegration()` | `vueIntegration()` | `@sentry/vue` |
4862

4963
## Deprecate `hub.bindClient()` and `makeMain()`
5064

packages/astro/src/index.types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ import sentryAstro from './index.server';
1414
export declare function init(options: Options | clientSdk.BrowserOptions | serverSdk.NodeOptions): void;
1515

1616
// We export a merged Integrations object so that users can (at least typing-wise) use all integrations everywhere.
17+
// eslint-disable-next-line deprecation/deprecation
1718
export declare const Integrations: typeof clientSdk.Integrations & typeof serverSdk.Integrations;
1819

20+
export declare const linkedErrorsIntegration: typeof clientSdk.linkedErrorsIntegration;
21+
1922
export declare const defaultIntegrations: Integration[];
2023
export declare const getDefaultIntegrations: (options: Options) => Integration[];
2124
export declare const defaultStackParser: StackParser;

packages/browser/src/exports.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,13 @@ export {
102102
// eslint-disable-next-line deprecation/deprecation
103103
wrap,
104104
} from './sdk';
105+
106+
export { breadcrumbsIntegration } from './integrations/breadcrumbs';
107+
export { dedupeIntegration } from './integrations/dedupe';
108+
export { globalHandlersIntegration } from './integrations/globalhandlers';
109+
export { httpContextIntegration } from './integrations/httpcontext';
110+
export { linkedErrorsIntegration } from './integrations/linkederrors';
111+
export { browserApiErrorsIntegration } from './integrations/trycatch';
112+
113+
// eslint-disable-next-line deprecation/deprecation
105114
export { GlobalHandlers, TryCatch, Breadcrumbs, LinkedErrors, HttpContext, Dedupe } from './integrations';

packages/browser/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ if (WINDOW.Sentry && WINDOW.Sentry.Integrations) {
1212
windowIntegrations = WINDOW.Sentry.Integrations;
1313
}
1414

15+
/** @deprecated Import the integration function directly, e.g. `inboundFiltersIntegration()` instead of `new Integrations.InboundFilter(). */
1516
const INTEGRATIONS = {
1617
...windowIntegrations,
1718
// eslint-disable-next-line deprecation/deprecation
1819
...CoreIntegrations,
1920
...BrowserIntegrations,
2021
};
2122

23+
// eslint-disable-next-line deprecation/deprecation
2224
export { INTEGRATIONS as Integrations };
2325

2426
export {

packages/browser/src/integrations/breadcrumbs.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable max-lines */
2-
import { addBreadcrumb, convertIntegrationFnToClass, getClient } from '@sentry/core';
2+
import { addBreadcrumb, convertIntegrationFnToClass, defineIntegration, getClient } from '@sentry/core';
33
import type {
44
Client,
55
Event as SentryEvent,
@@ -57,7 +57,7 @@ const MAX_ALLOWED_STRING_LENGTH = 1024;
5757

5858
const INTEGRATION_NAME = 'Breadcrumbs';
5959

60-
const breadcrumbsIntegration = ((options: Partial<BreadcrumbsOptions> = {}) => {
60+
const _breadcrumbsIntegration = ((options: Partial<BreadcrumbsOptions> = {}) => {
6161
const _options = {
6262
console: true,
6363
dom: true,
@@ -95,8 +95,12 @@ const breadcrumbsIntegration = ((options: Partial<BreadcrumbsOptions> = {}) => {
9595
};
9696
}) satisfies IntegrationFn;
9797

98+
export const breadcrumbsIntegration = defineIntegration(_breadcrumbsIntegration);
99+
98100
/**
99101
* Default Breadcrumbs instrumentations
102+
*
103+
* @deprecated Use `breadcrumbsIntegration()` instead.
100104
*/
101105
// eslint-disable-next-line deprecation/deprecation
102106
export const Breadcrumbs = convertIntegrationFnToClass(INTEGRATION_NAME, breadcrumbsIntegration) as IntegrationClass<

packages/browser/src/integrations/dedupe.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { convertIntegrationFnToClass } from '@sentry/core';
1+
import { convertIntegrationFnToClass, defineIntegration } from '@sentry/core';
22
import type { Event, Exception, Integration, IntegrationClass, IntegrationFn, StackFrame } from '@sentry/types';
33
import { logger } from '@sentry/utils';
44

55
import { DEBUG_BUILD } from '../debug-build';
66

77
const INTEGRATION_NAME = 'Dedupe';
88

9-
const dedupeIntegration = (() => {
9+
const _dedupeIntegration = (() => {
1010
let previousEvent: Event | undefined;
1111

1212
return {
@@ -33,7 +33,12 @@ const dedupeIntegration = (() => {
3333
};
3434
}) satisfies IntegrationFn;
3535

36-
/** Deduplication filter */
36+
export const dedupeIntegration = defineIntegration(_dedupeIntegration);
37+
38+
/**
39+
* Deduplication filter.
40+
* @deprecated Use `dedupeIntegration()` instead.
41+
*/
3742
// eslint-disable-next-line deprecation/deprecation
3843
export const Dedupe = convertIntegrationFnToClass(INTEGRATION_NAME, dedupeIntegration) as IntegrationClass<
3944
Integration & { processEvent: (event: Event) => Event }

packages/browser/src/integrations/globalhandlers.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
2-
import { captureEvent, convertIntegrationFnToClass, getClient } from '@sentry/core';
2+
import { captureEvent, convertIntegrationFnToClass, defineIntegration, getClient } from '@sentry/core';
33
import type {
44
Client,
55
Event,
@@ -30,7 +30,7 @@ type GlobalHandlersIntegrations = Record<GlobalHandlersIntegrationsOptionKeys, b
3030

3131
const INTEGRATION_NAME = 'GlobalHandlers';
3232

33-
const globalHandlersIntegration = ((options: Partial<GlobalHandlersIntegrations> = {}) => {
33+
const _globalHandlersIntegration = ((options: Partial<GlobalHandlersIntegrations> = {}) => {
3434
const _options = {
3535
onerror: true,
3636
onunhandledrejection: true,
@@ -55,7 +55,12 @@ const globalHandlersIntegration = ((options: Partial<GlobalHandlersIntegrations>
5555
};
5656
}) satisfies IntegrationFn;
5757

58-
/** Global handlers */
58+
export const globalHandlersIntegration = defineIntegration(_globalHandlersIntegration);
59+
60+
/**
61+
* Global handlers.
62+
* @deprecated Use `globalHandlersIntegration()` instead.
63+
*/
5964
// eslint-disable-next-line deprecation/deprecation
6065
export const GlobalHandlers = convertIntegrationFnToClass(
6166
INTEGRATION_NAME,

packages/browser/src/integrations/httpcontext.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { convertIntegrationFnToClass } from '@sentry/core';
1+
import { convertIntegrationFnToClass, defineIntegration } from '@sentry/core';
22
import type { Event, Integration, IntegrationClass, IntegrationFn } from '@sentry/types';
33

44
import { WINDOW } from '../helpers';
55

66
const INTEGRATION_NAME = 'HttpContext';
77

8-
const httpContextIntegration = (() => {
8+
const _httpContextIntegration = (() => {
99
return {
1010
name: INTEGRATION_NAME,
1111
// TODO v8: Remove this
@@ -33,7 +33,12 @@ const httpContextIntegration = (() => {
3333
};
3434
}) satisfies IntegrationFn;
3535

36-
/** HttpContext integration collects information about HTTP request headers */
36+
export const httpContextIntegration = defineIntegration(_httpContextIntegration);
37+
38+
/**
39+
* HttpContext integration collects information about HTTP request headers.
40+
* @deprecated Use `httpContextIntegration()` instead.
41+
*/
3742
// eslint-disable-next-line deprecation/deprecation
3843
export const HttpContext = convertIntegrationFnToClass(INTEGRATION_NAME, httpContextIntegration) as IntegrationClass<
3944
Integration & { preprocessEvent: (event: Event) => void }

packages/browser/src/integrations/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable deprecation/deprecation */
12
export { GlobalHandlers } from './globalhandlers';
23
export { TryCatch } from './trycatch';
34
export { Breadcrumbs } from './breadcrumbs';

packages/browser/src/integrations/linkederrors.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { convertIntegrationFnToClass } from '@sentry/core';
1+
import { convertIntegrationFnToClass, defineIntegration } from '@sentry/core';
22
import type { Client, Event, EventHint, Integration, IntegrationClass, IntegrationFn } from '@sentry/types';
33
import { applyAggregateErrorsToEvent } from '@sentry/utils';
44
import { exceptionFromError } from '../eventbuilder';
@@ -13,7 +13,7 @@ const DEFAULT_LIMIT = 5;
1313

1414
const INTEGRATION_NAME = 'LinkedErrors';
1515

16-
const linkedErrorsIntegration = ((options: LinkedErrorsOptions = {}) => {
16+
const _linkedErrorsIntegration = ((options: LinkedErrorsOptions = {}) => {
1717
const limit = options.limit || DEFAULT_LIMIT;
1818
const key = options.key || DEFAULT_KEY;
1919

@@ -38,7 +38,12 @@ const linkedErrorsIntegration = ((options: LinkedErrorsOptions = {}) => {
3838
};
3939
}) satisfies IntegrationFn;
4040

41-
/** Aggregrate linked errors in an event. */
41+
export const linkedErrorsIntegration = defineIntegration(_linkedErrorsIntegration);
42+
43+
/**
44+
* Aggregrate linked errors in an event.
45+
* @deprecated Use `linkedErrorsIntegration()` instead.
46+
*/
4247
// eslint-disable-next-line deprecation/deprecation
4348
export const LinkedErrors = convertIntegrationFnToClass(INTEGRATION_NAME, linkedErrorsIntegration) as IntegrationClass<
4449
Integration & { preprocessEvent: (event: Event, hint: EventHint, client: Client) => void }

0 commit comments

Comments
 (0)