mirror of
https://github.com/BradNut/boredgame
synced 2025-09-08 17:40:22 +00:00
Adding plausible analytics for testing.
This commit is contained in:
parent
ad74bc0f85
commit
fba22e7ebd
5 changed files with 82 additions and 67 deletions
|
|
@ -95,7 +95,7 @@
|
||||||
"@sveltejs/adapter-node": "^5.2.5",
|
"@sveltejs/adapter-node": "^5.2.5",
|
||||||
"@sveltejs/adapter-vercel": "^5.4.4",
|
"@sveltejs/adapter-vercel": "^5.4.4",
|
||||||
"@types/feather-icons": "^4.29.4",
|
"@types/feather-icons": "^4.29.4",
|
||||||
"bits-ui": "^0.21.13",
|
"bits-ui": "^0.21.16",
|
||||||
"boardgamegeekclient": "^1.9.1",
|
"boardgamegeekclient": "^1.9.1",
|
||||||
"bullmq": "^5.15.0",
|
"bullmq": "^5.15.0",
|
||||||
"class-variance-authority": "^0.7.0",
|
"class-variance-authority": "^0.7.0",
|
||||||
|
|
|
||||||
|
|
@ -72,8 +72,8 @@ importers:
|
||||||
specifier: ^4.29.4
|
specifier: ^4.29.4
|
||||||
version: 4.29.4
|
version: 4.29.4
|
||||||
bits-ui:
|
bits-ui:
|
||||||
specifier: ^0.21.13
|
specifier: ^0.21.16
|
||||||
version: 0.21.15(svelte@5.0.0-next.175)
|
version: 0.21.16(svelte@5.0.0-next.175)
|
||||||
boardgamegeekclient:
|
boardgamegeekclient:
|
||||||
specifier: ^1.9.1
|
specifier: ^1.9.1
|
||||||
version: 1.9.1
|
version: 1.9.1
|
||||||
|
|
@ -2334,8 +2334,8 @@ packages:
|
||||||
bindings@1.5.0:
|
bindings@1.5.0:
|
||||||
resolution: {integrity: sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==}
|
resolution: {integrity: sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==}
|
||||||
|
|
||||||
bits-ui@0.21.15:
|
bits-ui@0.21.16:
|
||||||
resolution: {integrity: sha512-+m5WSpJnFdCcNdXSTIVC1WYBozipO03qRh03GFWgrdxoHiolCfwW71EYG4LPCWYPG6KcTZV0Cj6iHSiZ7cdKdg==}
|
resolution: {integrity: sha512-XFZ7/bK7j/K+5iktxX/ZpmoFHjYjpPzP5EOO/4bWiaFg5TG1iMcfjDhlBTQnJxD6BoVoHuqeZPHZvaTgF4Iv3Q==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
svelte: ^4.0.0 || ^5.0.0-next.118
|
svelte: ^4.0.0 || ^5.0.0-next.118
|
||||||
|
|
||||||
|
|
@ -4121,8 +4121,8 @@ packages:
|
||||||
resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==}
|
resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==}
|
||||||
engines: {node: '>=8.10.0'}
|
engines: {node: '>=8.10.0'}
|
||||||
|
|
||||||
readdirp@4.0.1:
|
readdirp@4.0.2:
|
||||||
resolution: {integrity: sha512-GkMg9uOTpIWWKbSsgwb5fA4EavTR+SG/PMPoAY8hkhHfEEY0/vqljY+XHqtDf2cr2IJtoNRDbrrEpZUiZCkYRw==}
|
resolution: {integrity: sha512-yDMz9g+VaZkqBYS/ozoBJwaBhTbZo3UNYQHNRw1D3UFQB8oHB4uS/tAODO+ZLjGWmUbKnIlOWO+aaIiAxrUWHA==}
|
||||||
engines: {node: '>= 14.16.0'}
|
engines: {node: '>= 14.16.0'}
|
||||||
|
|
||||||
redis-errors@1.2.0:
|
redis-errors@1.2.0:
|
||||||
|
|
@ -6578,7 +6578,7 @@ snapshots:
|
||||||
dependencies:
|
dependencies:
|
||||||
file-uri-to-path: 1.0.0
|
file-uri-to-path: 1.0.0
|
||||||
|
|
||||||
bits-ui@0.21.15(svelte@5.0.0-next.175):
|
bits-ui@0.21.16(svelte@5.0.0-next.175):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@internationalized/date': 3.5.6
|
'@internationalized/date': 3.5.6
|
||||||
'@melt-ui/svelte': 0.76.2(svelte@5.0.0-next.175)
|
'@melt-ui/svelte': 0.76.2(svelte@5.0.0-next.175)
|
||||||
|
|
@ -6702,7 +6702,7 @@ snapshots:
|
||||||
|
|
||||||
chokidar@4.0.1:
|
chokidar@4.0.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
readdirp: 4.0.1
|
readdirp: 4.0.2
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
chownr@2.0.0: {}
|
chownr@2.0.0: {}
|
||||||
|
|
@ -8416,7 +8416,7 @@ snapshots:
|
||||||
dependencies:
|
dependencies:
|
||||||
picomatch: 2.3.1
|
picomatch: 2.3.1
|
||||||
|
|
||||||
readdirp@4.0.1:
|
readdirp@4.0.2:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
redis-errors@1.2.0: {}
|
redis-errors@1.2.0: {}
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,11 @@
|
||||||
<meta name="description" content="Bored? Find a game! Bored Game!" />
|
<meta name="description" content="Bored? Find a game! Bored Game!" />
|
||||||
<link rel="icon" href="%sveltekit.assets%/favicon-bored-game.svg" />
|
<link rel="icon" href="%sveltekit.assets%/favicon-bored-game.svg" />
|
||||||
<meta name="viewport" content="width=device-width" />
|
<meta name="viewport" content="width=device-width" />
|
||||||
<noscript>Please enable JavaScript.</noscript>
|
|
||||||
%sveltekit.head%
|
%sveltekit.head%
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body data-sveltekit-preload-data="hover">
|
<body>
|
||||||
<div id="svelte" style="display: contents">%sveltekit.body%</div>
|
<div id="svelte">%sveltekit.body%</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
13
src/lib/components/PlausibleAnalytics.svelte
Normal file
13
src/lib/components/PlausibleAnalytics.svelte
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
<script lang="ts">
|
||||||
|
import { PUBLIC_SITE_URL } from '$env/static/public'
|
||||||
|
const src = `${PUBLIC_SITE_URL}/js/script.js`
|
||||||
|
const dataDomain = PUBLIC_SITE_URL.replace('https://', '').replace('http://', '')
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<svelte:head>
|
||||||
|
<script
|
||||||
|
defer
|
||||||
|
data-domain={dataDomain}
|
||||||
|
{src}
|
||||||
|
></script>
|
||||||
|
</svelte:head>
|
||||||
|
|
@ -1,71 +1,73 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import '$lib/styles/app.pcss';
|
import '$lib/styles/app.pcss'
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte'
|
||||||
import { MetaTags } from 'svelte-meta-tags';
|
import { MetaTags } from 'svelte-meta-tags'
|
||||||
import { getFlash } from 'sveltekit-flash-message/client';
|
import { getFlash } from 'sveltekit-flash-message/client'
|
||||||
import 'iconify-icon';
|
import 'iconify-icon'
|
||||||
import { ModeWatcher } from 'mode-watcher';
|
import { onNavigate } from '$app/navigation'
|
||||||
import { Toaster } from '$lib/components/ui/sonner';
|
import { page } from '$app/stores'
|
||||||
import { onNavigate } from '$app/navigation';
|
import Analytics from '$components/Analytics.svelte'
|
||||||
import { page } from '$app/stores';
|
import PlausibleAnalytics from '$components/PlausibleAnalytics.svelte'
|
||||||
import Analytics from '$components/Analytics.svelte';
|
import { Toaster } from '$lib/components/ui/sonner'
|
||||||
import PageLoadingIndicator from '$lib/page_loading_indicator.svelte';
|
import PageLoadingIndicator from '$lib/page_loading_indicator.svelte'
|
||||||
import { theme } from '$state/theme';
|
import { toastMessage } from '$lib/utils/superforms.js'
|
||||||
import { toastMessage } from '$lib/utils/superforms.js';
|
import { theme } from '$state/theme'
|
||||||
|
import { ModeWatcher } from 'mode-watcher'
|
||||||
|
|
||||||
const dev = process.env.NODE_ENV !== 'production';
|
const dev = process.env.NODE_ENV !== 'production'
|
||||||
|
|
||||||
const { data, children } = $props();
|
const { data, children } = $props()
|
||||||
const { user } = data;
|
const { user } = data
|
||||||
|
|
||||||
const metaTags = $derived({
|
const metaTags = $derived({
|
||||||
|
titleTemplate: '%s | Bored Game',
|
||||||
|
description: 'Bored Game, keep track of your gamesTable.',
|
||||||
|
openGraph: {
|
||||||
|
type: 'website',
|
||||||
titleTemplate: '%s | Bored Game',
|
titleTemplate: '%s | Bored Game',
|
||||||
description: 'Bored Game, keep track of your gamesTable.',
|
locale: 'en_US',
|
||||||
openGraph: {
|
description: 'Bored Game, keep track of your gamesTable',
|
||||||
type: 'website',
|
},
|
||||||
titleTemplate: '%s | Bored Game',
|
...$page.data.metaTagsChild,
|
||||||
locale: 'en_US',
|
})
|
||||||
description: 'Bored Game, keep track of your gamesTable',
|
|
||||||
},
|
|
||||||
...$page.data.metaTagsChild,
|
|
||||||
});
|
|
||||||
|
|
||||||
const flash = getFlash(page, {
|
const flash = getFlash(page, {
|
||||||
clearOnNavigate: true,
|
clearOnNavigate: true,
|
||||||
clearAfterMs: 3000,
|
clearAfterMs: 3000,
|
||||||
clearArray: true,
|
clearArray: true,
|
||||||
});
|
})
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
// set the theme to the user's active theme
|
// set the theme to the user's active theme
|
||||||
$theme = user?.theme || 'system';
|
$theme = user?.theme || 'system'
|
||||||
document.querySelector('html')?.setAttribute('data-theme', $theme);
|
document.querySelector('html')?.setAttribute('data-theme', $theme)
|
||||||
});
|
})
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
console.log('flash', $flash);
|
console.log('flash', $flash)
|
||||||
if ($flash) {
|
if ($flash) {
|
||||||
toastMessage({ type: $flash.type, text: $flash.message });
|
toastMessage({ type: $flash.type, text: $flash.message })
|
||||||
// Clearing the flash message could sometimes
|
// Clearing the flash message could sometimes
|
||||||
// be required here to avoid double-toasting.
|
// be required here to avoid double-toasting.
|
||||||
flash.set(undefined);
|
flash.set(undefined)
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
onNavigate(async (navigation) => {
|
onNavigate(async (navigation) => {
|
||||||
if (!document.startViewTransition) return;
|
if (!document.startViewTransition) return
|
||||||
|
|
||||||
return new Promise((oldStateCaptureResolve) => {
|
return new Promise((oldStateCaptureResolve) => {
|
||||||
document.startViewTransition(async () => {
|
document.startViewTransition(async () => {
|
||||||
oldStateCaptureResolve();
|
oldStateCaptureResolve()
|
||||||
await navigation.complete;
|
await navigation.complete
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if !dev}
|
{#if !dev}
|
||||||
<Analytics />
|
<Analytics />
|
||||||
|
<PlausibleAnalytics />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<MetaTags {...metaTags} />
|
<MetaTags {...metaTags} />
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue