Skip to content

Commit a91624a

Browse files
committed
export it
1 parent ed7652c commit a91624a

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

packages/core/src/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,13 @@ export { createTransport } from './transports/base';
5454
export { makeOfflineTransport } from './transports/offline';
5555
export { makeMultiplexedTransport } from './transports/multiplexed';
5656
export { SDK_VERSION } from './version';
57-
export { getIntegrationsToSetup, addIntegration } from './integration';
57+
export {
58+
getIntegrationsToSetup,
59+
addIntegration,
60+
// eslint-disable-next-line deprecation/deprecation
61+
convertIntegrationFnToClass,
62+
makeIntegrationFn,
63+
} from './integration';
5864
export { FunctionToString, InboundFilters, LinkedErrors } from './integrations';
5965
export { prepareEvent } from './utils/prepareEvent';
6066
export { createCheckInEnvelope } from './checkin';

packages/core/src/integration.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,10 @@ function findIndex<T>(arr: T[], callback: (item: T) => boolean): number {
169169
* Generate a full integration function from a simple function.
170170
* This will ensure to add the given name both to the function definition, as well as to the integration return value.
171171
*/
172-
export function makeIntegrationFn<Fn extends (...rest: any[]) => Partial<IntegrationFnResult>>(
173-
name: string,
174-
fn: Fn,
175-
): ((...rest: Parameters<Fn>) => ReturnType<Fn> & { name: string }) & { id: string } {
172+
export function makeIntegrationFn<
173+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
174+
Fn extends (...rest: any[]) => Partial<IntegrationFnResult>,
175+
>(name: string, fn: Fn): ((...rest: Parameters<Fn>) => ReturnType<Fn> & { name: string }) & { id: string } {
176176
const patchedFn = addIdToIntegrationFnResult(name, fn);
177177

178178
return Object.assign(patchedFn, { id: name });
@@ -181,11 +181,15 @@ export function makeIntegrationFn<Fn extends (...rest: any[]) => Partial<Integra
181181
/**
182182
* Convert a new integration function to the legacy class syntax.
183183
* In v8, we can remove this and instead export the integration functions directly.
184+
*
185+
* @deprecated This will be removed in v8!
184186
*/
185-
export function convertIntegrationFnToClass<Fn extends IntegrationFn<(...rest: any[]) => IntegrationFnResult>>(
186-
fn: Fn,
187-
): IntegrationClass<Integration> {
187+
export function convertIntegrationFnToClass<
188+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
189+
Fn extends IntegrationFn<(...rest: any[]) => IntegrationFnResult>,
190+
>(fn: Fn): IntegrationClass<Integration> {
188191
return Object.assign(
192+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
189193
function ConvertedIntegration(...rest: any[]) {
190194
const res = {
191195
// eslint-disable-next-line @typescript-eslint/no-empty-function
@@ -200,10 +204,10 @@ export function convertIntegrationFnToClass<Fn extends IntegrationFn<(...rest: a
200204
) as unknown as IntegrationClass<Integration>;
201205
}
202206

203-
function addIdToIntegrationFnResult<Fn extends (...rest: any[]) => Partial<IntegrationFnResult>>(
204-
name: string,
205-
fn: Fn,
206-
): (...rest: Parameters<Fn>) => ReturnType<Fn> & { name: string } {
207+
function addIdToIntegrationFnResult<
208+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
209+
Fn extends (...rest: any[]) => Partial<IntegrationFnResult>,
210+
>(name: string, fn: Fn): (...rest: Parameters<Fn>) => ReturnType<Fn> & { name: string } {
207211
const patchedFn = (...rest: Parameters<Fn>): ReturnType<Fn> & { name: string } => {
208212
return { ...fn(...rest), name } as ReturnType<Fn> & { name: string };
209213
};

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,7 @@ describe('makeIntegrationFn', () => {
722722
});
723723

724724
describe('convertIntegrationFnToClass', () => {
725+
/* eslint-disable deprecation/deprecation */
725726
it('works with a minimal integration', () => {
726727
const integrationFn = makeIntegrationFn('testName', () => ({}));
727728

@@ -764,4 +765,5 @@ describe('convertIntegrationFnToClass', () => {
764765
preprocessEvent,
765766
});
766767
});
768+
/* eslint-enable deprecation/deprecation */
767769
});

0 commit comments

Comments
 (0)