tangled
alpha
login
or
join now
mackuba.eu
/
skythread
14
fork
atom
Thread viewer for Bluesky
14
fork
atom
overview
issues
pulls
pipelines
added matomo analytics
mackuba.eu
1 month ago
019a174b
2e1d9dbc
+35
-1
4 changed files
expand all
collapse all
unified
split
index.html
src
services
analytics.ts
skythread.ts
types.d.ts
+2
-1
index.html
···
4
4
<meta charset="UTF-8">
5
5
<meta http-equiv="Content-Security-Policy" content="
6
6
default-src 'none';
7
7
-
script-src 'self';
7
7
+
script-src 'self' https://mackuba.eu;
8
8
style-src 'self';
9
9
img-src 'self' https:;
10
10
font-src 'self';
···
26
26
</head>
27
27
<body>
28
28
<script src="dist/skythread.js"></script>
29
29
+
<script src="https://mackuba.eu/stat/matomo.js"></script>
29
30
</body>
30
31
</html>
+30
src/services/analytics.ts
···
1
1
+
export function initAnalytics() {
2
2
+
if (window.location.protocol != 'https:') { return }
3
3
+
4
4
+
let _paq = window._paq = window._paq || [];
5
5
+
_paq.push(["setExcludedQueryParams", ['fbclid']]);
6
6
+
_paq.push(['setTrackerUrl', 'https://mackuba.eu/stat/matomo.php']);
7
7
+
_paq.push(['setCustomUrl', anonymizeParams(location.href)]);
8
8
+
_paq.push(["setRequestMethod", "GET"]);
9
9
+
_paq.push(['setSiteId', '13']);
10
10
+
_paq.push(["disableCookies"]);
11
11
+
_paq.push(["disableAlwaysUseSendBeacon"]);
12
12
+
_paq.push(['trackPageView']);
13
13
+
}
14
14
+
15
15
+
function anonymizeParams(url: string) {
16
16
+
let u = new URL(url);
17
17
+
let params = u.searchParams;
18
18
+
19
19
+
// turn e.g.: /?author=jcsalterego.bsky.social&post=3mci5wurx6c2c
20
20
+
// into: /?author=xxx&post=xxx
21
21
+
22
22
+
for (let key of params.keys()) {
23
23
+
if (['q', 'author', 'post', 'quotes', 'hash'].includes(key)) {
24
24
+
params.set(key, 'xxx');
25
25
+
}
26
26
+
}
27
27
+
28
28
+
u.search = params.toString();
29
29
+
return u.origin + u.pathname + u.search;
30
30
+
}
+2
src/skythread.ts
···
1
1
import { mount } from 'svelte';
2
2
import { parseURLParams } from './router.js';
3
3
import App from './App.svelte';
4
4
+
import { initAnalytics } from './services/analytics.js';
4
5
5
6
function init() {
6
7
let params = parseURLParams(location.search);
···
8
9
}
9
10
10
11
document.addEventListener("DOMContentLoaded", init);
12
12
+
initAnalytics();
+1
src/types.d.ts
···
1
1
interface Window {
2
2
root: AnyPost;
3
3
subtreeRoot: AnyPost;
4
4
+
_paq?: any[][];
4
5
}
5
6
6
7
type json = Record<string, any>;