Commit a1ac506 1 parent e019d1e commit a1ac506 Copy full SHA for a1ac506
File tree 3 files changed +26
-17
lines changed
3 files changed +26
-17
lines changed Original file line number Diff line number Diff line change 37
37
},
38
38
"dependencies" : {
39
39
"defu" : " ^5.0.0" ,
40
- "ufo" : " ^0.7.9 " ,
40
+ "ufo" : " ^0.8.5 " ,
41
41
"web-vitals" : " ^2.1.0"
42
42
},
43
43
"devDependencies" : {
Original file line number Diff line number Diff line change @@ -3,17 +3,26 @@ import { sendToAnalytics } from '~vitals-provider'
3
3
4
4
const options = < %= JSON . stringify ( options , null , 2 ) % >
5
5
6
- export default function ( { app : { router } } ) {
7
- router . onReady ( ( to ) => {
8
- webVitals ( {
9
- options,
10
- sendToAnalytics,
11
- route : to
6
+ const sendVitals = ( to ) => webVitals ( {
7
+ options,
8
+ sendToAnalytics,
9
+ route : to
10
+ } )
11
+
12
+ export default async function ( ctx ) {
13
+ const router = ctx . app ?. router || ctx . $router
14
+ if ( ! router ) { return }
15
+
16
+ if ( 'isReady' in router ) {
17
+ // vue-router 4
18
+ await router . isReady ( )
19
+ sendVitals ( router . currentRoute )
20
+ router . afterEach ( ( to ) => sendVitals ( to ) )
21
+ } else {
22
+ // vue-router 3
23
+ router . onReady ( ( to ) => {
24
+ sendVitals ( to )
25
+ router . afterEach ( ( to ) => sendVitals ( to ) )
12
26
} )
13
- router . afterEach ( to => webVitals ( {
14
- options,
15
- sendToAnalytics,
16
- route : to
17
- } ) )
18
- } )
27
+ }
19
28
}
Original file line number Diff line number Diff line change @@ -9434,10 +9434,10 @@ ufo@^0.7.7:
9434
9434
resolved "https://registry.yarnpkg.com/ufo/-/ufo-0.7.7.tgz#0062f9e5e790819b0fb23ca24d7c63a4011c036a"
9435
9435
integrity sha512-N25aY3HBkJBnahm+2l4JRBBrX5I+JPakF/tDHYDTjd3wUR7iFLdyiPhj8mBwBz21v728BKwM9L9tgBfCntgdlw==
9436
9436
9437
- ufo@^0.7.9 :
9438
- version "0.7.9 "
9439
- resolved "https://registry.yarnpkg.com/ufo/-/ufo-0.7.9 .tgz#0268e3734b413c9ed6f3510201f42372821b875c "
9440
- integrity sha512-6t9LrLk3FhqTS+GW3IqlITtfRB5JAVr5MMNjpBECfK827W+Vh5Ilw/LhTcHWrt6b3hkeBvcbjx4Ti7QVFzmcww ==
9437
+ ufo@^0.8.5 :
9438
+ version "0.8.5 "
9439
+ resolved "https://registry.yarnpkg.com/ufo/-/ufo-0.8.5 .tgz#e367b4205ece9d9723f2fa54f887d43ed1bce5d0 "
9440
+ integrity sha512-e4+UtA5IRO+ha6hYklwj6r7BjiGMxS0O+UaSg9HbaTefg4kMkzj4tXzEBajRR+wkxf+golgAWKzLbytCUDMJAA ==
9441
9441
9442
9442
uglify-js@^3.1.4, uglify-js@^3.5.1 :
9443
9443
version "3.14.1"
You can’t perform that action at this time.
0 commit comments