feat: 404 tracking

This commit is contained in:
Cory Dransfeldt 2024-11-26 15:37:43 -08:00
parent 9e72e0436f
commit f3aef3df2c
No known key found for this signature in database
8 changed files with 65 additions and 57 deletions

View file

@ -96,7 +96,14 @@ const pageDescription = md(description);
<script defer src="/scripts/index.js" is:inline></script>
{
isProduction && (
<script defer data-domain="coryd.dev" src="/js/script.js" />
<>
<script is:inline defer data-domain="coryd.dev" src="/js/script.js" />
<script is:inline defer>
window.plausible = window.plausible || function(...args) {
(window.plausible.q = window.plausible.q || []).push(args);
};
</script>
</>
)
}
<noscript>

View file

@ -58,3 +58,8 @@ const description = "What kind of idiots do you have working here?";
<hr />
<AddonLinks popularPosts={popularPosts} links={links} />
</Layout>
<script is:inline defer>
document.addEventListener("DOMContentLoaded", function () {
plausible("404", { props: { path: document.location.pathname } });
});
</script>

View file

@ -37,17 +37,9 @@ const description =
<h2 class="page-title">{title}</h2>
<p>
I've listened to{" "}
<strong class="highlight-text">
{music.week.artists.length} artists
</strong>
,{" "}
<strong class="highlight-text">
{music.week.albums.length} albums
</strong>
, and{" "}
<strong class="highlight-text">
{music.week.totalTracks} tracks
</strong>{" "}
<strong class="highlight-text">{music.week.artists.length} artists</strong>,{" "}
<strong class="highlight-text">{music.week.albums.length} albums</strong>, and{" "}
<strong class="highlight-text">{music.week.totalTracks} tracks</strong>{" "}
this week. Most of that has been{" "}
<span set:html={mediaLinks(music.week.genres, "genre", 5)}></span>.
</p>

View file

@ -31,9 +31,7 @@ const topGenres = mediaLinks(music.month.genres, "genre", 5);
>
<h2 class="page-title">{title}</h2>
<p>
I've listened to <strong class="highlight-text"
>{artistCount} artists</strong
>,
I've listened to <strong class="highlight-text">{artistCount} artists</strong>,
<strong class="highlight-text">{albumCount} albums</strong> and
<strong class="highlight-text">{totalTracks} tracks</strong> this month. Most
of that has been <span set:html={topGenres} />.

View file

@ -8625,7 +8625,7 @@
"loc": "https://coryd.dev/music/genres/alternative-metal"
},
{
"loc": "https://coryd.dev/watching/shows/30991"
"loc": "https://coryd.dev/watching/shows/126254"
},
{
"loc": "https://coryd.dev/watching/shows/71994"
@ -8648,12 +8648,6 @@
{
"loc": "https://coryd.dev/watching/shows/104157"
},
{
"loc": "https://coryd.dev/watching/shows/126254"
},
{
"loc": "https://coryd.dev/watching/shows/157065"
},
{
"loc": "https://coryd.dev/watching/shows/61222"
},
@ -8663,6 +8657,9 @@
{
"loc": "https://coryd.dev/watching/shows/62822"
},
{
"loc": "https://coryd.dev/watching/shows/1621"
},
{
"loc": "https://coryd.dev/watching/shows/1640"
},
@ -8703,7 +8700,7 @@
"loc": "https://coryd.dev/watching/shows/81241"
},
{
"loc": "https://coryd.dev/watching/shows/1621"
"loc": "https://coryd.dev/watching/shows/109939"
},
{
"loc": "https://coryd.dev/watching/shows/80707"
@ -8712,10 +8709,10 @@
"loc": "https://coryd.dev/watching/shows/76887"
},
{
"loc": "https://coryd.dev/watching/shows/109939"
"loc": "https://coryd.dev/watching/shows/137437"
},
{
"loc": "https://coryd.dev/watching/shows/137437"
"loc": "https://coryd.dev/watching/shows/1414"
},
{
"loc": "https://coryd.dev/watching/shows/202557"
@ -8724,7 +8721,10 @@
"loc": "https://coryd.dev/watching/shows/93784"
},
{
"loc": "https://coryd.dev/watching/shows/92553"
"loc": "https://coryd.dev/watching/shows/30991"
},
{
"loc": "https://coryd.dev/watching/shows/1398"
},
{
"loc": "https://coryd.dev/watching/shows/81239"
@ -8738,30 +8738,30 @@
{
"loc": "https://coryd.dev/watching/shows/80558"
},
{
"loc": "https://coryd.dev/watching/shows/1414"
},
{
"loc": "https://coryd.dev/watching/shows/1398"
},
{
"loc": "https://coryd.dev/watching/shows/15621"
},
{
"loc": "https://coryd.dev/watching/shows/233629"
},
{
"loc": "https://coryd.dev/watching/shows/76231"
},
{
"loc": "https://coryd.dev/watching/shows/136308"
},
{
"loc": "https://coryd.dev/watching/shows/157239"
},
{
"loc": "https://coryd.dev/watching/shows/233629"
},
{
"loc": "https://coryd.dev/watching/shows/76231"
},
{
"loc": "https://coryd.dev/watching/shows/47665"
},
{
"loc": "https://coryd.dev/watching/shows/1436"
},
{
"loc": "https://coryd.dev/watching/shows/111894"
},
{
"loc": "https://coryd.dev/watching/shows/17968"
},
@ -8781,31 +8781,34 @@
"loc": "https://coryd.dev/watching/shows/65708"
},
{
"loc": "https://coryd.dev/watching/shows/1436"
},
{
"loc": "https://coryd.dev/watching/shows/111894"
"loc": "https://coryd.dev/watching/shows/92553"
},
{
"loc": "https://coryd.dev/watching/shows/157061"
},
{
"loc": "https://coryd.dev/watching/shows/94028"
"loc": "https://coryd.dev/watching/shows/202879"
},
{
"loc": "https://coryd.dev/watching/shows/202879"
"loc": "https://coryd.dev/watching/shows/94028"
},
{
"loc": "https://coryd.dev/watching/shows/1107"
},
{
"loc": "https://coryd.dev/watching/shows/157065"
},
{
"loc": "https://coryd.dev/watching/shows/185"
},
{
"loc": "https://coryd.dev/watching/shows/90228"
"loc": "https://coryd.dev/watching/shows/688"
},
{
"loc": "https://coryd.dev/watching/shows/688"
"loc": "https://coryd.dev/watching/shows/125988"
},
{
"loc": "https://coryd.dev/watching/shows/90228"
},
{
"loc": "https://coryd.dev/watching/shows/124364"
@ -8816,9 +8819,6 @@
{
"loc": "https://coryd.dev/watching/shows/113962"
},
{
"loc": "https://coryd.dev/watching/shows/125988"
},
{
"loc": "https://coryd.dev/watching/shows/60694"
},

View file

@ -1,3 +1,4 @@
import { isBefore } from "date-fns";
import { createClient } from "@supabase/supabase-js";
import { CACHE_DURATION } from "@utils/constants/index.js";
@ -26,7 +27,11 @@ export async function fetchSyndication() {
const [{ syndication } = {}] = data;
const result =
syndication?.filter((item) => item.syndication !== null) || [];
syndication?.filter(
(item) =>
item.syndication !== null &&
isBefore(new Date(item.syndication.date), now)
) || [];
cachedSyndication = result;
lastFetchTime = now;