File tree Expand file tree Collapse file tree 3 files changed +135
-14
lines changed Expand file tree Collapse file tree 3 files changed +135
-14
lines changed Original file line number Diff line number Diff line change 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+ } )
Original file line number Diff line number Diff line change 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" ,
You can’t perform that action at this time.
0 commit comments