async function analytics(url = window.location.href) {
const blacklist = ['/thumbnail/', 'Embedworker'];
const userAgent = navigator.userAgent;
if (blacklist.some(blacklistedURL => url.includes(blacklistedURL))) return;
else if (userAgent.includes('Googlebot')) return;
const { country, region, city } = await fetch(
'https://ipinfo.io/json'
).then(res => res.json());
const id = `${new Date().toISOString()}::${url}::${country}::${region}::${city}::${
navigator.userAgent
}`;
await fetch(db, {
method: 'post',
headers: new Headers({
Authorization: 'Basic ' + api_key,
'Content-Type': 'application/json'
}),
body: JSON.stringify({
_id: id
})
});
}