Skip to content

Commit

Permalink
Merge pull request #404 from DeterminateSystems/fix-the-back-button
Browse files Browse the repository at this point in the history
Fix the back button
  • Loading branch information
lucperkins authored Jan 9, 2025
2 parents aea42c7 + d4c47e7 commit 07323bc
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/components/Posthog.astro
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@
window.posthog = posthog;

(() => {
const urlParams = new URLSearchParams(window.location.search);
const phid = urlParams.get("phid");
const newUrl = new URL(window.location.toString());
const phid = newUrl.searchParams.get('phid');

if (phid) {
if (window.posthog) {
window.posthog.alias(phid)
}
urlParams.delete("phid");
window.location.search = urlParams.toString();

newUrl.searchParams.delete('phid');
window.history.replaceState(window.history.state, '', newUrl);
}
})();
</script>

0 comments on commit 07323bc

Please sign in to comment.