Skip to content

Commit 4a6bab5

Browse files
Use Segment (#818)
Co-authored-by: Paulo Borges <paulohtb@hotmail.com>
1 parent 327cb56 commit 4a6bab5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

docs/.vuepress/client.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ const reload = () => {
4848
}
4949

5050
const leave = (to: RouteLocationNormalized, from: RouteLocationNormalized) => {
51-
if (from.path !== to.path && typeof window !== "undefined" && window.posthog !== undefined) {
52-
window.posthog.capture('$pageleave');
51+
if (from.path !== to.path && typeof window !== "undefined" && window.analytics !== undefined) {
52+
window.analytics.track({ event: "$pageleave" });
5353
}
5454
}
5555

@@ -110,6 +110,7 @@ export default defineClientConfig({
110110
if (typeof window === "undefined" || to.path === from.path || removeHtml(to.path) === removeHtml(from.path)) return;
111111
const esData = findEsMeta(to);
112112
const a = window.analytics;
113+
if(a){
113114
setTimeout(() => {
114115
a.page({
115116
site: "docs",
@@ -120,6 +121,7 @@ export default defineClientConfig({
120121
$host: window.location.hostname
121122
});
122123
}, 1000);
124+
}
123125
});
124126
router.beforeEach((to, from) => leave(to, from));
125127
},

0 commit comments

Comments
 (0)