Skip to content

feat(v8/integrations): Remove deprecated exports #10556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/flaky-test-detector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
with:
list-files: json
filters: |
browser_integration: dev-packages/browser-integration-tests/suites/**
browser_integration: dev-packages/browser-integration-tests/suites/**/test.ts

- name: Detect flaky tests
run: yarn test:detect-flaky
Expand Down
5 changes: 5 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,14 @@ to access and mutate the current scope.

## General API Changes

- The minumum supported Node version for all the SDK packages is Node 14 (#10527)
- Remove `spanStatusfromHttpCode` in favour of `getSpanStatusFromHttpCode` (#10361)
- Remove deprecated `deepReadDirSync` export from `@sentry/node` (#10564)
- Remove `_eventFromIncompleteOnError` usage (#10553)
- The `Transaction` integration in `@sentry/integrations` has been removed. There is no replacement API. (#10556)
- `extraErrorDataIntegration` now looks at
[`error.cause`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause) by
default.

# Deprecations in 7.x

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

window.Sentry = Sentry;

Sentry.init({
dsn: 'https://[email protected]/1337',
integrations: [new ContextLines()],
integrations: [contextLinesIntegration()],
});
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as Sentry from '@sentry/browser';
import { HttpClient } from '@sentry/integrations';
import { httpClientIntegration } from '@sentry/integrations';

window.Sentry = Sentry;

Sentry.init({
dsn: 'https://[email protected]/1337',
integrations: [new HttpClient()],
integrations: [httpClientIntegration()],
tracesSampleRate: 1,
sendDefaultPii: true,
});
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as Sentry from '@sentry/browser';
import { HttpClient } from '@sentry/integrations';
import { httpClientIntegration } from '@sentry/integrations';

window.Sentry = Sentry;

Sentry.init({
dsn: 'https://[email protected]/1337',
integrations: [new HttpClient()],
integrations: [httpClientIntegration()],
tracesSampleRate: 1,
sendDefaultPii: true,
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as Integrations from '@sentry/integrations';
import { httpClientIntegration } from '@sentry/integrations';
import * as Sentry from '@sentry/node';
import '@sentry/tracing';
import express from 'express';
Expand All @@ -13,7 +13,7 @@ Sentry.init({
environment: 'qa', // dynamic sampling bias to keep transactions
dsn: process.env.E2E_TEST_DSN,
includeLocalVariables: true,
integrations: [new Integrations.HttpClient()],
integrations: [httpClientIntegration()],
debug: true,
tunnel: `http://localhost:3031/`, // proxy server
tracesSampleRate: 1,
Expand Down
1 change: 0 additions & 1 deletion packages/browser/test/integration/common/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ var dsn =
function initSDK() {
Sentry.init({
dsn: dsn,
integrations: [new Sentry.Integrations.Dedupe()],
attachStacktrace: true,
ignoreErrors: ['ignoreErrorTest'],
denyUrls: ['foo.js'],
Expand Down
2 changes: 0 additions & 2 deletions packages/browser/test/package/test-code.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
/* eslint-disable no-console */
const Sentry = require('../../build/npm/cjs/index.js');
const Integrations = require('../../../integrations/build/npm/cjs/dedupe.js');

// Init
Sentry.init({
dsn: 'https://[email protected]/42',
integrations: [new Integrations.Dedupe()],
beforeSend(_event) {
console.log('Got an event');
return null;
Expand Down
22 changes: 3 additions & 19 deletions packages/integrations/src/captureconsole.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import {
captureException,
captureMessage,
convertIntegrationFnToClass,
defineIntegration,
getClient,
withScope,
} from '@sentry/core';
import type { CaptureContext, Client, Integration, IntegrationClass, IntegrationFn } from '@sentry/types';
import { captureException, captureMessage, defineIntegration, getClient, withScope } from '@sentry/core';
import type { CaptureContext, IntegrationFn } from '@sentry/types';
import {
CONSOLE_LEVELS,
GLOBAL_OBJ,
Expand Down Expand Up @@ -45,19 +38,10 @@ const _captureConsoleIntegration = ((options: CaptureConsoleOptions = {}) => {
};
}) satisfies IntegrationFn;

export const captureConsoleIntegration = defineIntegration(_captureConsoleIntegration);

/**
* Send Console API calls as Sentry Events.
* @deprecated Use `captureConsoleIntegration()` instead.
*/
// eslint-disable-next-line deprecation/deprecation
export const CaptureConsole = convertIntegrationFnToClass(
INTEGRATION_NAME,
captureConsoleIntegration,
) as IntegrationClass<Integration & { setup: (client: Client) => void }> & {
new (options?: { levels?: string[] }): Integration;
};
export const captureConsoleIntegration = defineIntegration(_captureConsoleIntegration);

function consoleHandler(args: unknown[], level: string): void {
const captureContext: CaptureContext = {
Expand Down
13 changes: 3 additions & 10 deletions packages/integrations/src/contextlines.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { convertIntegrationFnToClass, defineIntegration } from '@sentry/core';
import type { Event, Integration, IntegrationClass, IntegrationFn, StackFrame } from '@sentry/types';
import { defineIntegration } from '@sentry/core';
import type { Event, IntegrationFn, StackFrame } from '@sentry/types';
import { GLOBAL_OBJ, addContextToFrame, stripUrlQueryAndFragment } from '@sentry/utils';

const WINDOW = GLOBAL_OBJ as typeof GLOBAL_OBJ & Window;
Expand Down Expand Up @@ -31,8 +31,6 @@ const _contextLinesIntegration = ((options: ContextLinesOptions = {}) => {
};
}) satisfies IntegrationFn;

export const contextLinesIntegration = defineIntegration(_contextLinesIntegration);

/**
* Collects source context lines around the lines of stackframes pointing to JS embedded in
* the current page's HTML.
Expand All @@ -43,13 +41,8 @@ export const contextLinesIntegration = defineIntegration(_contextLinesIntegratio
*
* Use this integration if you have inline JS code in HTML pages that can't be accessed
* by our backend (e.g. due to a login-protected page).
*
* @deprecated Use `contextLinesIntegration()` instead.
*/
// eslint-disable-next-line deprecation/deprecation
export const ContextLines = convertIntegrationFnToClass(INTEGRATION_NAME, contextLinesIntegration) as IntegrationClass<
Integration & { processEvent: (event: Event) => Event }
> & { new (options?: { frameContextLines?: number }): Integration };
export const contextLinesIntegration = defineIntegration(_contextLinesIntegration);

/**
* Processes an event and adds context lines.
Expand Down
24 changes: 6 additions & 18 deletions packages/integrations/src/debug.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { convertIntegrationFnToClass, defineIntegration } from '@sentry/core';
import type { Client, Event, EventHint, Integration, IntegrationClass, IntegrationFn } from '@sentry/types';
import { defineIntegration } from '@sentry/core';
import type { Event, EventHint, IntegrationFn } from '@sentry/types';
import { consoleSandbox } from '@sentry/utils';

const INTEGRATION_NAME = 'Debug';
Expand All @@ -11,6 +11,10 @@ interface DebugOptions {
debugger?: boolean;
}

/**
* Integration to debug sent Sentry events.
* This integration should not be used in production.
*/
const _debugIntegration = ((options: DebugOptions = {}) => {
const _options = {
debugger: false,
Expand Down Expand Up @@ -50,19 +54,3 @@ const _debugIntegration = ((options: DebugOptions = {}) => {
}) satisfies IntegrationFn;

export const debugIntegration = defineIntegration(_debugIntegration);

/**
* Integration to debug sent Sentry events.
* This integration should not be used in production.
*
* @deprecated Use `debugIntegration()` instead.
*/
// eslint-disable-next-line deprecation/deprecation
export const Debug = convertIntegrationFnToClass(INTEGRATION_NAME, debugIntegration) as IntegrationClass<
Integration & { setup: (client: Client) => void }
> & {
new (options?: {
stringify?: boolean;
debugger?: boolean;
}): Integration;
};
12 changes: 3 additions & 9 deletions packages/integrations/src/dedupe.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { convertIntegrationFnToClass, defineIntegration } from '@sentry/core';
import type { Event, Exception, Integration, IntegrationClass, IntegrationFn, StackFrame } from '@sentry/types';
import { defineIntegration } from '@sentry/core';
import type { Event, Exception, IntegrationFn, StackFrame } from '@sentry/types';
import { logger } from '@sentry/utils';

import { DEBUG_BUILD } from './debug-build';
Expand Down Expand Up @@ -33,16 +33,10 @@ const _dedupeIntegration = (() => {
};
}) 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 }
>;
export const dedupeIntegration = defineIntegration(_dedupeIntegration);

/** only exported for tests. */
export function _shouldDropEvent(currentEvent: Event, previousEvent?: Event): boolean {
Expand Down
40 changes: 7 additions & 33 deletions packages/integrations/src/extraerrordata.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
import { convertIntegrationFnToClass, defineIntegration } from '@sentry/core';
import type {
Contexts,
Event,
EventHint,
ExtendedError,
Integration,
IntegrationClass,
IntegrationFn,
} from '@sentry/types';
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 { DEBUG_BUILD } from './debug-build';
Expand All @@ -21,19 +13,18 @@ interface ExtraErrorDataOptions {
depth: number;

/**
* Whether to capture error causes.
* Whether to capture error causes. Defaults to true.
*
* More information: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause
*/
captureErrorCause: boolean;
}

/**
* Extract additional data for from original exceptions.
*/
const _extraErrorDataIntegration = ((options: Partial<ExtraErrorDataOptions> = {}) => {
const depth = options.depth || 3;

// TODO(v8): Flip the default for this option to true
const captureErrorCause = options.captureErrorCause || false;

const { depth = 3, captureErrorCause = true } = options;
return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
Expand All @@ -46,23 +37,6 @@ const _extraErrorDataIntegration = ((options: Partial<ExtraErrorDataOptions> = {

export const extraErrorDataIntegration = defineIntegration(_extraErrorDataIntegration);

/**
* Extract additional data for from original exceptions.
* @deprecated Use `extraErrorDataIntegration()` instead.
*/
// eslint-disable-next-line deprecation/deprecation
export const ExtraErrorData = convertIntegrationFnToClass(
INTEGRATION_NAME,
extraErrorDataIntegration,
) as IntegrationClass<Integration & { processEvent: (event: Event, hint: EventHint) => Event }> & {
new (
options?: Partial<{
depth: number;
captureErrorCause: boolean;
}>,
): Integration;
};

function _enhanceEventWithErrorData(
event: Event,
hint: EventHint = {},
Expand Down
30 changes: 3 additions & 27 deletions packages/integrations/src/httpclient.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
import {
captureEvent,
convertIntegrationFnToClass,
defineIntegration,
getClient,
isSentryRequestUrl,
} from '@sentry/core';
import type {
Client,
Event as SentryEvent,
Integration,
IntegrationClass,
IntegrationFn,
SentryWrappedXMLHttpRequest,
} from '@sentry/types';
import { captureEvent, defineIntegration, getClient, isSentryRequestUrl } from '@sentry/core';
import type { Client, Event as SentryEvent, IntegrationFn, SentryWrappedXMLHttpRequest } from '@sentry/types';
import {
GLOBAL_OBJ,
SENTRY_XHR_DATA_KEY,
Expand Down Expand Up @@ -69,21 +56,10 @@ const _httpClientIntegration = ((options: Partial<HttpClientOptions> = {}) => {
};
}) satisfies IntegrationFn;

export const httpClientIntegration = defineIntegration(_httpClientIntegration);

/**
* Create events for failed client side HTTP requests.
* @deprecated Use `httpClientIntegration()` instead.
*/
// eslint-disable-next-line deprecation/deprecation
export const HttpClient = convertIntegrationFnToClass(INTEGRATION_NAME, httpClientIntegration) as IntegrationClass<
Integration & { setup: (client: Client) => void }
> & {
new (options?: {
failedRequestStatusCodes: HttpStatusCodeRange[];
failedRequestTargets: HttpRequestTarget[];
}): Integration;
};
export const httpClientIntegration = defineIntegration(_httpClientIntegration);

/**
* Interceptor function for fetch requests
Expand Down
20 changes: 9 additions & 11 deletions packages/integrations/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
/* eslint-disable deprecation/deprecation */
export { CaptureConsole, captureConsoleIntegration } from './captureconsole';
export { Debug, debugIntegration } from './debug';
export { Dedupe, dedupeIntegration } from './dedupe';
export { ExtraErrorData, extraErrorDataIntegration } from './extraerrordata';
export { ReportingObserver, reportingObserverIntegration } from './reportingobserver';
export { RewriteFrames, rewriteFramesIntegration } from './rewriteframes';
export { SessionTiming, sessionTimingIntegration } from './sessiontiming';
export { Transaction } from './transaction';
export { HttpClient, httpClientIntegration } from './httpclient';
export { ContextLines, contextLinesIntegration } from './contextlines';
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';
17 changes: 3 additions & 14 deletions packages/integrations/src/reportingobserver.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { captureMessage, convertIntegrationFnToClass, defineIntegration, getClient, withScope } from '@sentry/core';
import type { Client, Integration, IntegrationClass, IntegrationFn } from '@sentry/types';
import { captureMessage, defineIntegration, getClient, withScope } from '@sentry/core';
import type { Client, IntegrationFn } from '@sentry/types';
import { GLOBAL_OBJ, supportsReportingObserver } from '@sentry/utils';

const WINDOW = GLOBAL_OBJ as typeof GLOBAL_OBJ & Window;
Expand Down Expand Up @@ -115,18 +115,7 @@ const _reportingObserverIntegration = ((options: ReportingObserverOptions = {})
};
}) satisfies IntegrationFn;

export const reportingObserverIntegration = defineIntegration(_reportingObserverIntegration);

/**
* Reporting API integration - https://w3c.github.io/reporting/
* @deprecated Use `reportingObserverIntegration()` instead.
*/
// eslint-disable-next-line deprecation/deprecation
export const ReportingObserver = convertIntegrationFnToClass(
INTEGRATION_NAME,
reportingObserverIntegration,
) as IntegrationClass<Integration & { setup: (client: Client) => void }> & {
new (options?: {
types?: ReportTypes[];
}): Integration;
};
export const reportingObserverIntegration = defineIntegration(_reportingObserverIntegration);
Loading