export async function sendViewedEvent( researchId: string, sessionId: string, identity?: string ) { // eslint-disable-next-line turbo/no-undeclared-env-vars await fetch(`${process.env.SAMELOGIC_URL}/api/events`, { method: "POST", headers: { Accept: "application/json", "Content-Type": "application/json", "Access-Control-Allow-Origin": "*", }, mode: "cors", body: JSON.stringify({ researchId: researchId, sessionId: sessionId, identity, event: "view", }), }); } export async function sendResponseEvent( researchId: string, sessionId: string, response: object, identity?: string ) { // eslint-disable-next-line turbo/no-undeclared-env-vars await fetch(`${process.env.SAMELOGIC_URL}/api/events`, { method: "POST", headers: { Accept: "application/json", "Content-Type": "application/json", "Access-Control-Allow-Origin": "*", }, mode: "cors", body: JSON.stringify({ researchId: researchId, sessionId: sessionId, identity, event: "response", response: response, }), }); } export async function sendCompletedEvent( researchId: string, sessionId: string, response: object, identity?: string ) { // eslint-disable-next-line turbo/no-undeclared-env-vars await fetch(`${process.env.SAMELOGIC_URL}/api/events`, { method: "POST", headers: { Accept: "application/json", "Content-Type": "application/json", "Access-Control-Allow-Origin": "*", }, mode: "cors", body: JSON.stringify({ researchId: researchId, sessionId: sessionId, identity, event: "complete", response: response, }), }); }