Skip to content

Commit f9bb1c5

Browse files
committed
Switch analytics to whatsmytraffic, web build only
1 parent 4230dc1 commit f9bb1c5

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

src/app.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,5 @@
3232
</head>
3333
<body data-sveltekit-preload-data="hover">
3434
<div style="display: contents">%sveltekit.body%</div>
35-
<!-- whatsmytraffic Analytics -->
36-
<script defer src="https://whatsmytraffic.com/beacon.js" data-website-id="4fcc8497-cf99-4df4-bedd-36f46b4b9c72"></script>
3735
</body>
3836
</html>

src/routes/+layout.svelte

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
<script lang="ts">
2+
import { onMount } from 'svelte';
23
import '../app.css';
34
45
interface Props {
56
children: import('svelte').Snippet;
67
}
78
89
let { children }: Props = $props();
10+
11+
// whatsmytraffic-Analytics nur auf der Web-Version (view.pathsim.org),
12+
// nicht in der Standalone-/pip-Version.
13+
onMount(() => {
14+
if (location.hostname !== 'view.pathsim.org') return;
15+
const s = document.createElement('script');
16+
s.defer = true;
17+
s.src = 'https://whatsmytraffic.com/beacon.js';
18+
s.dataset.websiteId = '4fcc8497-cf99-4df4-bedd-36f46b4b9c72';
19+
document.head.appendChild(s);
20+
});
921
</script>
1022

1123
<div class="app">

0 commit comments

Comments
 (0)