UNPKG

@robotical/appv2-analytics-gatherer

Version:

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

23 lines (22 loc) 902 B
import Logger from "../services/Logger"; import Transport from "../transport/server"; import { ServerEndpoints } from "../types/types"; const SHOW_LOGS = true; const TAG = 'core/sessions'; export const startSession = async (sessionId, deviceId, robotId, raftType) => { Logger.info(SHOW_LOGS, TAG, `Starting session with id: ${sessionId}`); try { const data = { sessionId, deviceId, robotId, raftType }; const response = await Transport.post(ServerEndpoints.START_SESSION, data); if (!response.ok) { const errorText = await response.text(); throw new Error(`Error response from server: ${errorText}`); } Logger.info(SHOW_LOGS, TAG, `Session started successfully: ${sessionId}`); return true; } catch (error) { Logger.error(SHOW_LOGS, TAG, `Error starting session: ${error}`); return false; } };