import type { Event } from "src/analytics/types";
import { useConfig } from "./useConfig";

export const useLogEvent = () => {
	const { eventHandlers } = useConfig();

	const logEvent = (event: Event, context?: Record<string, unknown>) => {
		if (eventHandlers?.logEvent) {
			eventHandlers.logEvent({ error: null, context, event });
		}
	};

	return {
		logEvent,
	};
};
