1 import { useEffect } from 'react';
3 import metrics from '@proton/metrics';
5 addIPCHostUpdateListener,
6 canListenInboxDesktopHostMessages,
7 hasInboxDesktopFeature,
9 } from '@proton/shared/lib/desktop/ipcHelpers';
11 export const useInboxDesktopMetrics = () => {
13 if (!canListenInboxDesktopHostMessages || !hasInboxDesktopFeature('HeartbeatMetrics')) {
17 const metricsListener = addIPCHostUpdateListener('sentHeartbeatMetrics', (payload) => {
18 metrics.desktop_inbox_heartbeat_total.increment(payload.Labels);
21 invokeInboxDesktopIPC({ type: 'metricsListenerChanged', payload: 'ready' });
24 invokeInboxDesktopIPC({ type: 'metricsListenerChanged', payload: 'removed' });
25 metricsListener.removeListener();