Skip to content

Commit 2a64201

Browse files
committed
avoid unncessary function
1 parent c5c8d82 commit 2a64201

File tree

4 files changed

+7
-82
lines changed

4 files changed

+7
-82
lines changed

packages/core/src/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ export {
5959
addIntegration,
6060
// eslint-disable-next-line deprecation/deprecation
6161
convertIntegrationFnToClass,
62-
makeIntegrationFn,
6362
} from './integration';
6463
export { FunctionToString, InboundFilters, LinkedErrors } from './integrations';
6564
export { prepareEvent } from './utils/prepareEvent';

packages/core/src/integration.ts

-10
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import type {
55
Integration,
66
IntegrationClass,
77
IntegrationFn,
8-
IntegrationFnResult,
98
Options,
109
} from '@sentry/types';
1110
import { arrayify, logger } from '@sentry/utils';
@@ -165,15 +164,6 @@ function findIndex<T>(arr: T[], callback: (item: T) => boolean): number {
165164
return -1;
166165
}
167166

168-
/**
169-
* Generate a full integration function from a simple function.
170-
* This will ensure to add the given name both to the function definition (as id),
171-
* as well as to the integration return value.
172-
*/
173-
export function makeIntegrationFn<Fn extends IntegrationFn>(fn: Fn): Fn {
174-
return fn;
175-
}
176-
177167
/**
178168
* Convert a new integration function to the legacy class syntax.
179169
* In v8, we can remove this and instead export the integration functions directly.

packages/core/src/integrations/inboundfilters.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import type { Client, Event, EventHint, Integration, StackFrame } from '@sentry/types';
1+
import type { Client, Event, EventHint, Integration, IntegrationFn, StackFrame } from '@sentry/types';
22
import { getEventDescription, logger, stringMatchesSomePattern } from '@sentry/utils';
33

44
import { DEBUG_BUILD } from '../debug-build';
5-
import { convertIntegrationFnToClass, makeIntegrationFn } from '../integration';
5+
import { convertIntegrationFnToClass } from '../integration';
66

77
// "Script error." is hard coded into browsers for errors that it can't read.
88
// this is the result of a script being pulled in from an external domain and CORS.
@@ -30,7 +30,7 @@ export interface InboundFiltersOptions {
3030
}
3131

3232
const INTEGRATION_NAME = 'InboundFilters';
33-
const inboundFiltersIntegration = makeIntegrationFn((options: Partial<InboundFiltersOptions>) => {
33+
const inboundFiltersIntegration: IntegrationFn = (options: Partial<InboundFiltersOptions>) => {
3434
return {
3535
name: INTEGRATION_NAME,
3636
processEvent(event, _hint, client) {
@@ -39,7 +39,7 @@ const inboundFiltersIntegration = makeIntegrationFn((options: Partial<InboundFil
3939
return _shouldDropEvent(event, mergedOptions) ? null : event;
4040
},
4141
};
42-
});
42+
}
4343

4444
/** Inbound filters configurable by the user */
4545
// eslint-disable-next-line deprecation/deprecation

packages/core/test/lib/integration.test.ts

+3-67
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
convertIntegrationFnToClass,
88
getIntegrationsToSetup,
99
installedIntegrations,
10-
makeIntegrationFn,
1110
setupIntegration,
1211
} from '../../src/integration';
1312
import { TestClient, getDefaultTestClientOptions } from '../mocks/client';
@@ -655,75 +654,12 @@ describe('addIntegration', () => {
655654
});
656655
});
657656

658-
describe('makeIntegrationFn', () => {
659-
it('works with a minimal integration', () => {
660-
const myIntegration = makeIntegrationFn(() => {
661-
return {
662-
name: 'testName'
663-
};
664-
});
665-
666-
const integration = myIntegration();
667-
expect(integration).toEqual({
668-
name: 'testName',
669-
});
670-
671-
// @ts-expect-error This SHOULD error
672-
myIntegration({});
673-
});
674-
675-
it('works with integration options', () => {
676-
const myIntegration = makeIntegrationFn((_options: { xxx: string }) => {
677-
return {
678-
name: 'testName'
679-
};
680-
});
681-
682-
const integration = myIntegration({ xxx: 'aa' });
683-
expect(integration).toEqual({
684-
name: 'testName',
685-
});
686-
687-
// @ts-expect-error This SHOULD error
688-
myIntegration();
689-
// @ts-expect-error This SHOULD error
690-
myIntegration({});
691-
});
692-
693-
it('works with integration hooks', () => {
694-
const setup = jest.fn();
695-
const setupOnce = jest.fn();
696-
const processEvent = jest.fn();
697-
const preprocessEvent = jest.fn();
698657

699-
const myIntegration = makeIntegrationFn(() => {
700-
return {
701-
name: 'testName',
702-
setup,
703-
setupOnce,
704-
processEvent,
705-
preprocessEvent,
706-
};
707-
});
708-
709-
const integration = myIntegration();
710-
expect(integration).toEqual({
711-
name: 'testName',
712-
setup,
713-
setupOnce,
714-
processEvent,
715-
preprocessEvent,
716-
});
717-
718-
// @ts-expect-error This SHOULD error
719-
makeIntegrationFn('testName', () => ({ other: 'aha' }));
720-
});
721-
});
722658

723659
describe('convertIntegrationFnToClass', () => {
724660
/* eslint-disable deprecation/deprecation */
725661
it('works with a minimal integration', () => {
726-
const integrationFn = makeIntegrationFn(() => ({ name: 'testName'}));
662+
const integrationFn = () => ({ name: 'testName'});
727663

728664
const IntegrationClass = convertIntegrationFnToClass('testName', integrationFn);
729665

@@ -742,15 +678,15 @@ describe('convertIntegrationFnToClass', () => {
742678
const processEvent = jest.fn();
743679
const preprocessEvent = jest.fn();
744680

745-
const integrationFn = makeIntegrationFn( () => {
681+
const integrationFn = () => {
746682
return {
747683
name: 'testName',
748684
setup,
749685
setupOnce,
750686
processEvent,
751687
preprocessEvent,
752688
};
753-
});
689+
};
754690

755691
const IntegrationClass = convertIntegrationFnToClass('testName', integrationFn);
756692

0 commit comments

Comments
 (0)