Skip to content

Commit aa0fa66

Browse files
committed
docs: add vercel insights
1 parent 5dce078 commit aa0fa66

File tree

3 files changed

+135
-14
lines changed

3 files changed

+135
-14
lines changed

docs/app/plugins/vercel.client.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { inject, pageview } from '@vercel/analytics'
2+
import { injectSpeedInsights } from '@vercel/speed-insights'
3+
4+
export default defineNuxtPlugin(() => {
5+
if (import.meta.dev) return
6+
7+
const nuxtApp = useNuxtApp()
8+
const route = useRoute()
9+
const speedInsights = injectSpeedInsights({
10+
route: route.matched[0]?.path || route.path,
11+
framework: 'nuxt',
12+
})
13+
14+
onNuxtReady(() => {
15+
inject({
16+
disableAutoTrack: true,
17+
framework: 'nuxt',
18+
})
19+
pageview({
20+
route: route.matched[0]?.path || route.path,
21+
path: route.path,
22+
})
23+
})
24+
// On navigation to a new page
25+
nuxtApp.hooks.hook('page:finish', () => {
26+
pageview({
27+
route: route.matched[0]?.path || route.path,
28+
path: route.path,
29+
})
30+
speedInsights?.setRoute(route.matched[0]?.path || route.path)
31+
})
32+
})

docs/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
"@nuxt/ui": "^4.1.0",
1111
"@nuxthub/core": "npm:@nuxthub/core-nightly@1.0.0-20251028-004316-83d4099",
1212
"@nuxtjs/plausible": "^2.0.1",
13+
"@vercel/analytics": "^1.5.0",
14+
"@vercel/speed-insights": "^1.2.0",
1315
"@vueuse/nuxt": "^14.0.0",
1416
"better-sqlite3": "^12.4.1",
1517
"docus": "^5.2.1",

0 commit comments

Comments
 (0)