Introduce analytics

This commit is contained in:
2025-05-22 16:01:34 +03:00
parent e080f3978c
commit 76338eff71
4 changed files with 40 additions and 2 deletions

View File

@@ -0,0 +1,19 @@
import { init, trackEvent } from "@aptabase/web";
export default defineNuxtPlugin((nuxtApp) => {
const config = useRuntimeConfig();
nuxtApp.hook("app:mounted", () => {
init(config.public.aptabaseAppKey, { isDebug: import.meta.dev });
});
nuxtApp.hook("page:finish", (ctx) => {
const route = useRoute();
trackEvent("page_view", {
path: route.path,
name: String(route.name),
redirectedFrom: String(route.redirectedFrom),
});
});
});