mirror of
https://github.com/directus/directus.git
synced 2026-01-27 19:17:55 -05:00
Reset page track if you navigate multiple times within 2.5s
This commit is contained in:
@@ -117,12 +117,20 @@ export const onBeforeEach: NavigationGuard = async (to, from, next) => {
|
||||
return next();
|
||||
};
|
||||
|
||||
let trackTimeout: number | null= null;
|
||||
|
||||
export const onAfterEach = (to: Route) => {
|
||||
const userStore = useUserStore();
|
||||
|
||||
if (to.meta.public !== true) {
|
||||
// The timeout gives the page some breathing room to load. No need to clog up the thread with
|
||||
// this call while more important things are loading
|
||||
|
||||
if (trackTimeout) {
|
||||
clearTimeout(trackTimeout);
|
||||
trackTimeout = null;
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
userStore.trackPage(to.fullPath);
|
||||
}, 2500);
|
||||
|
||||
Reference in New Issue
Block a user