Skip to content

Commit

Permalink
Send our own pageLoad, routeChanged events (#2044)
Browse files Browse the repository at this point in the history
  • Loading branch information
visnup committed Apr 4, 2024
1 parent 210b0d2 commit 00610bb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/.vitepress/theme/index.ts
Expand Up @@ -17,11 +17,11 @@ export default {
}
};

async function enableAnalytics(router) {
function enableAnalytics(router) {
if (typeof location === "undefined" || location.origin !== "https://observablehq.com") return;
const {pageLoad, routeChanged} = await import("https://events.observablehq.com/client.js?pageLoad");
let pageLoaded = false;
watch(router.route, () => {
watch(router.route, async () => {
const {pageLoad, routeChanged} = await import("https://events.observablehq.com/client.js");
if (pageLoaded) {
routeChanged();
} else {
Expand Down

0 comments on commit 00610bb

Please sign in to comment.