reset pushstate on plausible opt-out (#48)

This commit is contained in:
juls0730 2025-04-07 11:14:20 -05:00 committed by GitHub
parent 4c26c84219
commit 2c8cb1922c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 0 deletions

View File

@ -17,6 +17,7 @@
vertdLoaded, vertdLoaded,
} from "$lib/store/index.svelte"; } from "$lib/store/index.svelte";
import "../app.scss"; import "../app.scss";
import { browser } from "$app/environment";
let { children, data } = $props(); let { children, data } = $props();
let enablePlausible = $state(false); let enablePlausible = $state(false);
@ -73,6 +74,10 @@
// Enable plausible if enabled // Enable plausible if enabled
enablePlausible = enablePlausible =
!!PUB_PLAUSIBLE_URL && Settings.instance.settings.plausible; !!PUB_PLAUSIBLE_URL && Settings.instance.settings.plausible;
if (!enablePlausible && browser) {
// reset pushState on opt-out so that plausible stops firing events on page navigation
history.pushState = History.prototype.pushState;
}
}); });
</script> </script>