Handle umami errors
All checks were successful
Build and copy to prod / build-and-copy (push) Successful in 3m14s

This commit is contained in:
Lewis Dale 2024-11-21 10:24:15 +00:00
parent 5b29791fe0
commit 7c8115b298
2 changed files with 9 additions and 3 deletions

View File

@ -94,5 +94,6 @@ const fetchLatest = async (cache = []) => {
}
export default async function() {
return await fetchLatest(cachedContent());
return [];
// return await fetchLatest(cachedContent());
}

View File

@ -10,6 +10,7 @@ export default async function(arg) {
url.searchParams.append("startAt", 0);
url.searchParams.append("endAt", Date.now());
url.searchParams.append("type", "url");
try {
const metrics = await EleventyFetch(url.toString(), {
duration: '1h',
@ -18,10 +19,14 @@ export default async function(arg) {
headers: {
"Authorization": `Bearer ${apiKey}`,
"Accept": "application/json"
}
}
},
},
})
return metrics.filter(metric => postRegex.test(metric.x))
.map(({ x, y }) => ({ post: x, count: y }));
} catch (e) {
console.error(e);
return [];
}
}