portainer/app/react/hooks/useAnalytics.ts

17 lines
464 B
TypeScript
Raw Normal View History

import { trackEvent } from '@/angulartics.matomo/analytics-services';
import { usePublicSettings } from '@/react/portainer/settings/queries';
export function useAnalytics() {
const telemetryQuery = usePublicSettings({
select: (settings) => settings.EnableTelemetry,
});
return { trackEvent: handleTrackEvent };
function handleTrackEvent(...args: Parameters<typeof trackEvent>) {
if (telemetryQuery.data) {
trackEvent(...args);
}
}
}