diff --git a/api/event.js b/api/event.js index 94bc7ddb..88bc2543 100644 --- a/api/event.js +++ b/api/event.js @@ -3,7 +3,6 @@ import { getStore } from '@netlify/blobs'; export default async (request, context) => { const ns = new URL(request['url']).searchParams.get('ns') - const id = crypto.createHash('md5').update(`${context['ip']}${context['geo']['city']}`).digest('hex'); const page = new URL(request['url']).searchParams.get('page') const num = new URL(request['url']).searchParams.get('num') const lang = decodeURIComponent(new URL(request['url']).searchParams.get('lang')) @@ -16,10 +15,11 @@ export default async (request, context) => { if (ig) return; if (ns) { + const id = crypto.createHash('md5').update(`${context['ip']}${context['geo']['city']}`).digest('hex'); const ids = getStore('ids') if (!ids.get(id)) ids.set(id, '') - const id = ids.get(id) - url = `https://cdn.usefathom.com/?h=${encodeURIComponent(page)}&sid=CWSVCDJC&cid=${id}` + const idVal = ids.get(id) + url = `https://cdn.usefathom.com/?h=${encodeURIComponent(page)}&sid=CWSVCDJC&cid=${idVal}` } else { url = `https://cdn.usefathom.com/?h=${encodeURIComponent(page)}&sid=CWSVCDJC&cid=${num}` }