diff --git a/MIGRATION.md b/MIGRATION.md index 4c0ea3eddc91..f92022cc4690 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -53,12 +53,15 @@ The following list shows how integrations should be migrated: | `new RewriteFrames()` | `rewriteFramesIntegration()` | `@sentry/integrations` | | `new SessionTiming()` | `sessionTimingIntegration()` | `@sentry/integrations` | | `new HttpClient()` | `httpClientIntegration()` | `@sentry/integrations` | -| `new ContextLines()` | `contextLinesIntegration()` | `@sentry/browser` | +| `new ContextLines()` | `contextLinesIntegration()` | `@sentry/browser`, `@sentry/deno` | | `new Breadcrumbs()` | `breadcrumbsIntegration()` | `@sentry/browser`, `@sentry/deno` | -| `new GlobalHandlers()` | `globalHandlersIntegration()` | `@sentry/browser` | +| `new GlobalHandlers()` | `globalHandlersIntegration()` | `@sentry/browser` , `@sentry/deno` | | `new HttpContext()` | `httpContextIntegration()` | `@sentry/browser` | | `new TryCatch()` | `browserApiErrorsIntegration()` | `@sentry/browser`, `@sentry/deno` | | `new VueIntegration()` | `vueIntegration()` | `@sentry/vue` | +| `new DenoContext()` | `denoContextIntegration()` | `@sentry/deno` | +| `new DenoCron()` | `denoCronIntegration()` | `@sentry/deno` | +| `new NormalizePaths()` | `normalizePathsIntegration()` | `@sentry/deno` | ## Deprecate `hub.bindClient()` and `makeMain()` diff --git a/packages/deno/src/index.ts b/packages/deno/src/index.ts index 65d82a0e6779..a622df3111e6 100644 --- a/packages/deno/src/index.ts +++ b/packages/deno/src/index.ts @@ -97,12 +97,17 @@ export { export { breadcrumbsIntegration, dedupeIntegration } from '@sentry/browser'; import { Integrations as CoreIntegrations } from '@sentry/core'; +export { denoContextIntegration } from './integrations/context'; +export { globalHandlersIntegration } from './integrations/globalhandlers'; +export { normalizePathsIntegration } from './integrations/normalizepaths'; +export { contextLinesIntegration } from './integrations/contextlines'; +export { denoCronIntegration } from './integrations/deno-cron'; + import * as DenoIntegrations from './integrations'; -const INTEGRATIONS = { +/** @deprecated Import the integration function directly, e.g. `inboundFiltersIntegration()` instead of `new Integrations.InboundFilter(). */ +export const Integrations = { // eslint-disable-next-line deprecation/deprecation ...CoreIntegrations, ...DenoIntegrations, }; - -export { INTEGRATIONS as Integrations }; diff --git a/packages/deno/src/integrations/context.ts b/packages/deno/src/integrations/context.ts index 199da80d9b4b..f844b80be6c8 100644 --- a/packages/deno/src/integrations/context.ts +++ b/packages/deno/src/integrations/context.ts @@ -1,4 +1,4 @@ -import { convertIntegrationFnToClass } from '@sentry/core'; +import { convertIntegrationFnToClass, defineIntegration } from '@sentry/core'; import type { Event, Integration, IntegrationClass, IntegrationFn } from '@sentry/types'; const INTEGRATION_NAME = 'DenoContext'; @@ -52,7 +52,7 @@ async function addDenoRuntimeContext(event: Event): Promise { return event; } -const denoContextIntegration = (() => { +const _denoContextIntegration = (() => { return { name: INTEGRATION_NAME, // TODO v8: Remove this @@ -63,8 +63,16 @@ const denoContextIntegration = (() => { }; }) satisfies IntegrationFn; -/** Adds Deno context to events. */ +export const denoContextIntegration = defineIntegration(_denoContextIntegration); + +/** + * Adds Deno context to events. + * @deprecated Use `denoContextintegration()` instead. + */ // eslint-disable-next-line deprecation/deprecation export const DenoContext = convertIntegrationFnToClass(INTEGRATION_NAME, denoContextIntegration) as IntegrationClass< Integration & { processEvent: (event: Event) => Promise } >; + +// eslint-disable-next-line deprecation/deprecation +export type DenoContext = typeof DenoContext; diff --git a/packages/deno/src/integrations/contextlines.ts b/packages/deno/src/integrations/contextlines.ts index 1b3b413699f6..fc51e4ad2d57 100644 --- a/packages/deno/src/integrations/contextlines.ts +++ b/packages/deno/src/integrations/contextlines.ts @@ -1,4 +1,4 @@ -import { convertIntegrationFnToClass } from '@sentry/core'; +import { convertIntegrationFnToClass, defineIntegration } from '@sentry/core'; import type { Event, Integration, IntegrationClass, IntegrationFn, StackFrame } from '@sentry/types'; import { LRUMap, addContextToFrame } from '@sentry/utils'; @@ -47,7 +47,7 @@ interface ContextLinesOptions { frameContextLines?: number; } -const denoContextLinesIntegration = ((options: ContextLinesOptions = {}) => { +const _contextLinesIntegration = ((options: ContextLinesOptions = {}) => { const contextLines = options.frameContextLines !== undefined ? options.frameContextLines : DEFAULT_LINES_OF_CONTEXT; return { @@ -60,12 +60,19 @@ const denoContextLinesIntegration = ((options: ContextLinesOptions = {}) => { }; }) satisfies IntegrationFn; -/** Add node modules / packages to the event */ +export const contextLinesIntegration = defineIntegration(_contextLinesIntegration); + +/** + * Add node modules / packages to the event. + * @deprecated Use `contextLinesIntegration()` instead. + */ +// eslint-disable-next-line deprecation/deprecation +export const ContextLines = convertIntegrationFnToClass(INTEGRATION_NAME, contextLinesIntegration) as IntegrationClass< + Integration & { processEvent: (event: Event) => Promise } +>; + // eslint-disable-next-line deprecation/deprecation -export const ContextLines = convertIntegrationFnToClass( - INTEGRATION_NAME, - denoContextLinesIntegration, -) as IntegrationClass Promise }>; +export type ContextLines = typeof ContextLines; /** Processes an event and adds context lines */ async function addSourceContext(event: Event, contextLines: number): Promise { diff --git a/packages/deno/src/integrations/deno-cron.ts b/packages/deno/src/integrations/deno-cron.ts index 3b337b004405..0c54821effbe 100644 --- a/packages/deno/src/integrations/deno-cron.ts +++ b/packages/deno/src/integrations/deno-cron.ts @@ -1,4 +1,4 @@ -import { convertIntegrationFnToClass, getClient, withMonitor } from '@sentry/core'; +import { convertIntegrationFnToClass, defineIntegration, getClient, withMonitor } from '@sentry/core'; import type { Client, Integration, IntegrationClass, IntegrationFn } from '@sentry/types'; import { parseScheduleToString } from './deno-cron-format'; @@ -11,7 +11,7 @@ const INTEGRATION_NAME = 'DenoCron'; const SETUP_CLIENTS = new WeakMap(); -const denoCronIntegration = (() => { +const _denoCronIntegration = (() => { return { name: INTEGRATION_NAME, setupOnce() { @@ -60,8 +60,16 @@ const denoCronIntegration = (() => { }; }) satisfies IntegrationFn; -/** Instruments Deno.cron to automatically capture cron check-ins */ +export const denoCronIntegration = defineIntegration(_denoCronIntegration); + +/** + * Instruments Deno.cron to automatically capture cron check-ins. + * @deprecated Use `denoCronIntegration()` instead. + */ // eslint-disable-next-line deprecation/deprecation export const DenoCron = convertIntegrationFnToClass(INTEGRATION_NAME, denoCronIntegration) as IntegrationClass< Integration & { setup: (client: Client) => void } >; + +// eslint-disable-next-line deprecation/deprecation +export type DenoCron = typeof DenoCron; diff --git a/packages/deno/src/integrations/globalhandlers.ts b/packages/deno/src/integrations/globalhandlers.ts index 895c52ee59e4..0c830c40da25 100644 --- a/packages/deno/src/integrations/globalhandlers.ts +++ b/packages/deno/src/integrations/globalhandlers.ts @@ -1,4 +1,5 @@ import type { ServerRuntimeClient } from '@sentry/core'; +import { defineIntegration } from '@sentry/core'; import { convertIntegrationFnToClass } from '@sentry/core'; import { captureEvent } from '@sentry/core'; import { getClient } from '@sentry/core'; @@ -21,7 +22,7 @@ type GlobalHandlersIntegrations = Record { +const _globalHandlersIntegration = ((options?: GlobalHandlersIntegrations) => { const _options = { error: true, unhandledrejection: true, @@ -43,13 +44,21 @@ const globalHandlersIntegration = ((options?: GlobalHandlersIntegrations) => { }; }) satisfies IntegrationFn; -/** Global handlers */ +export const globalHandlersIntegration = defineIntegration(_globalHandlersIntegration); + +/** + * Global handlers. + * @deprecated Use `globalHandlersIntergation()` instead. + */ // eslint-disable-next-line deprecation/deprecation export const GlobalHandlers = convertIntegrationFnToClass( INTEGRATION_NAME, globalHandlersIntegration, ) as IntegrationClass void }>; +// eslint-disable-next-line deprecation/deprecation +export type GlobalHandlers = typeof GlobalHandlers; + function installGlobalErrorHandler(client: Client): void { globalThis.addEventListener('error', data => { if (getClient() !== client || isExiting) { diff --git a/packages/deno/src/integrations/index.ts b/packages/deno/src/integrations/index.ts index 065e16770109..6870606066eb 100644 --- a/packages/deno/src/integrations/index.ts +++ b/packages/deno/src/integrations/index.ts @@ -1,3 +1,4 @@ +/* eslint-disable deprecation/deprecation */ export { DenoContext } from './context'; export { GlobalHandlers } from './globalhandlers'; export { NormalizePaths } from './normalizepaths'; diff --git a/packages/deno/src/integrations/normalizepaths.ts b/packages/deno/src/integrations/normalizepaths.ts index 68ba3986e805..a9b8f3dbb0e3 100644 --- a/packages/deno/src/integrations/normalizepaths.ts +++ b/packages/deno/src/integrations/normalizepaths.ts @@ -1,4 +1,4 @@ -import { convertIntegrationFnToClass } from '@sentry/core'; +import { convertIntegrationFnToClass, defineIntegration } from '@sentry/core'; import type { Event, Integration, IntegrationClass, IntegrationFn } from '@sentry/types'; import { createStackParser, dirname, nodeStackLineParser } from '@sentry/utils'; @@ -55,7 +55,7 @@ function getCwd(): string | undefined { return undefined; } -const normalizePathsIntegration = (() => { +const _normalizePathsIntegration = (() => { // Cached here let appRoot: string | undefined; @@ -98,9 +98,17 @@ const normalizePathsIntegration = (() => { }; }) satisfies IntegrationFn; -/** Normalises paths to the app root directory. */ +export const normalizePathsIntegration = defineIntegration(_normalizePathsIntegration); + +/** + * Normalises paths to the app root directory. + * @deprecated Use `normalizePathsIntegration()` instead. + */ // eslint-disable-next-line deprecation/deprecation export const NormalizePaths = convertIntegrationFnToClass( INTEGRATION_NAME, normalizePathsIntegration, ) as IntegrationClass Event }>; + +// eslint-disable-next-line deprecation/deprecation +export type NormalizePaths = typeof NormalizePaths; diff --git a/packages/deno/src/sdk.ts b/packages/deno/src/sdk.ts index 990eb8146039..c5bd3a1d002f 100644 --- a/packages/deno/src/sdk.ts +++ b/packages/deno/src/sdk.ts @@ -6,7 +6,10 @@ import type { Integration, Options, StackParser } from '@sentry/types'; import { createStackParser, nodeStackLineParser, stackParserFromStackParserOptions } from '@sentry/utils'; import { DenoClient } from './client'; -import { ContextLines, DenoContext, GlobalHandlers, NormalizePaths } from './integrations'; +import { denoContextIntegration } from './integrations/context'; +import { contextLinesIntegration } from './integrations/contextlines'; +import { globalHandlersIntegration } from './integrations/globalhandlers'; +import { normalizePathsIntegration } from './integrations/normalizepaths'; import { makeFetchTransport } from './transports'; import type { DenoOptions } from './types'; @@ -24,10 +27,10 @@ export const defaultIntegrations = [ xhr: false, }), // Deno Specific - new DenoContext(), - new ContextLines(), - new NormalizePaths(), - new GlobalHandlers(), + denoContextIntegration(), + contextLinesIntegration(), + normalizePathsIntegration(), + globalHandlersIntegration(), ]; /** Get the default integrations for the Deno SDK. */