From 9cfc82c077a7512ce9819e0a126ca861d735815f Mon Sep 17 00:00:00 2001 From: Cory Dransfeldt Date: Mon, 25 Mar 2024 10:25:21 -0700 Subject: [PATCH] fix: headers --- api/event.js | 3 ++- package.json | 2 +- src/_includes/base.liquid | 2 +- src/assets/scripts/index.js | 11 +++++------ 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/api/event.js b/api/event.js index 2e352978..4e6561b6 100644 --- a/api/event.js +++ b/api/event.js @@ -4,10 +4,11 @@ import { getStore } from '@netlify/blobs' export default async (request, context) => { const params = new URL(request['url']).searchParams const ns = params.get('ns') + const site = params.get('site') const page = params.get('page') const ignore = params.get('ignore') - const setUrl = (id, event) => `https://cdn.usefathom.com/?h=${encodeURIComponent(page)}&sid=CWSVCDJC&cid=${id}&name=${encodeURIComponent(event)}` + const setUrl = (id, event) => `https://cdn.usefathom.com/?h=${encodeURIComponent(site)}&p=${encodeURIComponent(page)}&sid=CWSVCDJC&cid=${id}&name=${encodeURIComponent(event)}` const lang = decodeURIComponent(params.get('lang')) const nav = decodeURIComponent(params.get('nav')) diff --git a/package.json b/package.json index bf02050b..b242893a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coryd.dev", - "version": "8.7.7", + "version": "8.7.8", "description": "The source for my personal site. Built using 11ty.", "type": "module", "scripts": { diff --git a/src/_includes/base.liquid b/src/_includes/base.liquid index 8a6859e9..2efc29eb 100644 --- a/src/_includes/base.liquid +++ b/src/_includes/base.liquid @@ -90,7 +90,7 @@ {% endif %} diff --git a/src/assets/scripts/index.js b/src/assets/scripts/index.js index bc252acb..42b1bf00 100644 --- a/src/assets/scripts/index.js +++ b/src/assets/scripts/index.js @@ -1,7 +1,6 @@ -let ignore; -let url = `https://coryd.dev/api/event/?site=${encodeURIComponent(window.location.origin)}&page=${encodeURIComponent(window.location.pathname)}&lang=${encodeURIComponent(navigator.language)}&nav=${encodeURIComponent(navigator.userAgent)}` -if (window.localStorage && window.localStorage.getItem('ignore')) { - ignore = localStorage.getItem('ignore') - url = `${url}&ignore=${ignore}` -} +let ignore = window?.localStorage?.getItem('ignore') +let urlBase = 'https://coryd.dev/api/event/' +let params = `site=${encodeURIComponent(window.location.origin)}&page=${encodeURIComponent(window.location.pathname)}&lang=${encodeURIComponent(navigator.language)}&nav=${encodeURIComponent(navigator.userAgent)}` +let url = `${urlBase}?${params}`; +if (ignore) url = `${urlBase}?ignore=${ignore}&${params}` if (!window.fathom) fetch(url).then(() => {}).catch(() => {}); \ No newline at end of file