mirror of
https://github.com/imezx/Warp.git
synced 2025-04-24 15:10:03 +00:00
17 lines
563 B
TypeScript
17 lines
563 B
TypeScript
import type AlgoliaAnalytics from "./insights";
|
|
import type { InsightsClient } from "./types";
|
|
import { isFunction } from "./utils";
|
|
|
|
export function getFunctionalInterface(
|
|
instance: AlgoliaAnalytics
|
|
): InsightsClient {
|
|
return (functionName, ...functionArguments) => {
|
|
if (functionName && isFunction((instance as any)[functionName])) {
|
|
// @ts-expect-error
|
|
instance[functionName](...functionArguments);
|
|
} else {
|
|
// eslint-disable-next-line no-console
|
|
console.warn(`The method \`${functionName}\` doesn't exist.`);
|
|
}
|
|
};
|
|
}
|