Thread viewer for Bluesky
at master 30 lines 934 B view raw
1export function initAnalytics() { 2 if (window.location.protocol != 'https:') { return } 3 4 let _paq = window._paq = window._paq || []; 5 _paq.push(["setExcludedQueryParams", ['fbclid']]); 6 _paq.push(['setTrackerUrl', 'https://mackuba.eu/stat/matomo.php']); 7 _paq.push(['setCustomUrl', anonymizeParams(location.href)]); 8 _paq.push(["setRequestMethod", "GET"]); 9 _paq.push(['setSiteId', '13']); 10 _paq.push(["disableCookies"]); 11 _paq.push(["disableAlwaysUseSendBeacon"]); 12 _paq.push(['trackPageView']); 13} 14 15function anonymizeParams(url: string) { 16 let u = new URL(url); 17 let params = u.searchParams; 18 19 // turn e.g.: /?author=jcsalterego.bsky.social&post=3mci5wurx6c2c 20 // into: /?author=xxx&post=xxx 21 22 for (let key of params.keys()) { 23 if (['q', 'author', 'post', 'quotes', 'hash'].includes(key)) { 24 params.set(key, 'xxx'); 25 } 26 } 27 28 u.search = params.toString(); 29 return u.origin + u.pathname + u.search; 30}