reset pushstate on plausible opt-out

This commit is contained in:
Zoe 2025-04-06 02:01:54 -05:00
parent 4c26c84219
commit 73b231b532
No known key found for this signature in database
1 changed files with 5 additions and 0 deletions

View File

@ -17,6 +17,7 @@
vertdLoaded,
} from "$lib/store/index.svelte";
import "../app.scss";
import { browser } from "$app/environment";
let { children, data } = $props();
let enablePlausible = $state(false);
@ -73,6 +74,10 @@
// Enable plausible if enabled
enablePlausible =
!!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>