From e1cd7a7663b264817249843e87c07f45a53f2321 Mon Sep 17 00:00:00 2001 From: Cory Dransfeldt Date: Sun, 24 Mar 2024 15:37:13 -0700 Subject: [PATCH] chore: eventing --- api/event.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/api/event.js b/api/event.js index 85139d90..63c57a0e 100644 --- a/api/event.js +++ b/api/event.js @@ -3,6 +3,7 @@ import { getStore } from '@netlify/blobs'; export default async (request, context) => { const FATHOM_KEY = Netlify.env.get("API_KEY_FATHOM_EVENTING") + const FATHOM_EVENT_URL = 'https://api.usefathom.com/v1/sites/CWSVCDJC/events/' const ns = new URL(request['url']).searchParams.get('ns') const page = new URL(request['url']).searchParams.get('page') const num = new URL(request['url']).searchParams.get('num') @@ -13,15 +14,6 @@ export default async (request, context) => { if (lang) headers['Accept-Language'] = lang; if (nav) headers['User-Agent'] = nav; let url; - const fathomEvent = async (event) => { - await fetch(`https://api.usefathom.com/v1/sites/CWSVCDJC/events/${event}`, { - headers: { - "Authorization": `Bearer ${FATHOM_KEY}` - }, - }) - .then((data) => console.log(data)) - .catch((err) => console.log(err)) - } if (ig) return; if (ns) { @@ -31,10 +23,10 @@ export default async (request, context) => { if (!userId) await ids.set(id, id) const idVal = await ids.get(id) url = `https://cdn.usefathom.com/?h=${encodeURIComponent(page)}&sid=CWSVCDJC&cid=${idVal}` - await fathomEvent(`no-script-visit-id: ${idVal}`) + fetch(`${FATHOM_EVENT_URL}no-script-visit-id-${idVal}`, { headers: { "Authorization": `Bearer ${FATHOM_KEY}` }}) } else { url = `https://cdn.usefathom.com/?h=${encodeURIComponent(page)}&sid=CWSVCDJC&cid=${num}` - await fathomEvent(`blocked-visit-id: ${num}`) + fetch(`${FATHOM_EVENT_URL}blocked-visit-id-${num}`, { headers: { "Authorization": `Bearer ${FATHOM_KEY}` }}) } fetch(url, { headers })