Introduce analytics
This commit is contained in:
19
plugins/aptabase.client.ts
Normal file
19
plugins/aptabase.client.ts
Normal 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),
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user