diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 75efa8b163ff..15dd3e6862d1 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -65,8 +65,6 @@ export { getIntegrationsToSetup, addIntegration, defineIntegration, - // eslint-disable-next-line deprecation/deprecation - convertIntegrationFnToClass, } from './integration'; export { applyScopeDataToEvent, mergeScopeData } from './utils/applyScopeDataToEvent'; export { prepareEvent } from './utils/prepareEvent'; diff --git a/packages/core/src/integration.ts b/packages/core/src/integration.ts index 237a086b92bb..c5f9499f342e 100644 --- a/packages/core/src/integration.ts +++ b/packages/core/src/integration.ts @@ -1,4 +1,4 @@ -import type { Client, Event, EventHint, Integration, IntegrationClass, IntegrationFn, Options } from '@sentry/types'; +import type { Client, Event, EventHint, Integration, IntegrationFn, Options } from '@sentry/types'; import { arrayify, logger } from '@sentry/utils'; import { getClient } from './currentScopes'; @@ -169,24 +169,6 @@ function findIndex(arr: T[], callback: (item: T) => boolean): number { return -1; } -/** - * Convert a new integration function to the legacy class syntax. - * In v8, we can remove this and instead export the integration functions directly. - * - * @deprecated This will be removed in v8! - */ -export function convertIntegrationFnToClass( - name: string, - fn: Fn, -): IntegrationClass { - return Object.assign( - function ConvertedIntegration(...args: Parameters): Integration { - return fn(...args); - }, - { id: name }, - ) as unknown as IntegrationClass; -} - /** * Define an integration function that can be used to create an integration instance. * Note that this by design hides the implementation details of the integration, as they are considered internal. diff --git a/packages/core/test/lib/integration.test.ts b/packages/core/test/lib/integration.test.ts index 46c7eba84e34..d190d5b32dab 100644 --- a/packages/core/test/lib/integration.test.ts +++ b/packages/core/test/lib/integration.test.ts @@ -2,13 +2,7 @@ import type { Integration, Options } from '@sentry/types'; import { logger } from '@sentry/utils'; import { getCurrentScope } from '../../src/currentScopes'; -import { - addIntegration, - convertIntegrationFnToClass, - getIntegrationsToSetup, - installedIntegrations, - setupIntegration, -} from '../../src/integration'; +import { addIntegration, getIntegrationsToSetup, installedIntegrations, setupIntegration } from '../../src/integration'; import { setCurrentClient } from '../../src/sdk'; import { TestClient, getDefaultTestClientOptions } from '../mocks/client'; @@ -699,74 +693,3 @@ describe('addIntegration', () => { expect(logs).toHaveBeenCalledWith('Integration skipped because it was already installed: test'); }); }); - -describe('convertIntegrationFnToClass', () => { - /* eslint-disable deprecation/deprecation */ - it('works with a minimal integration', () => { - const integrationFn = () => ({ - name: 'testName', - setupOnce: () => {}, - }); - - const IntegrationClass = convertIntegrationFnToClass('testName', integrationFn); - - expect(IntegrationClass.id).toBe('testName'); - - const integration = new IntegrationClass(); - expect(integration).toEqual({ - name: 'testName', - setupOnce: expect.any(Function), - }); - }); - - it('works with options', () => { - const integrationFn = (_options: { num: number }) => ({ - name: 'testName', - setupOnce: () => {}, - }); - - const IntegrationClass = convertIntegrationFnToClass('testName', integrationFn); - - expect(IntegrationClass.id).toBe('testName'); - - // not type safe options by default :( - new IntegrationClass(); - - const integration = new IntegrationClass({ num: 3 }); - expect(integration).toEqual({ - name: 'testName', - setupOnce: expect.any(Function), - }); - }); - - it('works with integration hooks', () => { - const setup = jest.fn(); - const setupOnce = jest.fn(); - const processEvent = jest.fn(); - const preprocessEvent = jest.fn(); - - const integrationFn = () => { - return { - name: 'testName', - setup, - setupOnce, - processEvent, - preprocessEvent, - }; - }; - - const IntegrationClass = convertIntegrationFnToClass('testName', integrationFn); - - expect(IntegrationClass.id).toBe('testName'); - - const integration = new IntegrationClass(); - expect(integration).toEqual({ - name: 'testName', - setupOnce, - setup, - processEvent, - preprocessEvent, - }); - }); - /* eslint-enable deprecation/deprecation */ -});