Skip to content

feat(v8/core): Remove deprecated integration classes #11132

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 3 commits into from
Mar 18, 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: 0 additions & 2 deletions packages/browser/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ export {
getSpanStatusFromHttpCode,
setHttpStatus,
makeMultiplexedTransport,
// eslint-disable-next-line deprecation/deprecation
ModuleMetadata,
moduleMetadataIntegration,
} from '@sentry/core';
export type { Span } from '@sentry/types';
Expand Down
3 changes: 0 additions & 3 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ export {
} from './utils/spanUtils';
export { applySdkMetadata } from './utils/sdkMetadata';
export { DEFAULT_ENVIRONMENT } from './constants';
/* eslint-disable deprecation/deprecation */
export { ModuleMetadata } from './integrations/metadata';
export { RequestData } from './integrations/requestdata';
export { addBreadcrumb } from './breadcrumbs';
export { functionToStringIntegration } from './integrations/functiontostring';
export { inboundFiltersIntegration } from './integrations/inboundfilters';
Expand Down
18 changes: 2 additions & 16 deletions packages/core/src/integrations/functiontostring.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Client, Integration, IntegrationClass, IntegrationFn, WrappedFunction } from '@sentry/types';
import type { Client, IntegrationFn, WrappedFunction } from '@sentry/types';
import { getOriginalFunction } from '@sentry/utils';
import { getClient } from '../currentScopes';
import { convertIntegrationFnToClass, defineIntegration } from '../integration';
import { defineIntegration } from '../integration';

let originalFunctionToString: () => void;

