UNPKG

@robotical/appv2-analytics-gatherer

Version:

A tool that gathers data from the Apps and sends it to the Analytics server

20 lines (19 loc) 641 B
import Logger from "../services/Logger"; import Transport from "../transport/server"; import { ServerEndpoints } from "../types/types"; const SHOW_LOGS = true; const TAG = 'core/heartbeat'; export const sendHeartbeat = async (data) => { try { const response = await Transport.post(ServerEndpoints.HEARTBEAT, data); if (!response.ok) { const errorText = await response.text(); throw new Error(`Error response from server: ${errorText}`); } return true; } catch (error) { Logger.error(SHOW_LOGS, TAG, 'Failed to track consent', error); return false; } };