Expand Down Expand Up @@ -48,17 +48,3 @@ const _functionToStringIntegration = (() => {
* ```
*/
export const functionToStringIntegration = defineIntegration(_functionToStringIntegration);

/**
* Patch toString calls to return proper name for wrapped functions.
*
* @deprecated Use `functionToStringIntegration()` instead.
*/
// eslint-disable-next-line deprecation/deprecation
export const FunctionToString = convertIntegrationFnToClass(
INTEGRATION_NAME,
functionToStringIntegration,
) as IntegrationClass<Integration & { setupOnce: () => void }>;

// eslint-disable-next-line deprecation/deprecation
export type FunctionToString = typeof FunctionToString;
19 changes: 3 additions & 16 deletions packages/core/src/integrations/metadata.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Client, Event, EventHint, EventItem, Integration, IntegrationClass, IntegrationFn } from '@sentry/types';
import type { EventItem, IntegrationFn } from '@sentry/types';
import { forEachEnvelopeItem } from '@sentry/utils';
import { convertIntegrationFnToClass, defineIntegration } from '../integration';
import { defineIntegration } from '../integration';

import { addMetadataToStackFrames, stripMetadataFromStackFrames } from '../metadata';

Expand Down Expand Up @@ -33,8 +33,6 @@ const _moduleMetadataIntegration = (() => {
};
}) satisfies IntegrationFn;

export const moduleMetadataIntegration = defineIntegration(_moduleMetadataIntegration);

/**
* Adds module metadata to stack frames.
*
Expand All @@ -43,16 +41,5 @@ export const moduleMetadataIntegration = defineIntegration(_moduleMetadataIntegr
* When this integration is added, the metadata passed to the bundler plugin is added to the stack frames of all events
* under the `module_metadata` property. This can be used to help in tagging or routing of events from different teams
* our sources
*
* @deprecated Use `moduleMetadataIntegration()` instead.
*/
// eslint-disable-next-line deprecation/deprecation
export const ModuleMetadata = convertIntegrationFnToClass(
INTEGRATION_NAME,
moduleMetadataIntegration,
) as IntegrationClass<
Integration & {
setup: (client: Client) => void;
processEvent: (event: Event, hint: EventHint, client: Client) => Event;
}
>;
export const moduleMetadataIntegration = defineIntegration(_moduleMetadataIntegration);
44 changes: 3 additions & 41 deletions packages/core/src/integrations/requestdata.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import type {
Client,
Event,
EventHint,
Integration,
IntegrationClass,
IntegrationFn,
Transaction,
} from '@sentry/types';
import type { Client, IntegrationFn, Transaction } from '@sentry/types';
import type { AddRequestDataToEventOptions, TransactionNamingScheme } from '@sentry/utils';
import { addRequestDataToEvent, extractPathForTransaction } from '@sentry/utils';
import { convertIntegrationFnToClass, defineIntegration } from '../integration';
import { defineIntegration } from '../integration';
import { spanToJSON } from '../utils/spanUtils';

export type RequestDataIntegrationOptions = {
Expand Down Expand Up @@ -127,41 +119,11 @@ const _requestDataIntegration = ((options: RequestDataIntegrationOptions = {}) =
};
}) satisfies IntegrationFn;

export const requestDataIntegration = defineIntegration(_requestDataIntegration);

/**
* 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.
*/
// eslint-disable-next-line deprecation/deprecation
export const RequestData = convertIntegrationFnToClass(INTEGRATION_NAME, requestDataIntegration) as IntegrationClass<
Integration & { processEvent: (event: Event, hint: EventHint, client: Client) => Event }
> & {
new (options?: {
/**
* Controls what data is pulled from the request and added to the event
*/
include?: {
cookies?: boolean;
data?: boolean;
headers?: boolean;
ip?: boolean;
query_string?: boolean;
url?: boolean;
user?:
| boolean
| {
id?: boolean;
username?: boolean;
email?: boolean;
};
};

/** Whether to identify transactions by parameterized path, parameterized path with method, or handler name */
transactionNamingScheme?: TransactionNamingScheme;
}): Integration;
};
export const requestDataIntegration = defineIntegration(_requestDataIntegration);

/** Convert this integration's options to match what `addRequestDataToEvent` expects */
/** TODO: Can possibly be deleted once https://github.com/getsentry/sentry-javascript/issues/5718 is fixed */
Expand Down
5 changes: 2 additions & 3 deletions packages/core/test/lib/integrations/metadata.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Event } from '@sentry/types';
import { GLOBAL_OBJ, createStackParser, nodeStackLineParser, parseEnvelope } from '@sentry/utils';

import { ModuleMetadata, captureException, createTransport, setCurrentClient } from '../../../src';
import { captureException, createTransport, moduleMetadataIntegration, setCurrentClient } from '../../../src';
import { TestClient, getDefaultTestClientOptions } from '../../mocks/client';

const stackParser = createStackParser(nodeStackLineParser());
Expand All @@ -26,8 +26,7 @@ describe('ModuleMetadata integration', () => {
dsn: 'https://username@domain/123',
enableSend: true,
stackParser,
// eslint-disable-next-line deprecation/deprecation
integrations: [new ModuleMetadata()],
integrations: [moduleMetadataIntegration()],
beforeSend: (event, _hint) => {
// copy the frames since reverse in in-place
const lastFrame = [...(event.exception?.values?.[0].stacktrace?.frames || [])].reverse()[0];
Expand Down
7 changes: 3 additions & 4 deletions packages/core/test/lib/integrations/requestdata.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { IncomingMessage } from 'http';
import type { Event, EventProcessor } from '@sentry/types';
import * as sentryUtils from '@sentry/utils';
import type { RequestDataIntegrationOptions } from '../../../src';
import { RequestData, setCurrentClient } from '../../../src';
import { requestDataIntegration, setCurrentClient } from '../../../src';

import { TestClient, getDefaultTestClientOptions } from '../../mocks/client';

Expand All @@ -16,15 +16,14 @@ const path = '/by/the/trees/';
const queryString = 'chase=me&please=thankyou';

function initWithRequestDataIntegrationOptions(integrationOptions: RequestDataIntegrationOptions): EventProcessor {
// eslint-disable-next-line deprecation/deprecation
const requestDataIntegration = new RequestData({
const integration = requestDataIntegration({
...integrationOptions,
});

const client = new TestClient(
getDefaultTestClientOptions({
dsn: 'https://dogsarebadatkeepingsecrets@squirrelchasers.ingest.sentry.io/12312012',
integrations: [requestDataIntegration],
integrations: [integration],
}),
);

Expand Down
1 change: 0 additions & 1 deletion packages/node/src/integrations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export { OnUncaughtException } from './onuncaughtexception';
export { OnUnhandledRejection } from './onunhandledrejection';
export { Modules } from './modules';
export { Context } from './context';
export { RequestData } from '@sentry/core';
export { Undici } from './undici';
export { Spotlight } from './spotlight';
export { Hapi } from './hapi';